mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Add new is_bot method to check if the logged-in user is a bot
This commit is contained in:
@@ -110,6 +110,7 @@ class UserMethods(TelegramBaseClient):
|
||||
me = (await self(
|
||||
functions.users.GetUsersRequest([types.InputUserSelf()])))[0]
|
||||
|
||||
self._bot = me.bot
|
||||
if not self._self_input_peer:
|
||||
self._self_input_peer = utils.get_input_peer(
|
||||
me, allow_self=False
|
||||
@@ -119,6 +120,15 @@ class UserMethods(TelegramBaseClient):
|
||||
except errors.UnauthorizedError:
|
||||
return None
|
||||
|
||||
async def is_bot(self):
|
||||
"""
|
||||
Return ``True`` if the signed-in user is a bot, ``False`` otherwise.
|
||||
"""
|
||||
if self._bot is None:
|
||||
self._bot = (await self.get_me()).bot
|
||||
|
||||
return self._bot
|
||||
|
||||
async def is_user_authorized(self):
|
||||
"""
|
||||
Returns ``True`` if the user is authorized.
|
||||
|
Reference in New Issue
Block a user