-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace BotMan\Drivers\Telegram\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class TelegramRegisterCommand extends Command | ||
{ | ||
/** | ||
* The console command signature. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'botman:telegram:register {--output}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Register your bot with Telegram\'s webhook'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$url = 'https://api.telegram.org/bot' | ||
.config('botman.telegram.token') | ||
.'/setWebhook?url=' | ||
.$this->ask('What is the target url for the telegram bot?'); | ||
|
||
$this->info('Using '.$url); | ||
|
||
$this->info('Pinging Telegram...'); | ||
|
||
$output = json_decode(file_get_contents($url)); | ||
|
||
if ($output->ok == true && $output->result == true) { | ||
$this->info('Your bot is now set up with Telegram\'s webhook!'); | ||
} | ||
|
||
if ($this->option('output')) { | ||
dump($output); | ||
} | ||
} | ||
} |