@@ -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'); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | public function offsetUnset($offset) |
42 | 42 | { |
43 | - /* Log a warning */ |
|
43 | + /* Log a warning */ |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -79,12 +79,12 @@ |
||
79 | 79 | // If we found a valid command (check first lenght, then use strpos) |
80 | 80 | if ($message_is_command && $this->length == $message['entities'][0]['length'] && |
81 | 81 | mb_strpos($this->command, $message['text'], $message['entities'][0]['offset']) !== false) { |
82 | - // Check that the user can execute the command |
|
83 | - if (in_array($message['from']['id'], $this->ids)) { |
|
82 | + // Check that the user can execute the command |
|
83 | + if (in_array($message['from']['id'], $this->ids)) { |
|
84 | 84 | return true; |
85 | - } else { |
|
85 | + } else { |
|
86 | 86 | return false; |
87 | - } |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return false; |
@@ -8,30 +8,30 @@ |
||
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 | $bot = new WhoAmIBot('BOT_TOKEN'); |
29 | 29 | |
30 | 30 | // Add a welcome message |
31 | 31 | $start_command = new PhpBotFramework\Commands\MessageCommand('start', |
32 | - function ($bot, $message) { |
|
32 | + function ($bot, $message) { |
|
33 | 33 | $bot->sendMessage('<strong>Hey there!</strong> Send or forward me a text message :)'); |
34 | - } |
|
34 | + } |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | $bot->addCommand($start_command); |
@@ -324,27 +324,27 @@ |
||
324 | 324 | Chat; |
325 | 325 | |
326 | 326 | /** @internal |
327 | - * \brief Chat_id of the user that interacted with the bot. */ |
|
327 | + * \brief Chat_id of the user that interacted with the bot. */ |
|
328 | 328 | protected $_chat_id; |
329 | 329 | |
330 | 330 | /** @internal |
331 | - * \brief Bot id. */ |
|
331 | + * \brief Bot id. */ |
|
332 | 332 | protected $_bot_id; |
333 | 333 | |
334 | 334 | /** @internal |
335 | - * \brief API endpoint (containing $token). */ |
|
335 | + * \brief API endpoint (containing $token). */ |
|
336 | 336 | protected $_api_url; |
337 | 337 | |
338 | 338 | /** @internal |
339 | - * \brief Implements interface for execute HTTP requests. */ |
|
339 | + * \brief Implements interface for execute HTTP requests. */ |
|
340 | 340 | public $_http; |
341 | 341 | |
342 | 342 | /** @internal |
343 | - * \brief Object of class PhpBotFramework\Entities\File that contain a path or resource to a file that has to be sent using Telegram API Methods. */ |
|
343 | + * \brief Object of class PhpBotFramework\Entities\File that contain a path or resource to a file that has to be sent using Telegram API Methods. */ |
|
344 | 344 | protected $_file; |
345 | 345 | |
346 | 346 | /** \@internal |
347 | - * brief Contains parameters of the next request. */ |
|
347 | + * brief Contains parameters of the next request. */ |
|
348 | 348 | protected $parameters; |
349 | 349 | |
350 | 350 | /** |