mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Remove input_peer parameter from get_me
This commit is contained in:
parent
7778e54467
commit
d426099bf5
|
@ -773,3 +773,5 @@ connection type is gone
|
|||
raise_last_call_error is now the default rather than ValueError
|
||||
|
||||
self-produced updates like getmessage now also trigger a handler
|
||||
|
||||
input_peer removed from get_me; input peers should remain mostly an impl detail
|
||||
|
|
|
@ -648,7 +648,7 @@ async def get_permissions(
|
|||
entity
|
||||
))
|
||||
if isinstance(user, _tl.InputPeerSelf):
|
||||
user = await self.get_me(input_peer=True)
|
||||
user = _tl.PeerUser(self._session_state.user_id)
|
||||
for participant in chat.full_chat.participants.participants:
|
||||
if participant.user_id == user.user_id:
|
||||
return _custom.ParticipantPermissions(participant, True)
|
||||
|
|
|
@ -3274,19 +3274,13 @@ class TelegramClient:
|
|||
"""
|
||||
|
||||
@forward_call(users.get_me)
|
||||
async def get_me(self: 'TelegramClient', input_peer: bool = False) \
|
||||
-> 'typing.Union[_tl.User, _tl.InputPeerUser]':
|
||||
async def get_me(self: 'TelegramClient') \
|
||||
-> '_tl.User':
|
||||
"""
|
||||
Gets "me", the current :tl:`User` who is logged in.
|
||||
|
||||
If the user has not logged in yet, this method returns `None`.
|
||||
|
||||
Arguments
|
||||
input_peer (`bool`, optional):
|
||||
Whether to return the :tl:`InputPeerUser` version or the normal
|
||||
:tl:`User`. This can be useful if you just need to know the ID
|
||||
of yourself.
|
||||
|
||||
Returns
|
||||
Your own :tl:`User`.
|
||||
|
||||
|
@ -3434,9 +3428,6 @@ class TelegramClient:
|
|||
:tl:`InputPeerUser`, :tl:`InputPeerChat` or :tl:`InputPeerChannel`
|
||||
or :tl:`InputPeerSelf` if the parameter is ``'me'`` or ``'self'``.
|
||||
|
||||
If you need to get the ID of yourself, you should use
|
||||
`get_me` with ``input_peer=True``) instead.
|
||||
|
||||
Example
|
||||
.. code-block:: python
|
||||
|
||||
|
|
|
@ -126,11 +126,10 @@ async def _call(self: 'TelegramClient', sender, request, ordered=False, flood_sl
|
|||
raise last_error
|
||||
|
||||
|
||||
async def get_me(self: 'TelegramClient', input_peer: bool = False) \
|
||||
async def get_me(self: 'TelegramClient') \
|
||||
-> 'typing.Union[_tl.User, _tl.InputPeerUser]':
|
||||
try:
|
||||
me = (await self(_tl.fn.users.GetUsers([_tl.InputUserSelf()])))[0]
|
||||
return utils.get_input_peer(me, allow_self=False) if input_peer else me
|
||||
return (await self(_tl.fn.users.GetUsers([_tl.InputUserSelf()])))[0]
|
||||
except UnauthorizedError:
|
||||
return None
|
||||
|
||||
|
@ -296,7 +295,7 @@ async def get_peer_id(
|
|||
peer = await self.get_input_entity(peer)
|
||||
|
||||
if isinstance(peer, _tl.InputPeerSelf):
|
||||
peer = await self.get_me(input_peer=True)
|
||||
peer = _tl.PeerUser(self._session_state.user_id)
|
||||
|
||||
return utils.get_peer_id(peer)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ async def _into_id_set(client, chats):
|
|||
else:
|
||||
chat = await client.get_input_entity(chat)
|
||||
if isinstance(chat, _tl.InputPeerSelf):
|
||||
chat = await client.get_me(input_peer=True)
|
||||
chat = _tl.PeerUser(self._session_state.user_id)
|
||||
result.add(utils.get_peer_id(chat))
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue
Block a user