@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace PhpBotFramework\Core; |
| 4 | 4 | |
| 5 | 5 | use PhpBotFramework\Exceptions\BotException; |
| 6 | - |
|
| 7 | 6 | use PhpBotFramework\Entities\Message; |
| 8 | 7 | use PhpBotFramework\Entities\CallbackQuery; |
| 9 | 8 | use PhpBotFramework\Entities\ChosenInlineResult; |
@@ -232,7 +232,6 @@ |
||
| 232 | 232 | * \brief Called every time a post get edited in the channel where the bot is in. |
| 233 | 233 | * \details Override it to script the bot answer for each post edited in a channel. |
| 234 | 234 | * <code>$chat_id</code> set inside of this function. |
| 235 | - * @param Message $post The message edited in the channel. |
|
| 236 | 235 | */ |
| 237 | 236 | protected function processEditedChannelPost(Message $edited_post) |
| 238 | 237 | { |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | |
| 101 | 101 | // Exec getUpdates |
| 102 | 102 | $this->execRequest('getUpdates?' . http_build_query($parameters) |
| 103 | - . '&allowed_updates=' . json_encode($allowed_updates)); |
|
| 103 | + . '&allowed_updates=' . json_encode($allowed_updates)); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** @} */ |
@@ -18,8 +18,6 @@ |
||
| 18 | 18 | |
| 19 | 19 | namespace PhpBotFramework\Test; |
| 20 | 20 | |
| 21 | -use PhpBotFramework\Entities\Message; |
|
| 22 | - |
|
| 23 | 21 | /* \class FakeUpdate |
| 24 | 22 | * \brief Contains abstract methods for processing fake updates. |
| 25 | 23 | */ |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | // Get the language from the bot |
| 63 | 63 | $sth = $this->pdo->prepare('SELECT language FROM ' . $this->user_table . ' WHERE ' |
| 64 | - . $this->id_column . ' = :chat_id'); |
|
| 64 | + . $this->id_column . ' = :chat_id'); |
|
| 65 | 65 | $sth->bindParam(':chat_id', $this->_chat_id); |
| 66 | 66 | |
| 67 | 67 | try { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // Update the language in the database |
| 99 | 99 | $sth = $this->pdo->prepare('UPDATE ' . $this->user_table . ' SET language = :language WHERE ' |
| 100 | - . $this->id_column . ' = :id'); |
|
| 100 | + . $this->id_column . ' = :id'); |
|
| 101 | 101 | $sth->bindParam(':language', $language); |
| 102 | 102 | $sth->bindParam(':id', $this->_chat_id); |
| 103 | 103 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | * \brief Set current chat ID. |
| 402 | 402 | * \details Change the chat ID on which the bot acts. |
| 403 | - * @param $chat_id The new chat ID to set. |
|
| 403 | + * @param string $chat_id The new chat ID to set. |
|
| 404 | 404 | */ |
| 405 | 405 | public function setChatID($chat_id) |
| 406 | 406 | { |
@@ -460,7 +460,6 @@ discard block |
||
| 460 | 460 | * \brief Process an API method by taking method and parameter. |
| 461 | 461 | * \details optionally create a object of $class class name with the response as constructor param. |
| 462 | 462 | * @param string $method Method to call. |
| 463 | - * @param array $param Parameter for the method. |
|
| 464 | 463 | * @param string $class Class name of the object to create using response. |
| 465 | 464 | * @return mixed Response or object of $class class name. |
| 466 | 465 | */ |
@@ -533,6 +532,9 @@ discard block |
||
| 533 | 532 | return $this->checkRequestError($response); |
| 534 | 533 | } |
| 535 | 534 | |
| 535 | + /** |
|
| 536 | + * @param \Psr\Http\Message\ResponseInterface $response |
|
| 537 | + */ |
|
| 536 | 538 | public function checkRequestError($response) |
| 537 | 539 | { |
| 538 | 540 | $http_code = $response->getStatusCode(); |
@@ -19,9 +19,7 @@ |
||
| 19 | 19 | namespace PhpBotFramework\Core; |
| 20 | 20 | |
| 21 | 21 | use PhpBotFramework\Exceptions\BotException; |
| 22 | - |
|
| 23 | 22 | use PhpBotFramework\Entities\File as TelegramFile; |
| 24 | - |
|
| 25 | 23 | use PhpBotFramework\Entities\InlineKeyboard; |
| 26 | 24 | |
| 27 | 25 | /** |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | namespace PhpBotFramework\Core; |
| 20 | 20 | |
| 21 | 21 | use PhpBotFramework\Entities\Message; |
| 22 | - |
|
| 23 | 22 | use PhpBotFramework\Entities\File as TelegramFile; |
| 24 | 23 | |
| 25 | 24 | trait Send |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | $offset = $this->getUpdateOffsetRedis($offset_key); |
| 96 | 96 | $this->initCommands(); |
| 97 | 97 | |
| 98 | - // Process all updates received |
|
| 98 | + // Process all updates received |
|
| 99 | 99 | while (true) { |
| 100 | 100 | $updates = $this->getUpdates($offset, $limit, $timeout); |
| 101 | 101 | |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | */ |
| 79 | 79 | protected function addDefaultValue(array $params) : array |
| 80 | 80 | { |
| 81 | - static $defaults = [ 'adapter' => PDO_DEFAULT_ADAPTER, 'host' => 'localhost', 'options' => [] ]; |
|
| 81 | + static $defaults = ['adapter' => PDO_DEFAULT_ADAPTER, 'host' => 'localhost', 'options' => []]; |
|
| 82 | 82 | return array_merge($defaults, $params); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -8,21 +8,21 @@ discard block |
||
| 8 | 8 | require_once '../../vendor/autoload.php'; |
| 9 | 9 | |
| 10 | 10 | class WhoAmIBot extends PhpBotFramework\Bot { |
| 11 | - // Override 'processMessage' in order to intercept the message and |
|
| 12 | - // get information about its author (if forwarded, its original author). |
|
| 13 | - protected function processMessage($message) { |
|
| 11 | + // Override 'processMessage' in order to intercept the message and |
|
| 12 | + // get information about its author (if forwarded, its original author). |
|
| 13 | + protected function processMessage($message) { |
|
| 14 | 14 | // Check if the message was forward |
| 15 | 15 | isset($message['forward_from']) ? $index = 'forward_from' : $index = 'from'; |
| 16 | 16 | |
| 17 | 17 | $response = $this->prepareResponse($message[$index]); |
| 18 | 18 | $this->sendMessage($response); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - private function prepareResponse($user) { |
|
| 21 | + private function prepareResponse($user) { |
|
| 22 | 22 | return '<strong>Message sent by </strong>' . $user['first_name'] . "\n" . |
| 23 | - '<strong>User ID: </strong>' . $user['id'] . "\n" . |
|
| 24 | - '<strong>Username: </strong>' . $user['username'] . "\n"; |
|
| 25 | - } |
|
| 23 | + '<strong>User ID: </strong>' . $user['id'] . "\n" . |
|
| 24 | + '<strong>Username: </strong>' . $user['username'] . "\n"; |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // Add a welcome message |
| 32 | 32 | $bot->addMessageCommand('start', function ($bot, $message) { |
| 33 | - $bot->sendMessage('<strong>Hey there!</strong> Send or forward me a text message :)'); |
|
| 33 | + $bot->sendMessage('<strong>Hey there!</strong> Send or forward me a text message :)'); |
|
| 34 | 34 | }); |
| 35 | 35 | |
| 36 | 36 | $bot->getUpdatesLocal(); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $bot = new WhoAmIBot('YOUR_BOT_TOKEN'); |
| 30 | 30 | |
| 31 | 31 | // Add a welcome message |
| 32 | -$bot->addMessageCommand('start', function ($bot, $message) { |
|
| 32 | +$bot->addMessageCommand('start', function($bot, $message) { |
|
| 33 | 33 | $bot->sendMessage('<strong>Hey there!</strong> Send or forward me a text message :)'); |
| 34 | 34 | }); |
| 35 | 35 | |