mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +00:00
Fix wrong sender_chat
This commit is contained in:
parent
e2cce1b1e6
commit
439935b401
@ -513,12 +513,12 @@ class Message(Object, Update):
|
|||||||
service_type = "voice_chat_members_invited"
|
service_type = "voice_chat_members_invited"
|
||||||
|
|
||||||
from_user = types.User._parse(client, users.get(user_id, None))
|
from_user = types.User._parse(client, users.get(user_id, None))
|
||||||
sender_chat = types.Chat._parse(client, message, users, chats) if not from_user else None
|
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
|
||||||
|
|
||||||
parsed_message = Message(
|
parsed_message = Message(
|
||||||
message_id=message.id,
|
message_id=message.id,
|
||||||
date=message.date,
|
date=message.date,
|
||||||
chat=types.Chat._parse(client, message, users, chats),
|
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
||||||
from_user=from_user,
|
from_user=from_user,
|
||||||
sender_chat=sender_chat,
|
sender_chat=sender_chat,
|
||||||
service=service_type,
|
service=service_type,
|
||||||
@ -707,12 +707,12 @@ class Message(Object, Update):
|
|||||||
reply_markup = None
|
reply_markup = None
|
||||||
|
|
||||||
from_user = types.User._parse(client, users.get(user_id, None))
|
from_user = types.User._parse(client, users.get(user_id, None))
|
||||||
sender_chat = types.Chat._parse(client, message, users, chats) if not from_user else None
|
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
|
||||||
|
|
||||||
parsed_message = Message(
|
parsed_message = Message(
|
||||||
message_id=message.id,
|
message_id=message.id,
|
||||||
date=message.date,
|
date=message.date,
|
||||||
chat=types.Chat._parse(client, message, users, chats),
|
chat=types.Chat._parse(client, message, users, chats, is_chat=True),
|
||||||
from_user=from_user,
|
from_user=from_user,
|
||||||
sender_chat=sender_chat,
|
sender_chat=sender_chat,
|
||||||
text=(
|
text=(
|
||||||
|
@ -238,14 +238,23 @@ class Chat(Object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, message: Union[raw.types.Message, raw.types.MessageService], users: dict, chats: dict) -> "Chat":
|
def _parse(
|
||||||
|
client,
|
||||||
|
message: Union[raw.types.Message, raw.types.MessageService],
|
||||||
|
users: dict,
|
||||||
|
chats: dict,
|
||||||
|
is_chat: bool
|
||||||
|
) -> "Chat":
|
||||||
if isinstance(message.peer_id, raw.types.PeerUser):
|
if isinstance(message.peer_id, raw.types.PeerUser):
|
||||||
return Chat._parse_user_chat(client, users[message.peer_id.user_id])
|
user_id = message.peer_id.user_id if is_chat else message.from_id.user_id
|
||||||
|
return Chat._parse_user_chat(client, users[user_id])
|
||||||
|
|
||||||
if isinstance(message.peer_id, raw.types.PeerChat):
|
if isinstance(message.peer_id, raw.types.PeerChat):
|
||||||
return Chat._parse_chat_chat(client, chats[message.peer_id.chat_id])
|
chat_id = message.peer_id.chat_id if is_chat else message.from_id.chat_id
|
||||||
|
return Chat._parse_chat_chat(client, chats[chat_id])
|
||||||
|
|
||||||
return Chat._parse_channel_chat(client, chats[message.peer_id.channel_id])
|
channel_id = message.peer_id.channel_id if is_chat else message.from_id.channel_id
|
||||||
|
return Chat._parse_channel_chat(client, chats[channel_id])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_dialog(client, peer, users: dict, chats: dict):
|
def _parse_dialog(client, peer, users: dict, chats: dict):
|
||||||
|
Loading…
Reference in New Issue
Block a user