mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Only parse selected messages
This commit is contained in:
parent
91133812a7
commit
f1e1480c5a
@ -730,6 +730,9 @@ class Client:
|
|||||||
elif isinstance(message, types.MessageService):
|
elif isinstance(message, types.MessageService):
|
||||||
m = utils.parse_message_service(message, users, chats)
|
m = utils.parse_message_service(message, users, chats)
|
||||||
|
|
||||||
|
if m is None:
|
||||||
|
continue
|
||||||
|
|
||||||
if isinstance(message.action, types.MessageActionPinMessage):
|
if isinstance(message.action, types.MessageActionPinMessage):
|
||||||
pm = self.get_messages(m.chat.id, [message.reply_to_msg_id])
|
pm = self.get_messages(m.chat.id, [message.reply_to_msg_id])
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ def parse_user(user: types.User):
|
|||||||
) if user else None
|
) if user else None
|
||||||
|
|
||||||
|
|
||||||
def parse_chat(peer: types.PeerUser or types.PeerChat or types.PeerChannel, users: dict, chats: dict):
|
def parse_chat(message: types.Message, users: dict, chats: dict):
|
||||||
if isinstance(peer, types.PeerUser):
|
if isinstance(message.to_id, types.PeerUser):
|
||||||
return parse_user_chat(users[peer.user_id])
|
return parse_user_chat(users[message.from_id])
|
||||||
elif isinstance(peer, types.PeerChat):
|
elif isinstance(message.to_id, types.PeerChat):
|
||||||
return parse_chat_chat(chats[peer.chat_id])
|
return parse_chat_chat(chats[message.to_id.chat_id])
|
||||||
else:
|
else:
|
||||||
return parse_channel_chat(chats[peer.channel_id])
|
return parse_channel_chat(chats[message.to_id.channel_id])
|
||||||
|
|
||||||
|
|
||||||
def parse_user_chat(user: types.User):
|
def parse_user_chat(user: types.User):
|
||||||
@ -104,7 +104,7 @@ def parse_message(message: types.Message, users: dict, chats: dict):
|
|||||||
return pyrogram.Message(
|
return pyrogram.Message(
|
||||||
message_id=message.id,
|
message_id=message.id,
|
||||||
date=message.date,
|
date=message.date,
|
||||||
chat=parse_chat(message.to_id, users, chats),
|
chat=parse_chat(message, users, chats),
|
||||||
from_user=parse_user(users.get(message.from_id, None)),
|
from_user=parse_user(users.get(message.from_id, None)),
|
||||||
text=message.message or None if message.media is None else None,
|
text=message.message or None if message.media is None else None,
|
||||||
caption=message.message or None if message.media is not None else None,
|
caption=message.message or None if message.media is not None else None,
|
||||||
@ -147,6 +147,8 @@ def parse_message_service(message: types.MessageService, users: dict, chats: dic
|
|||||||
migrate_from_chat_id = action.chat_id
|
migrate_from_chat_id = action.chat_id
|
||||||
elif isinstance(action, types.MessageActionChatCreate):
|
elif isinstance(action, types.MessageActionChatCreate):
|
||||||
group_chat_created = True
|
group_chat_created = True
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
return pyrogram.Message(
|
return pyrogram.Message(
|
||||||
message_id=message.id,
|
message_id=message.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user