diff --git a/docs/source/start/Installation.rst b/docs/source/start/Installation.rst index 37fedbdf..efebac5a 100644 --- a/docs/source/start/Installation.rst +++ b/docs/source/start/Installation.rst @@ -82,7 +82,7 @@ If no error shows up you are good to go. >>> import pyrogram >>> pyrogram.__version__ - '0.9.1' + '0.9.3' .. _TgCrypto: https://docs.pyrogram.ml/resources/TgCrypto .. _develop: http://github.com/pyrogram/pyrogram diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 8471dd82..b1a5430c 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -23,7 +23,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès 50: self.channels_pts[channel_id] = self.channels_pts[channel_id][25:] - self.dispatcher.updates.put((update, updates.users, updates.chats)) + self.dispatcher.updates_queue.put((update, updates.users, updates.chats)) elif isinstance(updates, (types.UpdateShortMessage, types.UpdateShortChatMessage)): diff = self.send( functions.updates.GetDifference( @@ -862,7 +862,7 @@ class Client(Methods, BaseClient): ) if diff.new_messages: - self.dispatcher.updates.put(( + self.dispatcher.updates_queue.put(( types.UpdateNewMessage( message=diff.new_messages[0], pts=updates.pts, @@ -872,9 +872,9 @@ class Client(Methods, BaseClient): diff.chats )) else: - self.dispatcher.updates.put((diff.other_updates[0], [], [])) + self.dispatcher.updates_queue.put((diff.other_updates[0], [], [])) elif isinstance(updates, types.UpdateShort): - self.dispatcher.updates.put((updates.update, [], [])) + self.dispatcher.updates_queue.put((updates.update, [], [])) elif isinstance(updates, types.UpdatesTooLong): log.warning(updates) except Exception as e: diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index fa65f987..a61e8077 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -52,17 +52,15 @@ class Dispatcher: MESSAGE_UPDATES = NEW_MESSAGE_UPDATES + EDIT_MESSAGE_UPDATES - UPDATES = None - def __init__(self, client, workers: int): self.client = client self.workers = workers self.workers_list = [] - self.updates = Queue() + self.updates_queue = Queue() self.groups = OrderedDict() - Dispatcher.UPDATES = { + self.update_parsers = { Dispatcher.MESSAGE_UPDATES: lambda upd, usr, cht: (utils.parse_messages(self.client, upd.message, usr, cht), MessageHandler), @@ -76,7 +74,7 @@ class Dispatcher: lambda upd, usr, cht: (utils.parse_user_status(upd.status, upd.user_id), UserStatusHandler) } - Dispatcher.UPDATES = {key: value for key_tuple, value in Dispatcher.UPDATES.items() for key in key_tuple} + self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple} def start(self): for i in range(self.workers): @@ -91,7 +89,7 @@ class Dispatcher: def stop(self): for _ in range(self.workers): - self.updates.put(None) + self.updates_queue.put(None) for worker in self.workers_list: worker.join() @@ -116,7 +114,7 @@ class Dispatcher: log.debug("{} started".format(name)) while True: - update = self.updates.get() + update = self.updates_queue.get() if update is None: break @@ -126,7 +124,7 @@ class Dispatcher: chats = {i.id: i for i in update[2]} update = update[0] - parser = Dispatcher.UPDATES.get(type(update), None) + parser = self.update_parsers.get(type(update), None) if parser is None: continue diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index ee812c3a..404ad39d 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -68,7 +68,7 @@ class Message(Object): new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created, migrate_to_chat_id, migrate_from_chat_id, pinned_message. - media (``bool``` *optional*): + media (``bool`` *optional*): The message is a media message. A media message has one and only one of these fields set: audio, document, photo, sticker, video, animation, voice, video_note, contact, location, venue. @@ -391,7 +391,7 @@ class Message(Object): ) def edit(self, text: str, parse_mode: str = "", disable_web_page_preview: bool = None, reply_markup=None): - """Bound method *edit* of :obj:`Message + """Bound method *edit* of :obj:`Message ` Use as a shortcut for: