mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Handle pts
This commit is contained in:
parent
85b573d1e5
commit
dc94386507
@ -133,6 +133,8 @@ class Client:
|
|||||||
self.peers_by_id = {}
|
self.peers_by_id = {}
|
||||||
self.peers_by_username = {}
|
self.peers_by_username = {}
|
||||||
|
|
||||||
|
self.channels_pts = {}
|
||||||
|
|
||||||
self.markdown = Markdown(self.peers_by_id)
|
self.markdown = Markdown(self.peers_by_id)
|
||||||
self.html = HTML(self.peers_by_id)
|
self.html = HTML(self.peers_by_id)
|
||||||
|
|
||||||
@ -274,6 +276,28 @@ class Client:
|
|||||||
self.fetch_peers(update.chats)
|
self.fetch_peers(update.chats)
|
||||||
|
|
||||||
for i in update.updates:
|
for i in update.updates:
|
||||||
|
channel_id = getattr(
|
||||||
|
getattr(
|
||||||
|
getattr(
|
||||||
|
i, "message", None
|
||||||
|
), "to_id", None
|
||||||
|
), "channel_id", None
|
||||||
|
) or getattr(i, "channel_id", None)
|
||||||
|
|
||||||
|
pts = getattr(i, "pts", None)
|
||||||
|
|
||||||
|
if channel_id and pts:
|
||||||
|
if channel_id not in self.channels_pts:
|
||||||
|
self.channels_pts[channel_id] = []
|
||||||
|
|
||||||
|
if pts in self.channels_pts[channel_id]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.channels_pts[channel_id].append(pts)
|
||||||
|
|
||||||
|
if len(self.channels_pts[channel_id]) > 50:
|
||||||
|
self.channels_pts[channel_id] = self.channels_pts[channel_id][25:]
|
||||||
|
|
||||||
self.event_queue.put((i, update.users, update.chats))
|
self.event_queue.put((i, update.users, update.chats))
|
||||||
elif isinstance(update, (types.UpdateShortMessage, types.UpdateShortChatMessage)):
|
elif isinstance(update, (types.UpdateShortMessage, types.UpdateShortChatMessage)):
|
||||||
diff = self.send(
|
diff = self.send(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user