@@ -30,56 +30,56 @@ |
||
| 30 | 30 | class TelegramController extends Controller |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - public function setupWebhookAction($secret) |
|
| 34 | - { |
|
| 35 | - $api = $this->get("buktopuha.telegram_bot_api"); |
|
| 36 | - $config = $this->getParameter("buktopuha.config"); |
|
| 33 | + public function setupWebhookAction($secret) |
|
| 34 | + { |
|
| 35 | + $api = $this->get("buktopuha.telegram_bot_api"); |
|
| 36 | + $config = $this->getParameter("buktopuha.config"); |
|
| 37 | 37 | |
| 38 | - if (empty($config['webhook']['domain'])) { |
|
| 39 | - throw new Exception("buktopuha.webhook.domain' is not set in config.yml", 0); |
|
| 40 | - } |
|
| 41 | - $url = "https://" . $config['webhook']['domain'] . $config['webhook']['path_prefix'] . "/telegram-bot/update"; |
|
| 42 | - if (null !== $secret) { |
|
| 43 | - $url .= "/" . $secret; |
|
| 44 | - } |
|
| 45 | - $res = $api->setwebhook($url); |
|
| 46 | - return new JsonResponse([ |
|
| 47 | - 'ok' => $res, |
|
| 48 | - 'url' => $url |
|
| 49 | - ]); |
|
| 50 | - } |
|
| 38 | + if (empty($config['webhook']['domain'])) { |
|
| 39 | + throw new Exception("buktopuha.webhook.domain' is not set in config.yml", 0); |
|
| 40 | + } |
|
| 41 | + $url = "https://" . $config['webhook']['domain'] . $config['webhook']['path_prefix'] . "/telegram-bot/update"; |
|
| 42 | + if (null !== $secret) { |
|
| 43 | + $url .= "/" . $secret; |
|
| 44 | + } |
|
| 45 | + $res = $api->setwebhook($url); |
|
| 46 | + return new JsonResponse([ |
|
| 47 | + 'ok' => $res, |
|
| 48 | + 'url' => $url |
|
| 49 | + ]); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function updateAction($secret, Request $request) |
|
| 53 | - { |
|
| 54 | - $data0 = $request->getContent(); |
|
| 52 | + public function updateAction($secret, Request $request) |
|
| 53 | + { |
|
| 54 | + $data0 = $request->getContent(); |
|
| 55 | 55 | |
| 56 | - $data = json_decode($data0); |
|
| 56 | + $data = json_decode($data0); |
|
| 57 | 57 | |
| 58 | - $api = $this->get("buktopuha.telegram_bot_api"); |
|
| 59 | - $config = $this->getParameter("buktopuha.config"); |
|
| 58 | + $api = $this->get("buktopuha.telegram_bot_api"); |
|
| 59 | + $config = $this->getParameter("buktopuha.config"); |
|
| 60 | 60 | |
| 61 | - if (empty($config['webhook']['update_receiver'])) { |
|
| 62 | - throw new Exception("'webhook.update_receiver' is not valud service name", 0); |
|
| 63 | - } |
|
| 61 | + if (empty($config['webhook']['update_receiver'])) { |
|
| 62 | + throw new Exception("'webhook.update_receiver' is not valud service name", 0); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $updateReceiver = $this->getUpdateReceiverService($config['webhook']['update_receiver']); |
|
| 65 | + $updateReceiver = $this->getUpdateReceiverService($config['webhook']['update_receiver']); |
|
| 66 | 66 | |
| 67 | - $update = new Update($data); |
|
| 67 | + $update = new Update($data); |
|
| 68 | 68 | |
| 69 | - $updateReceiver->handleUpdate($update); |
|
| 69 | + $updateReceiver->handleUpdate($update); |
|
| 70 | 70 | |
| 71 | - return new JsonResponse([ |
|
| 72 | - 'ok' => true |
|
| 73 | - ]); |
|
| 74 | - } |
|
| 71 | + return new JsonResponse([ |
|
| 72 | + 'ok' => true |
|
| 73 | + ]); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * |
|
| 78 | - * @return UpdateReceiverInterface |
|
| 79 | - */ |
|
| 80 | - protected function getUpdateReceiverService($serviceName) |
|
| 81 | - { |
|
| 82 | - return $this->container |
|
| 83 | - ->get($serviceName); |
|
| 84 | - } |
|
| 76 | + /** |
|
| 77 | + * |
|
| 78 | + * @return UpdateReceiverInterface |
|
| 79 | + */ |
|
| 80 | + protected function getUpdateReceiverService($serviceName) |
|
| 81 | + { |
|
| 82 | + return $this->container |
|
| 83 | + ->get($serviceName); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | class BuktopuhaBotApi extends BotApi |
| 9 | 9 | { |
| 10 | - public function __construct(Container $container) |
|
| 11 | - { |
|
| 12 | - $token = $container->getParameter('buktopuha.config'); |
|
| 13 | - parent::__construct($token['token']); |
|
| 14 | - } |
|
| 10 | + public function __construct(Container $container) |
|
| 11 | + { |
|
| 12 | + $token = $container->getParameter('buktopuha.config'); |
|
| 13 | + parent::__construct($token['token']); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param string $token |
|
| 18 | - */ |
|
| 19 | - public function setToken($token) |
|
| 20 | - { |
|
| 21 | - $this->token = $token; |
|
| 22 | - } |
|
| 16 | + /** |
|
| 17 | + * @param string $token |
|
| 18 | + */ |
|
| 19 | + public function setToken($token) |
|
| 20 | + { |
|
| 21 | + $this->token = $token; |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -27,8 +27,8 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class AppBundle extends Bundle |
| 29 | 29 | { |
| 30 | - public function getContainerExtension() |
|
| 31 | - { |
|
| 32 | - return new BuktopuhaExtension(); |
|
| 33 | - } |
|
| 30 | + public function getContainerExtension() |
|
| 31 | + { |
|
| 32 | + return new BuktopuhaExtension(); |
|
| 33 | + } |
|
| 34 | 34 | } |