From 302513a7e7b569eea230dce7ac03fea8445a29ae Mon Sep 17 00:00:00 2001 From: nin0dev Date: Fri, 19 Jul 2024 12:59:45 -0400 Subject: [PATCH] added slash support --- main.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 4f90c74..2ae5ba4 100644 --- a/main.py +++ b/main.py @@ -1,32 +1,53 @@ import time import pyrogram from pyrogram import Client, filters, enums, types +from pyrogram.types import Message, BotCommand from dotenv import load_dotenv import os load_dotenv() +P = ["v", "/"] +COMMANDS = [ + BotCommand("help", "Get bot help"), + BotCommand("minky", "minker"), + BotCommand("sync", "(👑) Sync bot commands") +] +OWNER_ID = 1911826384 + app = Client( "venbot", api_id=os.getenv("API_ID"), api_hash=os.getenv("API_HASH"), bot_token=os.getenv("BOT_TOKEN") ) - - -@app.on_message(filters.command(["help"], prefixes="v")) -async def help(client, message: types.Message): +@app.on_message(filters.command(["help", "h"], prefixes=P)) +async def help(client, message: Message): await message.reply(""" - -v**help** (h) - Send this -v**minky** (mink, minker) - minker +--You can either use the `v` prefix or the native `/` commands from Telegram. Both work the same way-- +**help** (h) - Send this +**minky** (mink, minker) - minker +**sync** 👑 - Sync slash commands """, parse_mode=enums.ParseMode.MARKDOWN) #region Fun -@app.on_message(filters.command(["minky", "mink", "minker"], prefixes="v")) -async def minky(client, message: types.Message): +@app.on_message(filters.command(["minky", "mink", "minker"], prefixes=P)) +async def minky(client, message: Message): await message.reply_chat_action(enums.ChatAction.UPLOAD_PHOTO) await message.reply_photo(f"https://minky.materii.dev?{time.time()}") #endregion +#region Util +@app.on_message(filters.command("sync", prefixes=P)) +async def sync(client, message: Message): + await message.reply_chat_action(enums.ChatAction.TYPING) + if message.from_user.id != OWNER_ID: + await message.reply_voice("https://files.catbox.moe/8t4ljl.mp3") + return + await app.set_bot_commands(COMMANDS) + await message.reply("done") + await message.reply_chat_action(enums.ChatAction.CANCEL) + +#endregion + app.run() \ No newline at end of file