mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Better autocast to InputPeerDialog and documentation
This commit is contained in:
parent
92c9bb12b7
commit
cb6f980277
|
@ -262,7 +262,7 @@ You can also except it and act as you prefer:
|
||||||
print('Flood waited for', e.seconds)
|
print('Flood waited for', e.seconds)
|
||||||
quit(1)
|
quit(1)
|
||||||
|
|
||||||
VoIP numbers are very limited, and some countries are more limitted too.
|
VoIP numbers are very limited, and some countries are more limited too.
|
||||||
|
|
||||||
Chat or User From Messages
|
Chat or User From Messages
|
||||||
**************************
|
**************************
|
||||||
|
|
|
@ -401,6 +401,23 @@ class UserMethods(TelegramBaseClient):
|
||||||
'Cannot find any entity corresponding to "{}"'.format(string)
|
'Cannot find any entity corresponding to "{}"'.format(string)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def _get_input_dialog(self, dialog):
|
||||||
|
"""
|
||||||
|
Returns a :tl:`InputDialogPeer`. 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 dialog.SUBCLASS_OF_ID == 0xa21c9795: # crc32(b'InputDialogPeer')
|
||||||
|
dialog.peer = await self.get_input_entity(dialog.peer)
|
||||||
|
return dialog
|
||||||
|
elif dialog.SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer')
|
||||||
|
return types.InputDialogPeer(dialog)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return types.InputDialogPeer(await self.get_input_entity(dialog))
|
||||||
|
|
||||||
async def _get_input_notify(self, notify):
|
async def _get_input_notify(self, notify):
|
||||||
"""
|
"""
|
||||||
Returns a :tl:`InputNotifyPeer`. This is a bit tricky because
|
Returns a :tl:`InputNotifyPeer`. This is a bit tricky because
|
||||||
|
|
|
@ -192,7 +192,8 @@ def _get_description(arg):
|
||||||
'<code>None</code> and can be omitted.')
|
'<code>None</code> and can be omitted.')
|
||||||
otherwise = True
|
otherwise = True
|
||||||
|
|
||||||
if arg.type in {'InputPeer', 'InputUser', 'InputChannel'}:
|
if arg.type in {'InputPeer', 'InputUser', 'InputChannel',
|
||||||
|
'InputNotifyPeer', 'InputDialogPeer'}:
|
||||||
desc.append(
|
desc.append(
|
||||||
'Anything entity-like will work if the library can find its '
|
'Anything entity-like will work if the library can find its '
|
||||||
'<code>Input</code> version (e.g., usernames, <code>Peer</code>, '
|
'<code>Input</code> version (e.g., usernames, <code>Peer</code>, '
|
||||||
|
|
|
@ -20,9 +20,8 @@ AUTO_CASTS = {
|
||||||
'utils.get_input_channel(await client.get_input_entity({}))',
|
'utils.get_input_channel(await client.get_input_entity({}))',
|
||||||
'InputUser':
|
'InputUser':
|
||||||
'utils.get_input_user(await client.get_input_entity({}))',
|
'utils.get_input_user(await client.get_input_entity({}))',
|
||||||
'InputDialogPeer':
|
|
||||||
'utils.get_input_dialog(await client.get_input_entity({}))',
|
|
||||||
|
|
||||||
|
'InputDialogPeer': 'await client._get_input_dialog({})',
|
||||||
'InputNotifyPeer': 'await client._get_input_notify({})',
|
'InputNotifyPeer': 'await client._get_input_notify({})',
|
||||||
'InputMedia': 'utils.get_input_media({})',
|
'InputMedia': 'utils.get_input_media({})',
|
||||||
'InputPhoto': 'utils.get_input_photo({})',
|
'InputPhoto': 'utils.get_input_photo({})',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user