An user -> a user

This commit is contained in:
Lonami Exo 2018-09-22 19:18:42 +02:00
parent d5d3733fd4
commit ec0aa65fe1
11 changed files with 19 additions and 19 deletions

View File

@ -23,7 +23,7 @@ talk to the Telegram servers, such as to which IP the client should connect,
port, authorization key so that messages can be encrypted, and so on. port, authorization key so that messages can be encrypted, and so on.
These files will by default also save all the input entities that you've seen, These files will by default also save all the input entities that you've seen,
so that you can get information about an user or channel by just their ID. so that you can get information about a user or channel by just their ID.
Telegram will **not** send their ``access_hash`` required to retrieve more Telegram will **not** send their ``access_hash`` required to retrieve more
information about them, if it thinks you have already seem them. For this information about them, if it thinks you have already seem them. For this
reason, the library needs to store this information offline. reason, the library needs to store this information offline.

View File

@ -47,14 +47,14 @@ how the library refers to either of these:
.. code-block:: python .. code-block:: python
# The method will infer that you've passed an username # The method will infer that you've passed a username
# It also accepts phone numbers, and will get the user # It also accepts phone numbers, and will get the user
# from your contact list. # from your contact list.
lonami = client.get_entity('lonami') lonami = client.get_entity('lonami')
The so called "entities" are another important whole concept on its own, The so called "entities" are another important whole concept on its own,
but for now you don't need to worry about it. Simply know that they are but for now you don't need to worry about it. Simply know that they are
a good way to get information about an user, chat or channel. a good way to get information about a user, chat or channel.
Many other common methods for quick scripts are also available: Many other common methods for quick scripts are also available:

View File

@ -222,7 +222,7 @@ Restricting Users
***************** *****************
Similar to how you give or revoke admin permissions, you can edit the Similar to how you give or revoke admin permissions, you can edit the
banned rights of an user through :tl:`EditBannedRequest` and its parameter banned rights of a user through :tl:`EditBannedRequest` and its parameter
:tl:`ChannelBannedRights`: :tl:`ChannelBannedRights`:
.. code-block:: python .. code-block:: python
@ -232,7 +232,7 @@ banned rights of an user through :tl:`EditBannedRequest` and its parameter
from datetime import datetime, timedelta from datetime import datetime, timedelta
# Restricting an user for 7 days, only allowing view/send messages. # Restricting a user for 7 days, only allowing view/send messages.
# #
# Note that it's "reversed". You must set to ``True`` the permissions # Note that it's "reversed". You must set to ``True`` the permissions
# you want to REMOVE, and leave as ``None`` those you want to KEEP. # you want to REMOVE, and leave as ``None`` those you want to KEEP.
@ -272,7 +272,7 @@ https://core.telegram.org/bots/api#restrictchatmember.
Kicking a member Kicking a member
**************** ****************
Telegram doesn't actually have a request to kick an user from a group. Telegram doesn't actually have a request to kick a user from a group.
Instead, you need to restrict them so they can't see messages. Any date Instead, you need to restrict them so they can't see messages. Any date
is enough: is enough:

View File

@ -11,7 +11,7 @@ Users
Retrieving full information Retrieving full information
*************************** ***************************
If you need to retrieve the bio, biography or about information for an user If you need to retrieve the bio, biography or about information for a user
you should use :tl:`GetFullUser`: you should use :tl:`GetFullUser`:

View File

@ -25,7 +25,7 @@ when you upgrade!
.. note:: .. note::
The library uses `asyncio <https://docs.python.org/3/library/asyncio.html>`_ The library uses `asyncio <https://docs.python.org/3/library/asyncio.html>`_
under the hood, but you don't need to know anything about it unless you're under the hood, but you don't need to know anything about it unless you're
going to work with updates! If you're an user of Telethon pre-1.0 and you going to work with updates! If you're a user of Telethon pre-1.0 and you
aren't ready to convert your event handlers into ``async``, you can use aren't ready to convert your event handlers into ``async``, you can use
`a simpler version <https://github.com/LonamiWebs/Telethon/tree/sync>`_ `a simpler version <https://github.com/LonamiWebs/Telethon/tree/sync>`_
(select the "sync" version in ``readthedocs``' bottom left corner). (select the "sync" version in ``readthedocs``' bottom left corner).

View File

@ -139,7 +139,7 @@ class UserMethods(TelegramBaseClient):
and they will be efficiently fetched from the network. and they will be efficiently fetched from the network.
entity (`str` | `int` | :tl:`Peer` | :tl:`InputPeer`): entity (`str` | `int` | :tl:`Peer` | :tl:`InputPeer`):
If an username is given, **the username will be resolved** making If a username is given, **the username will be resolved** making
an API call every time. Resolving usernames is an expensive an API call every time. Resolving usernames is an expensive
operation and will start hitting flood waits around 50 usernames operation and will start hitting flood waits around 50 usernames
in a short period of time. in a short period of time.
@ -244,9 +244,9 @@ class UserMethods(TelegramBaseClient):
>>> chat = rc(client.get_input_entity(-123456789)) >>> chat = rc(client.get_input_entity(-123456789))
entity (`str` | `int` | :tl:`Peer` | :tl:`InputPeer`): entity (`str` | `int` | :tl:`Peer` | :tl:`InputPeer`):
If an username or invite link is given, **the library will If a username or invite link is given, **the library will
use the cache**. This means that it's possible to be using use the cache**. This means that it's possible to be using
an username that *changed* or an old invite link (this only a username that *changed* or an old invite link (this only
happens if an invite link for a small group chat is used happens if an invite link for a small group chat is used
after it was upgraded to a mega-group). after it was upgraded to a mega-group).
@ -267,7 +267,7 @@ class UserMethods(TelegramBaseClient):
(prefixed with ``-100``). (prefixed with ``-100``).
If a :tl:`Peer` is given, it will be searched exactly in the If a :tl:`Peer` is given, it will be searched exactly in the
cache as either an user, chat or channel. cache as either a user, chat or channel.
If the given object can be turned into an input entity directly, If the given object can be turned into an input entity directly,
said operation will be done. said operation will be done.
@ -343,7 +343,7 @@ class UserMethods(TelegramBaseClient):
async def _get_entity_from_string(self, string): async def _get_entity_from_string(self, string):
""" """
Gets a full entity from the given string, which may be a phone or Gets a full entity from the given string, which may be a phone or
an username, and processes all the found entities on the session. a username, and processes all the found entities on the session.
The string may also be a user link, or a channel/chat invite link. The string may also be a user link, or a channel/chat invite link.
This method has the side effect of adding the found users to the This method has the side effect of adding the found users to the

View File

@ -37,7 +37,7 @@ class ChatAction(EventBuilder):
added_by=True, added_by=True,
users=msg.from_id) users=msg.from_id)
elif isinstance(action, types.MessageActionChatAddUser): elif isinstance(action, types.MessageActionChatAddUser):
# If an user adds itself, it means they joined # If a user adds itself, it means they joined
added_by = ([msg.from_id] == action.users) or msg.from_id added_by = ([msg.from_id] == action.users) or msg.from_id
event = cls.Event(msg, event = cls.Event(msg,
added_by=added_by, added_by=added_by,

View File

@ -191,7 +191,7 @@ class NewMessage(EventBuilder):
self.__dict__['_init'] = False self.__dict__['_init'] = False
if not message.out and isinstance(message.to_id, types.PeerUser): if not message.out and isinstance(message.to_id, types.PeerUser):
# Incoming message (e.g. from a bot) has to_id=us, and # Incoming message (e.g. from a bot) has to_id=us, and
# from_id=bot (the actual "chat" from an user's perspective). # from_id=bot (the actual "chat" from a user's perspective).
chat_peer = types.PeerUser(message.from_id) chat_peer = types.PeerUser(message.from_id)
else: else:
chat_peer = message.to_id chat_peer = message.to_id

View File

@ -7,7 +7,7 @@ from ..tl import types
@name_inner_event @name_inner_event
class UserUpdate(EventBuilder): class UserUpdate(EventBuilder):
""" """
Represents an user update (gone online, offline, joined Telegram). Represents a user update (gone online, offline, joined Telegram).
""" """
@classmethod @classmethod
def build(cls, update): def build(cls, update):
@ -22,7 +22,7 @@ class UserUpdate(EventBuilder):
class Event(EventCommon): class Event(EventCommon):
""" """
Represents the event of an user status update (last seen, joined). Represents the event of a user status update (last seen, joined).
Members: Members:
online (`bool`, optional): online (`bool`, optional):

View File

@ -1,6 +1,6 @@
""" """
Utilities for working with the Telegram API itself (such as handy methods Utilities for working with the Telegram API itself (such as handy methods
to convert between an entity like an User, Chat, etc. into its Input version) to convert between an entity like a User, Chat, etc. into its Input version)
""" """
import base64 import base64
import binascii import binascii

View File

@ -51,7 +51,7 @@ USERNAME_NOT_OCCUPIED=The username is not in use by anyone else yet
USERNAME_OCCUPIED=The username is already taken USERNAME_OCCUPIED=The username is already taken
USERS_TOO_FEW=Not enough users (to create a chat, for example) USERS_TOO_FEW=Not enough users (to create a chat, for example)
USERS_TOO_MUCH=The maximum number of users has been exceeded (to create a chat, for example) USERS_TOO_MUCH=The maximum number of users has been exceeded (to create a chat, for example)
USER_ID_INVALID=Invalid object ID for an user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited USER_ID_INVALID=Invalid object ID for a user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited
ACTIVE_USER_REQUIRED=The method is only available to already activated users ACTIVE_USER_REQUIRED=The method is only available to already activated users
AUTH_KEY_INVALID=The key is invalid AUTH_KEY_INVALID=The key is invalid
AUTH_KEY_PERM_EMPTY=The method is unavailable for temporary authorization key, not bound to permanent AUTH_KEY_PERM_EMPTY=The method is unavailable for temporary authorization key, not bound to permanent