Commit 83436f83 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #565 from jacklul/cron_patch

Scheduler patch
parents fae82d96 d806cde5
...@@ -9,6 +9,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -9,6 +9,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated ### Deprecated
### Removed ### Removed
### Fixed ### Fixed
- `Telegram::enableAdmin()` now handles duplicate additions properly.
- `Request::getMe()` failure doesn't break cron execution any more.
### Security ### Security
## [0.46.0] - 2017-07-15 ## [0.46.0] - 2017-07-15
......
...@@ -520,10 +520,10 @@ class Telegram ...@@ -520,10 +520,10 @@ class Telegram
*/ */
public function enableAdmin($admin_id) public function enableAdmin($admin_id)
{ {
if (is_int($admin_id) && $admin_id > 0 && !in_array($admin_id, $this->admins_list, true)) { if (!is_int($admin_id) || $admin_id <= 0) {
$this->admins_list[] = $admin_id;
} else {
TelegramLog::error('Invalid value "%s" for admin.', $admin_id); 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; return $this;
...@@ -904,15 +904,20 @@ class Telegram ...@@ -904,15 +904,20 @@ class Telegram
$this->run_commands = true; $this->run_commands = true;
$this->botan_enabled = false; // Force disable Botan.io integration, we don't want to track self-executed commands! $this->botan_enabled = false; // Force disable Botan.io integration, we don't want to track self-executed commands!
$result = Request::getMe()->getResult(); $result = Request::getMe();
if (!$result->getId()) { if ($result->isOk()) {
throw new TelegramException('Received empty/invalid getMe result!'); $result = $result->getResult();
}
$bot_id = $result->getId(); $bot_id = $result->getId();
$bot_name = $result->getFirstName(); $bot_name = $result->getFirstName();
$bot_username = $result->getUsername(); $bot_username = $result->getUsername();
} else {
$bot_id = $this->getBotId();
$bot_name = $this->getBotUsername();
$bot_username = $this->getBotUsername();
}
$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 $this->getCommandsList(); // Load full commands list
......
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