From b8996b114748c79c193954e43087ad4ea7299658 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 29 Apr 2018 17:19:16 +0200 Subject: [PATCH] Remove chat field for now, it can be accessed via message.chat --- pyrogram/client/dispatcher/dispatcher.py | 2 +- pyrogram/client/types/callback_query.py | 2 -- pyrogram/client/utils.py | 17 +++++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index b68ccc59..a62d0fab 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -161,7 +161,7 @@ class Dispatcher: self.dispatch( pyrogram.Update( callback_query=utils.parse_callback_query( - self.client, update, users, chats + self.client, update, users ) ) ) diff --git a/pyrogram/client/types/callback_query.py b/pyrogram/client/types/callback_query.py index e3b18b91..a015c067 100644 --- a/pyrogram/client/types/callback_query.py +++ b/pyrogram/client/types/callback_query.py @@ -59,7 +59,6 @@ class CallbackQuery(Object): self, id: str, from_user, - chat, chat_instance: str, message=None, inline_message_id: str = None, @@ -68,7 +67,6 @@ class CallbackQuery(Object): ): self.id = id # string self.from_user = from_user # User - self.chat = chat self.message = message # flags.0?Message self.inline_message_id = inline_message_id # flags.1?string self.chat_instance = chat_instance # string diff --git a/pyrogram/client/utils.py b/pyrogram/client/utils.py index 8fc6efb8..95ac63ba 100644 --- a/pyrogram/client/utils.py +++ b/pyrogram/client/utils.py @@ -723,19 +723,20 @@ def parse_photos(photos): ) -def parse_callback_query(client, callback_query, users, chats): - if isinstance(callback_query.peer, types.PeerUser): - chat = parse_user_chat(users[callback_query.peer.user_id]) - elif isinstance(callback_query.peer, types.PeerChat): - chat = parse_chat_chat(chats[callback_query.peer.chat_id]) +def parse_callback_query(client, callback_query, users): + peer = callback_query.peer + + if isinstance(peer, types.PeerUser): + peer_id = peer.user_id + elif isinstance(peer, types.PeerChat): + peer_id = -peer.chat_id else: - chat = parse_channel_chat(chats[callback_query.peer.channel_id]) + peer_id = int("-100" + str(peer.channel_id)) return pyrogram_types.CallbackQuery( id=callback_query.query_id, from_user=parse_user(users[callback_query.user_id]), - chat=chat, - message=client.get_messages(chat.id, callback_query.msg_id), + message=client.get_messages(peer_id, callback_query.msg_id), chat_instance=str(callback_query.chat_instance), data=callback_query.data.decode(), game_short_name=callback_query.game_short_name