Longman\TelegramBot\Telegram::isAdmin PHP Method

isAdmin() public method

If no user id is passed, the current update is checked for a valid message sender.
public isAdmin ( integer | null $user_id = null ) : boolean
$user_id integer | null
return boolean
    public function isAdmin($user_id = null)
    {
        if ($user_id === null && $this->update !== null) {
            //Try to figure out if the user is an admin
            $update_methods = ['getMessage', 'getInlineQuery', 'getChosenInlineResult', 'getCallbackQuery', 'getEditedMessage'];
            foreach ($update_methods as $update_method) {
                $object = call_user_func([$this->update, $update_method]);
                if ($object !== null && ($from = $object->getFrom())) {
                    $user_id = $from->getId();
                    break;
                }
            }
        }
        return $user_id === null ? false : in_array($user_id, $this->admins_list, true);
    }