From 68f151bad5b8e4b1ebb14a1c8ee39b27306d0722 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:56:07 +0200 Subject: [PATCH] Merge changes --- pyrogram/methods/bots/delete_bot_commands.py | 7 +++---- pyrogram/methods/bots/get_bot_commands.py | 11 +++++++---- pyrogram/methods/bots/set_bot_commands.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pyrogram/methods/bots/delete_bot_commands.py b/pyrogram/methods/bots/delete_bot_commands.py index edb82deb..98e6d396 100644 --- a/pyrogram/methods/bots/delete_bot_commands.py +++ b/pyrogram/methods/bots/delete_bot_commands.py @@ -18,15 +18,14 @@ import pyrogram from pyrogram import raw, types -from pyrogram.scaffold import Scaffold -class DeleteBotCommands(Scaffold): +class DeleteBotCommands: async def delete_bot_commands( self: "pyrogram.Client", scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), language_code: str = "", - ): + ) -> bool: """Delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. @@ -53,7 +52,7 @@ class DeleteBotCommands(Scaffold): app.delete_bot_commands() """ - return await self.send( + return await self.invoke( raw.functions.bots.ResetBotCommands( scope=await scope.write(self), lang_code=language_code, diff --git a/pyrogram/methods/bots/get_bot_commands.py b/pyrogram/methods/bots/get_bot_commands.py index c92bd21e..fe5be0f3 100644 --- a/pyrogram/methods/bots/get_bot_commands.py +++ b/pyrogram/methods/bots/get_bot_commands.py @@ -16,17 +16,18 @@ # 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 import raw, types -from pyrogram.scaffold import Scaffold -class GetBotCommands(Scaffold): +class GetBotCommands: async def get_bot_commands( self: "pyrogram.Client", scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), language_code: str = "", - ): + ) -> List["types.BotCommand"]: """Get the current list of the bot's commands for the given scope and user language. Returns Array of BotCommand on success. If commands aren't set, an empty list is returned. @@ -54,9 +55,11 @@ class GetBotCommands(Scaffold): print(commands) """ - return await self.send( + r = await self.invoke( raw.functions.bots.GetBotCommands( scope=await scope.write(self), lang_code=language_code, ) ) + + return types.List(types.BotCommand.read(c) for c in r) diff --git a/pyrogram/methods/bots/set_bot_commands.py b/pyrogram/methods/bots/set_bot_commands.py index 6df1a2e4..b59c0fac 100644 --- a/pyrogram/methods/bots/set_bot_commands.py +++ b/pyrogram/methods/bots/set_bot_commands.py @@ -29,7 +29,7 @@ class SetBotCommands: commands: List["types.BotCommand"], scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), language_code: str = "", - ): + ) -> bool: """Set the list of the bot's commands. The commands passed will overwrite any command set previously. This method can be used by the own bot only.