Update readme and examples for enableAdmin(s) and add an extra test for string numbers.

parent d97f3862
...@@ -487,7 +487,11 @@ Enabling this feature, the admin bot can perform some super user commands like: ...@@ -487,7 +487,11 @@ Enabling this feature, the admin bot can perform some super user commands like:
You can specify one or more admins with this option: You can specify one or more admins with this option:
```php ```php
$telegram->enableAdmins(['your_telegram_user_id', 'other_telegram_user_id']); //Single admin
$telegram->enableAdmin(your_telegram_user_id);
//Multiple admins
$telegram->enableAdmins([your_telegram_user_id, other_telegram_user_id]);
``` ```
Telegram user id can be retrieved with the command **/whoami**. Telegram user id can be retrieved with the command **/whoami**.
Admin commands are stored in *src/Admin/* folder. Admin commands are stored in *src/Admin/* folder.
......
...@@ -33,8 +33,10 @@ try { ...@@ -33,8 +33,10 @@ try {
//// Add an additional commands path //// Add an additional commands path
//$telegram->addCommandsPath($commands_path); //$telegram->addCommandsPath($commands_path);
//// Here you can enable admin interface for the channel you want to manage //// Enable admin users
//$telegram->enableAdmins(['your_telegram_id']); //$telegram->enableAdmin(your_telegram_id);
//// Add the channel you want to manage
//$telegram->setCommandConfig('sendtochannel', ['your_channel' => '@type_here_your_channel']); //$telegram->setCommandConfig('sendtochannel', ['your_channel' => '@type_here_your_channel']);
//// Here you can set some command specific parameters, //// Here you can set some command specific parameters,
......
...@@ -31,8 +31,10 @@ try { ...@@ -31,8 +31,10 @@ try {
//// Add an additional commands path //// Add an additional commands path
//$telegram->addCommandsPath($commands_path); //$telegram->addCommandsPath($commands_path);
//// Here you can enable admin interface for the channel you want to manage //// Enable admin users
//$telegram->enableAdmins(['your_telegram_id']); //$telegram->enableAdmin(your_telegram_id);
//// Add the channel you want to manage
//$telegram->setCommandConfig('sendtochannel', ['your_channel' => '@type_here_your_channel']); //$telegram->setCommandConfig('sendtochannel', ['your_channel' => '@type_here_your_channel']);
//// Here you can set some command specific parameters, //// Here you can set some command specific parameters,
......
...@@ -91,15 +91,23 @@ class TelegramTest extends TestCase ...@@ -91,15 +91,23 @@ class TelegramTest extends TestCase
$this->assertEmpty($tg->getAdminList()); $this->assertEmpty($tg->getAdminList());
// Single
$tg->enableAdmin(1); $tg->enableAdmin(1);
$this->assertCount(1, $tg->getAdminList()); $this->assertCount(1, $tg->getAdminList());
// Multiple
$tg->enableAdmins([2, 3]); $tg->enableAdmins([2, 3]);
$this->assertCount(3, $tg->getAdminList()); $this->assertCount(3, $tg->getAdminList());
// Already added
$tg->enableAdmin(2); $tg->enableAdmin(2);
$this->assertCount(3, $tg->getAdminList()); $this->assertCount(3, $tg->getAdminList());
// Integer as a string
$tg->enableAdmin('4');
$this->assertCount(3, $tg->getAdminList());
// Random string
$tg->enableAdmin('a string?'); $tg->enableAdmin('a string?');
$this->assertCount(3, $tg->getAdminList()); $this->assertCount(3, $tg->getAdminList());
} }
......
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