Add new is_bot method to check if the logged-in user is a bot

This commit is contained in:
Lonami Exo
2018-12-24 17:32:34 +01:00
parent ab557a8cef
commit f16ed8235c
3 changed files with 13 additions and 0 deletions

View File

@@ -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.