diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index b3cc7630..1f1b2ce1 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -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 `): + The received update, which can be one of the many single Updates listed in the *updates* + field you see in the :obj:`types.Update ` type. + + users (:obj:`dict`): + Dictionary of all :obj:`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 ` and + :obj:`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 ` + - :obj:`types.ChatEmpty ` + - :obj:`types.ChatForbidden ` + - :obj:`types.ChannelForbidden ` """ self.update_handler = callback