@@ -93,7 +93,7 @@ |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * \brief Add various commands at once. |
96 | - * @param ...BasicCommand $commands The commands to add. |
|
96 | + * @param BasicCommand[] $commands The commands to add. |
|
97 | 97 | */ |
98 | 98 | public function addCommands(BasicCommand ...$commands) |
99 | 99 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function addCommands(BasicCommand ...$commands) |
99 | 99 | { |
100 | - foreach ($commands as $command) { |
|
100 | + foreach ($commands as $command) { |
|
101 | 101 | $this->addCommand($command); |
102 | 102 | } |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function addMessageCommand(string $command, callable $script) |
111 | 111 | { |
112 | - $this->_commands[] = new MessageCommand($command, $script); |
|
112 | + $this->_commands[] = new MessageCommand($command, $script); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function addCallbackCommand(string $data, callable $script) |
121 | 121 | { |
122 | - $this->_commands[] = new CallbackCommand($data, $script); |
|
122 | + $this->_commands[] = new CallbackCommand($data, $script); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -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 | $bot = new WhoAmIBot('BOT_TOKEN'); |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | // Add a welcome message |
31 | 31 | $bot->addMessageCommand('start', function ($bot, $message) { |
32 | 32 | $bot->sendMessage('<strong>Hey there!</strong> Send or forward me a text message :)'); |
33 | - } |
|
33 | + } |
|
34 | 34 | ); |
35 | 35 | |
36 | 36 | // Add various commands at once |
37 | 37 | $about_command = new PhpBotFramework\Commands\MessageCommand('about', function($bot, $message) { |
38 | - $bot->sendMessage('Powered by PhpBotFramework'); |
|
38 | + $bot->sendMessage('Powered by PhpBotFramework'); |
|
39 | 39 | }); |
40 | 40 | |
41 | 41 | $codename_command = new PhpBotFramework\Commands\MessageCommand('codename', function($bot, $message) { |
42 | - $bot->sendMessage('Iron Bird'); |
|
42 | + $bot->sendMessage('Iron Bird'); |
|
43 | 43 | }); |
44 | 44 | |
45 | 45 | $bot->addCommands($about_command, $codename_command); |