Add menu command

This commit is contained in:
2026-07-26 16:56:29 +02:00
parent 52d842d7be
commit 53aa9cfda7
2 changed files with 31 additions and 16 deletions
+2
View File
@@ -58,7 +58,9 @@ The database will be saved in `./bot_db/media.db`.
| Command | Description | | Command | Description |
|---|---| |---|---|
| `/menu` | Show the available commands |
| `/list` | Show all saved media | | `/list` | Show all saved media |
| `/edit [search]` | Select a meme and edit its keywords (admin only) |
| `/delete <id>` | Remove an entry (get ID from `/list`) | | `/delete <id>` | Remove an entry (get ID from `/list`) |
| `/cancel` | Cancel current add operation | | `/cancel` | Cancel current add operation |
+29 -16
View File
@@ -62,28 +62,41 @@ class EditMedia(StatesGroup):
waiting_for_new_keywords = State() waiting_for_new_keywords = State()
def menu_text(user_id: int) -> str:
if is_admin(user_id):
return (
"Send me any <b>photo, GIF, video, voice, or sticker</b>.\n"
"I'll ask you for keywords next.\n\n"
"/list — show all saved memes\n"
"/edit [search] — edit keywords of a meme\n"
"/delete &lt;id&gt; — remove a meme by ID\n"
"/cancel — cancel current operation"
)
return (
"Use me inline: type <code>@botname keyword</code> in any chat.\n\n"
"/list — browse all saved memes"
)
# ── /start ─────────────────────────────────────────────────────────────────── # ── /start ───────────────────────────────────────────────────────────────────
@dp.message(Command("start")) @dp.message(Command("start"))
async def cmd_start(msg: Message): async def cmd_start(msg: Message):
if not is_allowed(msg.from_user.id): if not is_allowed(msg.from_user.id):
return return
if is_admin(msg.from_user.id): await msg.answer(
await msg.answer( f"{menu_text(msg.from_user.id)}\n/menu — show this list again",
"Send me any <b>photo, GIF, video, voice, or sticker</b>.\n" parse_mode="HTML",
"I'll ask you for keywords next.\n\n" )
"/list — show all saved memes\n"
"/edit [search] — edit keywords of a meme\n"
"/delete &lt;id&gt; — remove a meme by ID\n" # ── /menu ────────────────────────────────────────────────────────────────────
"/cancel — cancel current operation",
parse_mode="HTML", @dp.message(Command("menu"))
) async def cmd_menu(msg: Message):
else: if not is_allowed(msg.from_user.id):
await msg.answer( return
"Use me inline: type <code>@botname keyword</code> in any chat.\n\n" await msg.answer(menu_text(msg.from_user.id), parse_mode="HTML")
"/list — browse all saved memes",
parse_mode="HTML",
)
# ── /cancel ────────────────────────────────────────────────────────────────── # ── /cancel ──────────────────────────────────────────────────────────────────