Commit b83f848d authored by sabas's avatar sabas

Fix GenericCommand and minor spelling errors

parent 235fd820
...@@ -90,14 +90,14 @@ And run composer update ...@@ -90,14 +90,14 @@ And run composer update
composer require longman/telegram-bot composer require longman/telegram-bot
``` ```
###### bot token ###### Bot token
You will notice that the Telegram Bot wants a value for `API_KEY`. This token may be obtained via a telegram client for your bot. See [this](https://core.telegram.org/bots#botfather) link if you are unsure of how to so this. You will notice that the Telegram Bot wants a value for `API_KEY`. This token may be obtained via a telegram client for your bot. See [this](https://core.telegram.org/bots#botfather) link if you are unsure of how to so this.
## Usage ## Usage
You must set [WebHook](https://core.telegram.org/bots/api#setwebhook) You must set a [WebHook](https://core.telegram.org/bots/api#setwebhook)
Create set.php and put: Create set.php and put into it:
```php ```php
<?php <?php
$loader = require __DIR__.'/vendor/autoload.php'; $loader = require __DIR__.'/vendor/autoload.php';
...@@ -154,7 +154,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_'); ...@@ -154,7 +154,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_');
``` ```
Commads Commands
-------------- --------------
The bot is able to recognise commands in chat with multiple bot. The bot is able to recognise commands in chat with multiple bot.
It can execute command triggering a chat event. Here's the list: It can execute command triggering a chat event. Here's the list:
...@@ -165,9 +165,9 @@ It can execute command triggering a chat event. Here's the list: ...@@ -165,9 +165,9 @@ It can execute command triggering a chat event. Here's the list:
- New chat title (**NewchattitleCommand.php**) - New chat title (**NewchattitleCommand.php**)
- Left chat participant (**LeftchatparticipantCommand.php**) - Left chat participant (**LeftchatparticipantCommand.php**)
**GenericCommand.php** let you handle commands that non exist or use commands as var: **GenericCommand.php** lets you handle commands that don't exist or to use commands as a variable:
Favourite colour? **/black /red** Favourite colour? **/black /red**
Favourite number? **/1 /134** Favourite number? **/1 /134**
Maybe you would like to develop your own commands. A good practice is to store them outside vendor/. This can be done adding before the method: Maybe you would like to develop your own commands. A good practice is to store them outside vendor/. This can be done adding before the method:
...@@ -179,7 +179,6 @@ $telegram->addCommandsPath($COMMANDS_FOLDER); ...@@ -179,7 +179,6 @@ $telegram->addCommandsPath($COMMANDS_FOLDER);
``` ```
Send message to all active chats (new!) Send message to all active chats (new!)
--------------------------------------- ---------------------------------------
To do this you have to enable the mysql connection. To do this you have to enable the mysql connection.
......
...@@ -17,7 +17,7 @@ use Longman\TelegramBot\Entities\Update; ...@@ -17,7 +17,7 @@ use Longman\TelegramBot\Entities\Update;
class GenericCommand extends Command class GenericCommand extends Command
{ {
protected $name = 'Generic'; protected $name = 'Generic';
protected $description = 'Handle genric commands or is executed by defaul when a command is not found'; protected $description = 'Handle genric commands or is executed by default when a command is not found';
protected $usage = '/'; protected $usage = '/';
protected $version = '1.0.0'; protected $version = '1.0.0';
protected $enabled = true; protected $enabled = true;
...@@ -29,6 +29,11 @@ class GenericCommand extends Command ...@@ -29,6 +29,11 @@ class GenericCommand extends Command
//you can use $command as param //you can use $command as param
$command = $message->getCommand(); $command = $message->getCommand();
$chat_id = $message->getChat()->getId();
$text = $message->getText(true);
$data = array();
$data['chat_id'] = $chat_id;
$data['text'] = 'Command: '.$command.' not found.. :('; $data['text'] = 'Command: '.$command.' not found.. :(';
$result = Request::sendMessage($data); $result = Request::sendMessage($data);
return $result; return $result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment