Add much more detailed set_update_handler docstring
This commit is contained in:
parent
df89669e04
commit
c6d5fb4178
@ -371,10 +371,41 @@ class Client:
|
||||
def set_update_handler(self, callback: callable):
|
||||
"""Use this method to set the update handler.
|
||||
|
||||
You must call this method *before* you *start()* the Client.
|
||||
|
||||
Args:
|
||||
callback (:obj:`callable`):
|
||||
A function that takes "client, update, users, chats" as positional arguments.
|
||||
It will be called when a new update is received from the server.
|
||||
A function that will be called when a new update is received from the server. It takes
|
||||
:obj:`(client, update, users, chats)` as positional arguments (Look at the section below for
|
||||
a detailed description).
|
||||
|
||||
Other Parameters:
|
||||
client (:obj:`pyrogram.Client`):
|
||||
The Client itself, useful when you want to call other API methods inside the update handler.
|
||||
|
||||
update (:obj:`types.Update <pyrogram.api.types.Update>`):
|
||||
The received update, which can be one of the many single Updates listed in the *updates*
|
||||
field you see in the :obj:`types.Update <pyrogram.api.types.Update>` type.
|
||||
|
||||
users (:obj:`dict`):
|
||||
Dictionary of all :obj:`types.User <pyrogram.api.types.User>` mentioned in the update.
|
||||
You can access extra info about the user (such as *first_name*, *last_name*, etc...) by using
|
||||
the IDs you find in the *update* argument (e.g.: *users[1768841572]*).
|
||||
|
||||
chats (:obj:`dict`):
|
||||
Dictionary of all :obj:`types.Chat <pyrogram.api.types.Chat>` and
|
||||
:obj:`types.Channel <pyrogram.api.types.Channel>` mentioned in the update.
|
||||
You can access extra info about the chat (such as *title*, *participants_count*, etc...)
|
||||
by using the IDs you find in the *update* argument (e.g.: *chats[1701277281]*).
|
||||
|
||||
Note:
|
||||
The following Empty or Forbidden types may exist inside the *users* and *chats* dictionaries.
|
||||
They mean you have been blocked by the user or banned from the group/channel.
|
||||
|
||||
- :obj:`types.UserEmpty <pyrogram.api.types.UserEmpty>`
|
||||
- :obj:`types.ChatEmpty <pyrogram.api.types.ChatEmpty>`
|
||||
- :obj:`types.ChatForbidden <pyrogram.api.types.ChatForbidden>`
|
||||
- :obj:`types.ChannelForbidden <pyrogram.api.types.ChannelForbidden>`
|
||||
"""
|
||||
self.update_handler = callback
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user