diff --git a/pyrogram/client/ext/base_client.py b/pyrogram/client/ext/base_client.py index 45bab738..7d5e7a4b 100644 --- a/pyrogram/client/ext/base_client.py +++ b/pyrogram/client/ext/base_client.py @@ -96,29 +96,29 @@ class BaseClient: self.disconnect_handler = None - def send(self, *args, **kwargs): + async def send(self, *args, **kwargs): pass - def resolve_peer(self, *args, **kwargs): + async def resolve_peer(self, *args, **kwargs): pass - def fetch_peers(self, *args, **kwargs): + async def fetch_peers(self, *args, **kwargs): pass - def add_handler(self, *args, **kwargs): + async def add_handler(self, *args, **kwargs): pass - def save_file(self, *args, **kwargs): + async def save_file(self, *args, **kwargs): pass - def get_messages(self, *args, **kwargs): + async def get_messages(self, *args, **kwargs): pass - def get_history(self, *args, **kwargs): + async def get_history(self, *args, **kwargs): pass - def get_dialogs(self, *args, **kwargs): + async def get_dialogs(self, *args, **kwargs): pass - def get_chat_members(self, *args, **kwargs): + async def get_chat_members(self, *args, **kwargs): pass diff --git a/pyrogram/client/methods/bots/get_game_high_scores.py b/pyrogram/client/methods/bots/get_game_high_scores.py index ad4f8b4a..e58bc17e 100644 --- a/pyrogram/client/methods/bots/get_game_high_scores.py +++ b/pyrogram/client/methods/bots/get_game_high_scores.py @@ -24,10 +24,10 @@ from pyrogram.client.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): + async 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: @@ -56,11 +56,11 @@ class GetGameHighScores(BaseClient): return pyrogram.GameHighScores._parse( self, - self.send( + await self.send( functions.messages.GetGameHighScores( - peer=self.resolve_peer(chat_id), + peer=await self.resolve_peer(chat_id), id=message_id, - user_id=self.resolve_peer(user_id) + user_id=await self.resolve_peer(user_id) ) ) ) diff --git a/pyrogram/client/methods/bots/send_game.py b/pyrogram/client/methods/bots/send_game.py index 401a5aa6..0f3593b0 100644 --- a/pyrogram/client/methods/bots/send_game.py +++ b/pyrogram/client/methods/bots/send_game.py @@ -24,15 +24,15 @@ from pyrogram.client.ext import BaseClient class SendGame(BaseClient): - def send_game(self, - chat_id: Union[int, str], - game_short_name: str, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + async def send_game(self, + chat_id: Union[int, str], + game_short_name: str, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union["pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply"] = None) -> "pyrogram.Message": """Use this method to send a game. Args: @@ -61,9 +61,9 @@ class SendGame(BaseClient): Raises: :class:`Error ` in case of a Telegram RPC error. """ - r = self.send( + r = await self.send( functions.messages.SendMedia( - peer=self.resolve_peer(chat_id), + peer=await self.resolve_peer(chat_id), media=types.InputMediaGame( id=types.InputGameShortName( bot_id=types.InputUserSelf(), @@ -80,7 +80,7 @@ class SendGame(BaseClient): for i in r.updates: if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): - return pyrogram.Message._parse( + return await pyrogram.Message._parse( self, i.message, {i.id: i for i in r.users}, {i.id: i for i in r.chats} diff --git a/pyrogram/client/methods/bots/set_game_score.py b/pyrogram/client/methods/bots/set_game_score.py index e9d20844..f90b7f46 100644 --- a/pyrogram/client/methods/bots/set_game_score.py +++ b/pyrogram/client/methods/bots/set_game_score.py @@ -24,13 +24,13 @@ from pyrogram.client.ext import BaseClient class SetGameScore(BaseClient): - def set_game_score(self, - user_id: Union[int, str], - score: int, - force: bool = None, - disable_edit_message: bool = None, - chat_id: Union[int, str] = None, - message_id: int = None): + async def set_game_score(self, + user_id: Union[int, str], + score: int, + force: bool = None, + disable_edit_message: bool = None, + chat_id: Union[int, str] = None, + message_id: int = None): # inline_message_id: str = None): TODO Add inline_message_id """Use this method to set the score of the specified user in a game. @@ -68,12 +68,12 @@ class SetGameScore(BaseClient): :class:`Error ` in case of a Telegram RPC error. :class:`BotScoreNotModified` if the new score is not greater than the user's current score in the chat and force is False. """ - r = self.send( + r = await self.send( functions.messages.SetGameScore( - peer=self.resolve_peer(chat_id), + peer=await self.resolve_peer(chat_id), score=score, id=message_id, - user_id=self.resolve_peer(user_id), + user_id=await self.resolve_peer(user_id), force=force or None, edit_message=not disable_edit_message or None ) @@ -81,7 +81,7 @@ class SetGameScore(BaseClient): for i in r.updates: if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)): - return pyrogram.Message._parse( + return await pyrogram.Message._parse( self, i.message, {i.id: i for i in r.users}, {i.id: i for i in r.chats} diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 77281425..f17eac93 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -423,7 +423,7 @@ class Message(PyrogramType, Update): if message.reply_to_msg_id and replies: try: - parsed_message.reply_to_message = client.get_messages( + parsed_message.reply_to_message = await client.get_messages( parsed_message.chat.id, reply_to_message_ids=message.id, replies=0 @@ -912,7 +912,11 @@ class Message(PyrogramType, Update): else: raise ValueError("The message doesn't contain any keyboard") - async def download(self, file_name: str = "", block: bool = True, progress: callable = None, progress_args: tuple = None): + async def download(self, + file_name: str = "", + block: bool = True, + progress: callable = None, + progress_args: tuple = None): """Bound method *download* of :obj:`Message `. Use as a shortcut for: