added slash support
This commit is contained in:
parent
61cdc17abd
commit
302513a7e7
1 changed files with 30 additions and 9 deletions
39
main.py
39
main.py
|
@ -1,32 +1,53 @@
|
||||||
import time
|
import time
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram import Client, filters, enums, types
|
from pyrogram import Client, filters, enums, types
|
||||||
|
from pyrogram.types import Message, BotCommand
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
P = ["v", "/"]
|
||||||
|
COMMANDS = [
|
||||||
|
BotCommand("help", "Get bot help"),
|
||||||
|
BotCommand("minky", "minker"),
|
||||||
|
BotCommand("sync", "(👑) Sync bot commands")
|
||||||
|
]
|
||||||
|
OWNER_ID = 1911826384
|
||||||
|
|
||||||
app = Client(
|
app = Client(
|
||||||
"venbot",
|
"venbot",
|
||||||
api_id=os.getenv("API_ID"), api_hash=os.getenv("API_HASH"),
|
api_id=os.getenv("API_ID"), api_hash=os.getenv("API_HASH"),
|
||||||
bot_token=os.getenv("BOT_TOKEN")
|
bot_token=os.getenv("BOT_TOKEN")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.on_message(filters.command(["help", "h"], prefixes=P))
|
||||||
|
async def help(client, message: Message):
|
||||||
@app.on_message(filters.command(["help"], prefixes="v"))
|
|
||||||
async def help(client, message: types.Message):
|
|
||||||
await message.reply("""
|
await message.reply("""
|
||||||
|
--You can either use the `v` prefix or the native `/` commands from Telegram. Both work the same way--
|
||||||
v**help** (h) - Send this
|
**help** (h) - Send this
|
||||||
v**minky** (mink, minker) - minker
|
**minky** (mink, minker) - minker
|
||||||
|
**sync** 👑 - Sync slash commands
|
||||||
""", parse_mode=enums.ParseMode.MARKDOWN)
|
""", parse_mode=enums.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
#region Fun
|
#region Fun
|
||||||
@app.on_message(filters.command(["minky", "mink", "minker"], prefixes="v"))
|
@app.on_message(filters.command(["minky", "mink", "minker"], prefixes=P))
|
||||||
async def minky(client, message: types.Message):
|
async def minky(client, message: Message):
|
||||||
await message.reply_chat_action(enums.ChatAction.UPLOAD_PHOTO)
|
await message.reply_chat_action(enums.ChatAction.UPLOAD_PHOTO)
|
||||||
await message.reply_photo(f"https://minky.materii.dev?{time.time()}")
|
await message.reply_photo(f"https://minky.materii.dev?{time.time()}")
|
||||||
#endregion
|
#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()
|
app.run()
|
Loading…
Reference in a new issue