From 8928ca34336a1ca5e1c8f5172e1a5dd3c62d9db5 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 7 Jan 2019 22:50:54 +0100 Subject: [PATCH] Rename game_score to game_high_score --- pyrogram/client/filters/filters.py | 4 ++-- pyrogram/client/types/bots/game_high_score.py | 12 ++++++++++-- pyrogram/client/types/messages_and_media/message.py | 8 ++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 01ffe434..77492c6a 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -172,8 +172,8 @@ class Filters: pinned_message = create("PinnedMessage", lambda _, m: bool(m.pinned_message)) """Filter service messages for pinned messages.""" - game_score = create("GameScore", lambda _, m: bool(m.game_score)) - """Filter service messages for game scores.""" + game_high_score = create("GameHighScore", lambda _, m: bool(m.game_high_score)) + """Filter service messages for game high scores.""" reply_keyboard = create("ReplyKeyboard", lambda _, m: isinstance(m.reply_markup, ReplyKeyboardMarkup)) """Filter messages containing reply keyboard markups""" diff --git a/pyrogram/client/types/bots/game_high_score.py b/pyrogram/client/types/bots/game_high_score.py index 1297d8a9..0541c18c 100644 --- a/pyrogram/client/types/bots/game_high_score.py +++ b/pyrogram/client/types/bots/game_high_score.py @@ -33,7 +33,7 @@ class GameHighScore(PyrogramType): score (``int``): Score. - position (``position``): + position (``position``, *optional*): Position in high score table for the game. """ @@ -42,7 +42,7 @@ class GameHighScore(PyrogramType): client: "pyrogram.client.ext.BaseClient", user: User, score: int, - position: int): + position: int = None): super().__init__(client) self.user = user @@ -59,3 +59,11 @@ class GameHighScore(PyrogramType): position=game_high_score.pos, client=client ) + + @staticmethod + def _parse_action(client, service: types.MessageService, users: dict): + return GameHighScore( + user=User._parse(client, users[service.from_id]), + score=service.action.score, + client=client + ) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index fddc4d0b..a323898c 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -202,7 +202,7 @@ class Message(PyrogramType, Update): Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. - game_score (``int``, *optional*): + game_high_score (:obj:`GameHighScore `, *optional*): The game score for a user. The reply_to_message field will contain the game Message. @@ -283,7 +283,7 @@ class Message(PyrogramType, Update): migrate_to_chat_id: int = None, migrate_from_chat_id: int = None, pinned_message: "Message" = None, - game_score: int = None, + game_high_score: int = None, views: int = None, via_bot: User = None, outgoing: bool = None, @@ -341,7 +341,7 @@ class Message(PyrogramType, Update): self.migrate_to_chat_id = migrate_to_chat_id self.migrate_from_chat_id = migrate_from_chat_id self.pinned_message = pinned_message - self.game_score = game_score + self.game_high_score = game_high_score self.views = views self.via_bot = via_bot self.outgoing = outgoing @@ -419,7 +419,7 @@ class Message(PyrogramType, Update): pass if isinstance(action, types.MessageActionGameScore): - parsed_message.game_score = action.score + parsed_message.game_high_score = pyrogram.GameHighScore._parse_action(client, message, users) if message.reply_to_msg_id and replies: try: