From a769fdfd20ad94f54e5caee0079ffc39a15de9a3 Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sat, 8 Jun 2019 15:14:28 +0200
Subject: [PATCH] Remove GameHighScores type
---
docs/source/api/types.rst | 2 -
.../methods/bots/get_game_high_scores.py | 21 ++++---
pyrogram/client/types/keyboards/__init__.py | 5 +-
.../types/keyboards/game_high_scores.py | 60 -------------------
4 files changed, 12 insertions(+), 76 deletions(-)
delete mode 100644 pyrogram/client/types/keyboards/game_high_scores.py
diff --git a/docs/source/api/types.rst b/docs/source/api/types.rst
index 66d409c4..118c4261 100644
--- a/docs/source/api/types.rst
+++ b/docs/source/api/types.rst
@@ -71,7 +71,6 @@ Keyboards
- :class:`ForceReply`
- :class:`CallbackQuery`
- :class:`GameHighScore`
- - :class:`GameHighScores`
- :class:`CallbackGame`
Input Media
@@ -150,7 +149,6 @@ Details
.. autoclass:: ForceReply()
.. autoclass:: CallbackQuery()
.. autoclass:: GameHighScore()
-.. autoclass:: GameHighScores()
.. autoclass:: CallbackGame()
.. Input Media
diff --git a/pyrogram/client/methods/bots/get_game_high_scores.py b/pyrogram/client/methods/bots/get_game_high_scores.py
index e1472b9e..e6459bac 100644
--- a/pyrogram/client/methods/bots/get_game_high_scores.py
+++ b/pyrogram/client/methods/bots/get_game_high_scores.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from typing import Union
+from typing import Union, List
import pyrogram
from pyrogram.api import functions
@@ -29,7 +29,7 @@ class GetGameHighScores(BaseClient):
user_id: Union[int, str],
chat_id: Union[int, str],
message_id: int = None
- ) -> "pyrogram.GameHighScores":
+ ) -> List["pyrogram.GameHighScore"]:
"""Get data for high score tables.
Parameters:
@@ -49,20 +49,19 @@ class GetGameHighScores(BaseClient):
Required if inline_message_id is not specified.
Returns:
- :obj:`GameHighScores`: On success.
+ List of :obj:`GameHighScore`: On success.
Raises:
RPCError: In case of a Telegram RPC error.
"""
# 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)
- )
+ r = self.send(
+ functions.messages.GetGameHighScores(
+ peer=self.resolve_peer(chat_id),
+ id=message_id,
+ user_id=self.resolve_peer(user_id)
)
)
+
+ return pyrogram.List(pyrogram.GameHighScore._parse(self, score, r.users) for score in r.scores)
diff --git a/pyrogram/client/types/keyboards/__init__.py b/pyrogram/client/types/keyboards/__init__.py
index dae33e10..90376504 100644
--- a/pyrogram/client/types/keyboards/__init__.py
+++ b/pyrogram/client/types/keyboards/__init__.py
@@ -20,7 +20,6 @@ from .callback_game import CallbackGame
from .callback_query import CallbackQuery
from .force_reply import ForceReply
from .game_high_score import GameHighScore
-from .game_high_scores import GameHighScores
from .inline_keyboard_button import InlineKeyboardButton
from .inline_keyboard_markup import InlineKeyboardMarkup
from .keyboard_button import KeyboardButton
@@ -28,6 +27,6 @@ from .reply_keyboard_markup import ReplyKeyboardMarkup
from .reply_keyboard_remove import ReplyKeyboardRemove
__all__ = [
- "CallbackGame", "CallbackQuery", "ForceReply", "GameHighScore", "GameHighScores", "InlineKeyboardButton",
- "InlineKeyboardMarkup", "KeyboardButton", "ReplyKeyboardMarkup", "ReplyKeyboardRemove"
+ "CallbackGame", "CallbackQuery", "ForceReply", "GameHighScore", "InlineKeyboardButton", "InlineKeyboardMarkup",
+ "KeyboardButton", "ReplyKeyboardMarkup", "ReplyKeyboardRemove"
]
diff --git a/pyrogram/client/types/keyboards/game_high_scores.py b/pyrogram/client/types/keyboards/game_high_scores.py
deleted file mode 100644
index ea557cd5..00000000
--- a/pyrogram/client/types/keyboards/game_high_scores.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# 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 List
-
-import pyrogram
-from pyrogram.api import types
-from pyrogram.client.types.object import Object
-from .game_high_score import GameHighScore
-
-
-class GameHighScores(Object):
- """The high scores table for a game.
-
- Parameters:
- total_count (``int``):
- Total number of scores the target game has.
-
- game_high_scores (List of :obj:`GameHighScore`):
- Game scores.
- """
-
- __slots__ = ["total_count", "game_high_scores"]
-
- def __init__(
- self,
- *,
- client: "pyrogram.BaseClient" = None,
- total_count: int,
- game_high_scores: List[GameHighScore]
- ):
- super().__init__(client)
-
- self.total_count = total_count
- self.game_high_scores = game_high_scores
-
- @staticmethod
- def _parse(client, game_high_scores: types.messages.HighScores) -> "GameHighScores":
- return GameHighScores(
- total_count=len(game_high_scores.scores),
- game_high_scores=[
- GameHighScore._parse(client, score, game_high_scores.users)
- for score in game_high_scores.scores],
- client=client
- )