From 780cba63011203c8c012b9f01dda9c60e7d48683 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Sat, 4 Apr 2026 05:43:50 +0000 Subject: [PATCH] feat: implement /show command to display full bounty details - Add cmd_show function to display bounty details including: - ID and full text (not sliced) - Link if exists - Due date formatted with room timezone - Created by username - Created at timestamp - Register show command handler in bot.py - Add show command to help text and bot command list - Fixes #44 --- apps/telegram-bot/bot.py | 3 +++ apps/telegram-bot/commands.py | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/apps/telegram-bot/bot.py b/apps/telegram-bot/bot.py index c72df9c..5d30328 100644 --- a/apps/telegram-bot/bot.py +++ b/apps/telegram-bot/bot.py @@ -13,6 +13,7 @@ from commands import ( cmd_edit, cmd_help, cmd_my, + cmd_show, cmd_start, cmd_track, cmd_untrack, @@ -41,6 +42,7 @@ def build_app() -> Application: app.add_handler(CommandHandler("delete", cmd_delete)) app.add_handler(CommandHandler("track", cmd_track)) app.add_handler(CommandHandler("untrack", cmd_untrack)) + app.add_handler(CommandHandler("show", cmd_show)) app.add_handler(MessageHandler(filters.COMMAND, cmd_help)) @@ -56,6 +58,7 @@ async def post_init(app: Application) -> None: ("edit", "Edit a bounty"), ("track", "Track a bounty"), ("untrack", "Stop tracking"), + ("show", "Show bounty details"), ("help", "Show help"), ] ) diff --git a/apps/telegram-bot/commands.py b/apps/telegram-bot/commands.py index b0ae05e..88f6055 100644 --- a/apps/telegram-bot/commands.py +++ b/apps/telegram-bot/commands.py @@ -311,6 +311,48 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: ) +async def cmd_show(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: + args = extract_args(update.message.text) + if not args: + await update.message.reply_text("Usage: /show ") + return + + try: + bounty_id = int(args[0]) + except ValueError: + await update.message.reply_text("Invalid bounty ID.") + return + + room_id = get_room_id(update) + bounty = BOUNTY_SERVICE.get_bounty(room_id, bounty_id) + + if not bounty: + await update.message.reply_text("Bounty not found.") + return + + timezone = BOUNTY_SERVICE.get_timezone(room_id) + + lines = [] + + title = bounty.text or "(no text)" + lines.append(f"[#{bounty.id}] {title}") + + if bounty.link: + lines.append(f"🔗 {bounty.link}") + + if bounty.due_date_ts: + due_str = time.strftime("%d %B %Y %H:%M", time.localtime(bounty.due_date_ts)) + lines.append(f"📅 {due_str} ({timezone})") + + username = bounty.created_by_username or f"user#{bounty.created_by_user_id}" + lines.append(f"👤 @{username}") + + created_str = time.strftime("%Y-%m-%d %H:%M", time.localtime(bounty.created_at)) + lines.append(f"📌 Created: {created_str}") + + await update.message.reply_text("\n".join(lines), disable_web_page_preview=True) + + async def cmd_help(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text( "👻 JIGAIDO Commands:\n\n" @@ -321,6 +363,7 @@ async def cmd_help(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: "/delete — delete bounty\n" "/track — track a bounty (groups only)\n" "/untrack — stop tracking (groups only)\n" + "/show — show bounty details\n" "/start — re-initialize\n" "/help — this message", disable_web_page_preview=True,