Support InputNotifyPeer autocast

This commit is contained in:
Lonami Exo 2018-07-07 12:14:03 +02:00
parent dfda61a1b5
commit bd878acbde
2 changed files with 15 additions and 0 deletions

View File

@ -337,4 +337,18 @@ class UserMethods(TelegramBaseClient):
'Cannot find any entity corresponding to "{}"'.format(string)
)
async def _get_input_notify(self, notify):
"""
Returns a :tl:`InputNotifyPeer`. This is a bit tricky because
it may or not need access to the client to convert what's given
into an input entity.
"""
try:
if notify.SUBCLASS_OF_ID == 0x58981615:
if isinstance(notify, types.InputNotifyPeer):
notify.peer = await self.get_input_entity(notify.peer)
return notify
except AttributeError:
return types.InputNotifyPeer(await self.get_input_entity(notify))
# endregion

View File

@ -23,6 +23,7 @@ AUTO_CASTS = {
'InputDialogPeer':
'utils.get_input_dialog(await client.get_input_entity({}))',
'InputNotifyPeer': 'await client._get_input_notify({})',
'InputMedia': 'utils.get_input_media({})',
'InputPhoto': 'utils.get_input_photo({})',
'InputMessage': 'utils.get_input_message({})'