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
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,

View File

@ -16,17 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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)

View File

@ -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.