File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ class TelegramRegisterCommand extends Command
11
11
*
12
12
* @var string
13
13
*/
14
- protected $ signature = 'botman:telegram:register {--output} ' ;
14
+ protected $ signature = 'botman:telegram:register {--remove} {-- output} ' ;
15
15
16
16
/**
17
17
* The console command description.
18
18
*
19
19
* @var string
20
20
*/
21
- protected $ description = 'Register your bot with Telegram \'s webhook ' ;
21
+ protected $ description = 'Register or unregister your bot with Telegram \'s webhook ' ;
22
22
23
23
/**
24
24
* Execute the console command.
@@ -29,8 +29,13 @@ public function handle()
29
29
{
30
30
$ url = 'https://api.telegram.org/bot '
31
31
.config ('botman.telegram.token ' )
32
- .'/setWebhook?url= '
33
- .$ this ->ask ('What is the target url for the telegram bot? ' );
32
+ .'/setWebhook ' ;
33
+
34
+ $ remove = $ this ->option ('remove ' , null );
35
+
36
+ if (! $ remove ) {
37
+ $ url .= '?url= ' .$ this ->ask ('What is the target url for the telegram bot? ' );
38
+ }
34
39
35
40
$ this ->info ('Using ' .$ url );
36
41
@@ -39,7 +44,10 @@ public function handle()
39
44
$ output = json_decode (file_get_contents ($ url ));
40
45
41
46
if ($ output ->ok == true && $ output ->result == true ) {
42
- $ this ->info ('Your bot is now set up with Telegram \'s webhook! ' );
47
+ $ this ->info ($ remove
48
+ ? 'Your bot Telegram \'s webhook has been removed! '
49
+ : 'Your bot is now set up with Telegram \'s webhook! '
50
+ );
43
51
}
44
52
45
53
if ($ this ->option ('output ' )) {
You can’t perform that action at this time.
0 commit comments