2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-30 05:48:14 +00:00

Remove chat field for now, it can be accessed via message.chat

This commit is contained in:
Dan 2018-04-29 17:19:16 +02:00
parent d6bdf5f38b
commit b8996b1147
3 changed files with 10 additions and 11 deletions

View File

@ -161,7 +161,7 @@ class Dispatcher:
self.dispatch( self.dispatch(
pyrogram.Update( pyrogram.Update(
callback_query=utils.parse_callback_query( callback_query=utils.parse_callback_query(
self.client, update, users, chats self.client, update, users
) )
) )
) )

View File

@ -59,7 +59,6 @@ class CallbackQuery(Object):
self, self,
id: str, id: str,
from_user, from_user,
chat,
chat_instance: str, chat_instance: str,
message=None, message=None,
inline_message_id: str = None, inline_message_id: str = None,
@ -68,7 +67,6 @@ class CallbackQuery(Object):
): ):
self.id = id # string self.id = id # string
self.from_user = from_user # User self.from_user = from_user # User
self.chat = chat
self.message = message # flags.0?Message self.message = message # flags.0?Message
self.inline_message_id = inline_message_id # flags.1?string self.inline_message_id = inline_message_id # flags.1?string
self.chat_instance = chat_instance # string self.chat_instance = chat_instance # string

View File

@ -723,19 +723,20 @@ def parse_photos(photos):
) )
def parse_callback_query(client, callback_query, users, chats): def parse_callback_query(client, callback_query, users):
if isinstance(callback_query.peer, types.PeerUser): peer = callback_query.peer
chat = parse_user_chat(users[callback_query.peer.user_id])
elif isinstance(callback_query.peer, types.PeerChat): if isinstance(peer, types.PeerUser):
chat = parse_chat_chat(chats[callback_query.peer.chat_id]) peer_id = peer.user_id
elif isinstance(peer, types.PeerChat):
peer_id = -peer.chat_id
else: else:
chat = parse_channel_chat(chats[callback_query.peer.channel_id]) peer_id = int("-100" + str(peer.channel_id))
return pyrogram_types.CallbackQuery( return pyrogram_types.CallbackQuery(
id=callback_query.query_id, id=callback_query.query_id,
from_user=parse_user(users[callback_query.user_id]), from_user=parse_user(users[callback_query.user_id]),
chat=chat, message=client.get_messages(peer_id, callback_query.msg_id),
message=client.get_messages(chat.id, callback_query.msg_id),
chat_instance=str(callback_query.chat_instance), chat_instance=str(callback_query.chat_instance),
data=callback_query.data.decode(), data=callback_query.data.decode(),
game_short_name=callback_query.game_short_name game_short_name=callback_query.game_short_name