2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Merge changes

This commit is contained in:
Dan 2022-04-24 11:56:07 +02:00
parent 405528c74b
commit 68f151bad5
3 changed files with 11 additions and 9 deletions

View File

@ -18,15 +18,14 @@
import pyrogram import pyrogram
from pyrogram import raw, types from pyrogram import raw, types
from pyrogram.scaffold import Scaffold
class DeleteBotCommands(Scaffold): class DeleteBotCommands:
async def delete_bot_commands( async def delete_bot_commands(
self: "pyrogram.Client", self: "pyrogram.Client",
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "", language_code: str = "",
): ) -> bool:
"""Delete the list of the bot's commands for the given scope and user language. """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. After deletion, higher level commands will be shown to affected users.
@ -53,7 +52,7 @@ class DeleteBotCommands(Scaffold):
app.delete_bot_commands() app.delete_bot_commands()
""" """
return await self.send( return await self.invoke(
raw.functions.bots.ResetBotCommands( raw.functions.bots.ResetBotCommands(
scope=await scope.write(self), scope=await scope.write(self),
lang_code=language_code, lang_code=language_code,

View File

@ -16,17 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import List
import pyrogram import pyrogram
from pyrogram import raw, types from pyrogram import raw, types
from pyrogram.scaffold import Scaffold
class GetBotCommands(Scaffold): class GetBotCommands:
async def get_bot_commands( async def get_bot_commands(
self: "pyrogram.Client", self: "pyrogram.Client",
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "", language_code: str = "",
): ) -> List["types.BotCommand"]:
"""Get the current list of the bot's commands for the given scope and user language. """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. 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) print(commands)
""" """
return await self.send( r = await self.invoke(
raw.functions.bots.GetBotCommands( raw.functions.bots.GetBotCommands(
scope=await scope.write(self), scope=await scope.write(self),
lang_code=language_code, lang_code=language_code,
) )
) )
return types.List(types.BotCommand.read(c) for c in r)

View File

@ -29,7 +29,7 @@ class SetBotCommands:
commands: List["types.BotCommand"], commands: List["types.BotCommand"],
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(), scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "", language_code: str = "",
): ) -> bool:
"""Set the list of the bot's commands. """Set the list of the bot's commands.
The commands passed will overwrite any command set previously. The commands passed will overwrite any command set previously.
This method can be used by the own bot only. This method can be used by the own bot only.