From bac6830fc30e478a96cc9aa03f818a6b9b4c3d4d Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Sat, 4 Apr 2026 17:59:20 +0700 Subject: [PATCH] feat(/add): add admin-only and link uniqueness handling Wrap add_bounty call in try-except to handle PermissionError and ValueError from admin check and link uniqueness check. Fixes #45 --- apps/telegram-bot/commands.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/telegram-bot/commands.py b/apps/telegram-bot/commands.py index ae66faa..609a921 100644 --- a/apps/telegram-bot/commands.py +++ b/apps/telegram-bot/commands.py @@ -229,13 +229,20 @@ async def cmd_add(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: user_id = get_user_id(update) room_id = get_room_id(update) - bounty = BOUNTY_SERVICE.add_bounty( - room_id=room_id, - user_id=user_id, - text=text, - link=link, - due_date_ts=due_date_ts, - ) + try: + bounty = BOUNTY_SERVICE.add_bounty( + room_id=room_id, + user_id=user_id, + text=text, + link=link, + due_date_ts=due_date_ts, + ) + except PermissionError as e: + await update.message.reply_text(f"⛔ {e}") + return + except ValueError as e: + await update.message.reply_text(f"⛔ {e}") + return due_str = "" if due_date_ts: -- 2.49.1