2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 21:38:04 +00:00

Merge branch 'develop'

This commit is contained in:
Dan 2018-11-13 20:40:43 +01:00
commit 3b3fec8293
5 changed files with 14 additions and 16 deletions

View File

@ -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

View File

@ -23,7 +23,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance
"e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
)
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
__version__ = "0.9.2"
__version__ = "0.9.3"
from .api.errors import Error
from .client.types import (

View File

@ -851,7 +851,7 @@ class Client(Methods, BaseClient):
if len(self.channels_pts[channel_id]) > 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:

View File

@ -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

View File

@ -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 <pyrogram.Message>
"""Bound method *edit* of :obj:`Message <pyrogram.Message>`
Use as a shortcut for: