Fix enableAdmin method when adding duplicate admin ids.

parent 1e0e7f79
......@@ -9,6 +9,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated
### Removed
### Fixed
- `Telegram::enableAdmin()` now handles duplicate additions properly.
- `Request::getMe()` failure doesn't break cron execution any more.
### Security
## [0.46.0] - 2017-07-15
......
......@@ -520,10 +520,10 @@ class Telegram
*/
public function enableAdmin($admin_id)
{
if (is_int($admin_id) && $admin_id > 0 && !in_array($admin_id, $this->admins_list, true)) {
$this->admins_list[] = $admin_id;
} else {
if (!is_int($admin_id) || $admin_id <= 0) {
TelegramLog::error('Invalid value "%s" for admin.', $admin_id);
} elseif (!in_array($admin_id, $this->admins_list, true)) {
$this->admins_list[] = $admin_id;
}
return $this;
......@@ -918,10 +918,8 @@ class Telegram
$bot_username = $this->getBotUsername();
}
if (!$this->isAdmin($bot_id)) {
$this->enableAdmin($bot_id); // Give bot access to admin commands
}
$this->enableAdmin($bot_id); // Give bot access to admin commands
$this->getCommandsList(); // Load full commands list
foreach ($commands as $command) {
......
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