} return require __DIR__ . '/../config/bots/' . $config['bots'][$bot] . '.php'; }); $app->get('/set_webhook/{bot}', function ($bot, Request $request) use($app, $config, $get_bot_config) { $bot_config = $get_bot_config($bot); //Let's make a new guzzle connection and set the hook: $client = new GuzzleHttp\Client(); $res = $client->get('https://api.telegram.org/bot' . $bot_config['token'] . '/setWebhook?url=https://' . $request->getHttpHost() . '/hook/' . $bot); return $res->getBody(); }); $app->post('/hook/{route}', function ($route) use($app, $config, $get_bot_config) { $bot_config = $get_bot_config($route); $response = file_get_contents('php://input'); $response_data = json_decode($response, true); $helper = new BotHelper($config, $route); $response = $helper->fetchMessage($bot_config, $response_data); //If its markup is like a command, just ignore it. //TODO this feature will be enabled in future versions. if (!$response) { return 'OK'; } //now let's reply! //https://core.telegram.org/bots/api#sendmessage $client = new GuzzleHttp\Client(); if ($config['source'] == 'file') { //try { $client->get('https://api.telegram.org/bot' . $bot_config['token'] . '/sendMessage?' . http_build_query($response['data'])); /*} catch(Exception $e) { //You can catch exceptions and log etc here by uncommenting try/catch statement. }*/ } else {