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
### 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;
......@@ -904,15 +904,20 @@ class Telegram
$this->run_commands = true;
$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()) {
throw new TelegramException('Received empty/invalid getMe result!');
if ($result->isOk()) {
$result = $result->getResult();
$bot_id = $result->getId();
$bot_name = $result->getFirstName();
$bot_username = $result->getUsername();
} else {
$bot_id = $this->getBotId();
$bot_name = $this->getBotUsername();
$bot_username = $this->getBotUsername();
}
$bot_id = $result->getId();
$bot_name = $result->getFirstName();
$bot_username = $result->getUsername();
$this->enableAdmin($bot_id); // Give bot access to admin commands
$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