Skip to content

Commit

Permalink
Merge branch 'Jeroen-G-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Oct 5, 2017
2 parents d23c6bf + 57dd111 commit d971cc5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"BotMan\\Drivers\\Telegram\\TelegramLocationDriver",
"BotMan\\Drivers\\Telegram\\TelegramPhotoDriver",
"BotMan\\Drivers\\Telegram\\TelegramVideoDriver"
],
"botman/commands": [
"BotMan\\Drivers\\Telegram\\Console\\Commands\\TelegramRegisterCommand"
]
}
49 changes: 49 additions & 0 deletions src/Console/Commands/TelegramRegisterCommand.php
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);
}
}
}

0 comments on commit d971cc5

Please sign in to comment.