diff --git a/src/Console/Commands/TelegramRegisterCommand.php b/src/Console/Commands/TelegramRegisterCommand.php index 3f6bcee..dda5d2b 100644 --- a/src/Console/Commands/TelegramRegisterCommand.php +++ b/src/Console/Commands/TelegramRegisterCommand.php @@ -35,6 +35,7 @@ public function handle() if (! $remove) { $url .= '?url='.$this->ask('What is the target url for the telegram bot?'); + $url .= '&secret_token='.str_replace(':', '_', env('TELEGRAM_TOKEN')); } $this->info('Using '.$url); diff --git a/src/TelegramDriver.php b/src/TelegramDriver.php index 78c07b1..21cb3ff 100644 --- a/src/TelegramDriver.php +++ b/src/TelegramDriver.php @@ -61,6 +61,12 @@ public function buildPayload(Request $request) $this->event = Collection::make($message); $this->config = Collection::make($this->config->get('telegram')); $this->queryParameters = Collection::make($request->query); + + $token = $request->headers->get('X-Telegram-Bot-Api-Secret-Token'); + + if ($token !== str_replace(':', '_', $this->config->get('token'))) { + throw new \Exception('Token mismatch!'); + } } /**