From 633fefe1785f5b50a664462e766ac6f3e80a52ef Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 7 Jan 2019 22:28:41 +0100 Subject: [PATCH] Add get_game_high_scores method --- docs/source/pyrogram/Client.rst | 1 + pyrogram/client/methods/messages/__init__.py | 8 ++- .../methods/messages/get_game_high_scores.py | 60 +++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 pyrogram/client/methods/messages/get_game_high_scores.py diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst index 2e2e1d96..9a1b0509 100644 --- a/docs/source/pyrogram/Client.rst +++ b/docs/source/pyrogram/Client.rst @@ -140,6 +140,7 @@ Bots request_callback_answer send_game set_game_score + get_game_high_scores .. autoclass:: pyrogram.Client diff --git a/pyrogram/client/methods/messages/__init__.py b/pyrogram/client/methods/messages/__init__.py index 252bf1db..a46b3c0c 100644 --- a/pyrogram/client/methods/messages/__init__.py +++ b/pyrogram/client/methods/messages/__init__.py @@ -24,6 +24,7 @@ from .edit_message_media import EditMessageMedia from .edit_message_reply_markup import EditMessageReplyMarkup from .edit_message_text import EditMessageText from .forward_messages import ForwardMessages +from .get_game_high_scores import GetGameHighScores from .get_history import GetHistory from .get_messages import GetMessages from .iter_history import IterHistory @@ -33,7 +34,7 @@ from .send_audio import SendAudio from .send_chat_action import SendChatAction from .send_contact import SendContact from .send_document import SendDocument -from .send_game import SendGame +from pyrogram.client.methods.bots.send_game import SendGame from .send_location import SendLocation from .send_media_group import SendMediaGroup from .send_message import SendMessage @@ -44,8 +45,8 @@ from .send_venue import SendVenue from .send_video import SendVideo from .send_video_note import SendVideoNote from .send_voice import SendVoice +from pyrogram.client.methods.bots.set_game_score import SetGameScore from .vote_poll import VotePoll -from .set_game_score import SetGameScore class Messages( @@ -78,6 +79,7 @@ class Messages( DownloadMedia, IterHistory, SendGame, - SetGameScore + SetGameScore, + GetGameHighScores ): pass diff --git a/pyrogram/client/methods/messages/get_game_high_scores.py b/pyrogram/client/methods/messages/get_game_high_scores.py new file mode 100644 index 00000000..9816c38e --- /dev/null +++ b/pyrogram/client/methods/messages/get_game_high_scores.py @@ -0,0 +1,60 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2019 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from typing import Union + +import pyrogram +from pyrogram.api import functions +from ...ext import BaseClient + + +class GetGameHighScores(BaseClient): + def get_game_high_scores(self, + user_id: Union[int, str], + chat_id: Union[int, str], + message_id: int = None): + """Use this method to get data for high score tables. + + Args: + user_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + For your personal cloud (Saved Messages) you can simply use "me" or "self". + For a contact that exists in your Telegram address book you can use his phone number (str). + + chat_id (``int`` | ``str``, *optional*): + Unique identifier (int) or username (str) of the target chat. + For your personal cloud (Saved Messages) you can simply use "me" or "self". + For a contact that exists in your Telegram address book you can use his phone number (str). + Required if inline_message_id is not specified. + + message_id (``int``, *optional*): + Identifier of the sent message. + Required if inline_message_id is not specified. + """ + # TODO: inline_message_id + + return pyrogram.GameHighScores._parse( + self, + self.send( + functions.messages.GetGameHighScores( + peer=self.resolve_peer(chat_id), + id=message_id, + user_id=self.resolve_peer(user_id) + ) + ) + )