@@ -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 | /** @} */ |
@@ -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 | |
@@ -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(); |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | require_once '../../vendor/autoload.php'; |
| 10 | 10 | |
| 11 | 11 | class EchoBot extends PhpBotFramework\Bot { |
| 12 | - // Override processMessage in order to send user the same message it give us. |
|
| 13 | - protected function processMessage($message) { |
|
| 12 | + // Override processMessage in order to send user the same message it give us. |
|
| 13 | + protected function processMessage($message) { |
|
| 14 | 14 | $this->sendMessage($message['text']); |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | $bot = new EchoBot('YOUR_BOT_TOKEN'); |
@@ -102,10 +102,4 @@ |
||
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - return $message; |
|
| 106 | - } |
|
| 107 | -} |
|
| 108 | - |
|
| 109 | -/* |
|
| 110 | - * @} |
|
| 111 | - */ |
|
| 105 | + return $message |
|
| 112 | 106 | \ No newline at end of file |
@@ -63,6 +63,4 @@ |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // If not return the data from the array after checking it is set |
| 66 | - return isset($this->container[$offset]) ? $this->container[$offset] : null; |
|
| 67 | - } |
|
| 68 | -} |
|
| 66 | + return isset($this->container[$offset]) ? $this->container[$offset |
|
| 69 | 67 | \ No newline at end of file |
@@ -38,15 +38,15 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | 40 | /** @internal |
| 41 | - * \brief Reference to the bot. */ |
|
| 41 | + * \brief Reference to the bot. */ |
|
| 42 | 42 | protected $bot; |
| 43 | 43 | |
| 44 | 44 | /** @internal |
| 45 | - * \brief Current user/group language. */ |
|
| 45 | + * \brief Current user/group language. */ |
|
| 46 | 46 | public $language; |
| 47 | 47 | |
| 48 | 48 | /** @internal |
| 49 | - * \brief Store the localizated strings. */ |
|
| 49 | + * \brief Store the localizated strings. */ |
|
| 50 | 50 | protected $local; |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | 48 | /** @internal |
| 49 | - * \brief Store the localized strings. */ |
|
| 49 | + * \brief Store the localized strings. */ |
|
| 50 | 50 | protected $local; |
| 51 | 51 | |
| 52 | 52 | /** \brief Source for localization files. */ |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Get the language from the bot |
| 64 | 64 | $sth = $pdo->prepare('SELECT language FROM ' . $this->user_table . ' WHERE ' |
| 65 | - . $this->id_column . ' = :chat_id'); |
|
| 65 | + . $this->id_column . ' = :chat_id'); |
|
| 66 | 66 | |
| 67 | 67 | $chat_id = $this->bot->getChatID(); |
| 68 | 68 | $sth->bindParam(':chat_id', $chat_id); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | // Update the language in the database |
| 97 | 97 | $sth = $pdo->prepare('UPDATE ' . $this->user_table . ' SET language = :language WHERE ' |
| 98 | - . $this->id_column . ' = :id'); |
|
| 98 | + . $this->id_column . ' = :id'); |
|
| 99 | 99 | $sth->bindParam(':language', $language); |
| 100 | 100 | |
| 101 | 101 | $chat_id = $this->bot->getChatID(); |