Permalink
Browse files

added avatar support and endpoint to send messages to user

  • Loading branch information...
david p
david p committed Feb 16, 2016
1 parent eaa4768 commit ca912396c35aaa048c8a2d46767c213b4b68acec
View
@@ -12,6 +12,8 @@ SESSION_DRIVER=file
QUEUE_DRIVER=sync
URL=<your_domain>
AVATAR_DIR=<path/to/directory>
AVATAR_LOCAL_DIR=</local/absolute/path/to/directory>
BOT_NAME=<bot_name>
BOT_TOKEN=<bot_token>
@@ -0,0 +1,53 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Webhook extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'webhook:set';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Set Telegram webhook';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$url = env('URL').'/receive/'.env('WEBHOOK_TOKEN');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.telegram.org/bot'.env('BOT_TOKEN').'/setWebhook');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('url' => $url));
$json = curl_exec($ch);
$result = json_decode($json, true);
if($result['ok'])
$this->info('Webhook was set to '.$url);
else
$this->error($json);
}
}
View
@@ -14,7 +14,8 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
Commands\CodeDelete::class,
Commands\TokenDelete::class
Commands\TokenDelete::class,
Commands\Webhook::class
];
/**
Oops, something went wrong.

0 comments on commit ca91239

Please sign in to comment.