From bd878acbdec09b12e4d962b2cdf0f9f22285f811 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Jul 2018 12:14:03 +0200 Subject: [PATCH] Support InputNotifyPeer autocast --- telethon/client/users.py | 14 ++++++++++++++ telethon_generator/generators/tlobject.py | 1 + 2 files changed, 15 insertions(+) diff --git a/telethon/client/users.py b/telethon/client/users.py index 393069ed..e4bec48b 100644 --- a/telethon/client/users.py +++ b/telethon/client/users.py @@ -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 diff --git a/telethon_generator/generators/tlobject.py b/telethon_generator/generators/tlobject.py index 111b0c75..43571c27 100644 --- a/telethon_generator/generators/tlobject.py +++ b/telethon_generator/generators/tlobject.py @@ -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({})'