@@ -520,10 +520,10 @@ protected function sanitizeCommand($command)
520
520
*/
521
521
public function enableAdmin ($ admin_id )
522
522
{
523
- if (is_int ($ admin_id ) && $ admin_id > 0 && !in_array ($ admin_id , $ this ->admins_list , true )) {
524
- $ this ->admins_list [] = $ admin_id ;
525
- } else {
523
+ if (!is_int ($ admin_id ) || $ admin_id <= 0 ) {
526
524
TelegramLog::error ('Invalid value "%s" for admin. ' , $ admin_id );
525
+ } elseif (!in_array ($ admin_id , $ this ->admins_list , true )) {
526
+ $ this ->admins_list [] = $ admin_id ;
527
527
}
528
528
529
529
return $ this ;
@@ -904,15 +904,20 @@ public function runCommands($commands)
904
904
$ this ->run_commands = true ;
905
905
$ this ->botan_enabled = false ; // Force disable Botan.io integration, we don't want to track self-executed commands!
906
906
907
- $ result = Request::getMe ()-> getResult () ;
907
+ $ result = Request::getMe ();
908
908
909
- if (!$ result ->getId ()) {
910
- throw new TelegramException ('Received empty/invalid getMe result! ' );
909
+ if ($ result ->isOk ()) {
910
+ $ result = $ result ->getResult ();
911
+
912
+ $ bot_id = $ result ->getId ();
913
+ $ bot_name = $ result ->getFirstName ();
914
+ $ bot_username = $ result ->getUsername ();
915
+ } else {
916
+ $ bot_id = $ this ->getBotId ();
917
+ $ bot_name = $ this ->getBotUsername ();
918
+ $ bot_username = $ this ->getBotUsername ();
911
919
}
912
920
913
- $ bot_id = $ result ->getId ();
914
- $ bot_name = $ result ->getFirstName ();
915
- $ bot_username = $ result ->getUsername ();
916
921
917
922
$ this ->enableAdmin ($ bot_id ); // Give bot access to admin commands
918
923
$ this ->getCommandsList (); // Load full commands list
0 commit comments