diff --git a/apps/telegram-bot/commands.py b/apps/telegram-bot/commands.py index d2f3562..51f5990 100644 --- a/apps/telegram-bot/commands.py +++ b/apps/telegram-bot/commands.py @@ -438,24 +438,14 @@ async def cmd_untrack(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: user_id = get_user_id(update) room_id = get_room_id(update) - import logging - - logging.info( - f"cmd_start: user_id={user_id}, room_id={room_id}, is_group={is_group(update)}" - ) if is_group(update): try: chat_member = await ctx.bot.get_chat_member(room_id, user_id) - logging.info(f"cmd_start: chat_member.status={chat_member.status}") if chat_member.status == "creator" and not BOUNTY_SERVICE.is_admin( room_id, user_id ): - logging.info(f"cmd_start: Promoting user {user_id} to admin") BOUNTY_SERVICE.add_admin(room_id, user_id, user_id) - logging.info( - f"cmd_start: After add_admin, is_admin={BOUNTY_SERVICE.is_admin(room_id, user_id)}" - ) await update.message.reply_text( "👻 JIGAIDO is watching.\n\n" "This group's bounty list is now active.\n" @@ -466,8 +456,7 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: "/my — your tracked bounties" ) return - except Exception as e: - logging.error(f"cmd_start: Exception in group start: {e}") + except Exception: pass await update.message.reply_text( @@ -480,7 +469,6 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: ) else: if not BOUNTY_SERVICE.is_admin(room_id, user_id): - logging.info(f"cmd_start: DM - promoting user {user_id} to admin") BOUNTY_SERVICE.add_admin(room_id, user_id, user_id) await update.message.reply_text( diff --git a/core/services.py b/core/services.py index f233aa1..a9105af 100644 --- a/core/services.py +++ b/core/services.py @@ -36,51 +36,23 @@ class BountyService: self, room_id: int, admin_user_id: int, requesting_user_id: int ) -> None: """Add an admin to a room. Requires admin permission, or self-promotion if first admin.""" - import logging - - logging.info( - f"add_admin: room_id={room_id}, admin_user_id={admin_user_id}, requesting_user_id={requesting_user_id}" - ) - room_data = self._storage.load(room_id) - logging.info( - f"add_admin: loaded room_data.admin_user_ids={room_data.admin_user_ids if room_data else None}" - ) has_no_admins = room_data is None or not room_data.admin_user_ids is_self_promotion = requesting_user_id == admin_user_id - logging.info( - f"add_admin: has_no_admins={has_no_admins}, is_self_promotion={is_self_promotion}" - ) if not self.is_admin(room_id, requesting_user_id): if not (has_no_admins and is_self_promotion): - logging.error("add_admin: PermissionError raised") raise PermissionError("Only admins can add admins.") - logging.info("add_admin: Self-promotion allowed") - if room_data is None: + if room_data is None or room_data.admin_user_ids is None: room_data = RoomData( room_id=room_id, bounties=[], next_id=1, admin_user_ids=[] ) - logging.info("add_admin: Created new RoomData") - - logging.info( - f"add_admin: Before append, room_data.admin_user_ids={room_data.admin_user_ids}" - ) if admin_user_id not in (room_data.admin_user_ids or []): - logging.info(f"add_admin: Appending {admin_user_id}") room_data.admin_user_ids.append(admin_user_id) - logging.info( - f"add_admin: After append, room_data.admin_user_ids={room_data.admin_user_ids}" - ) self._storage.save(room_data) - logging.info("add_admin: Saved") - else: - logging.info( - f"add_admin: {admin_user_id} already in admin_user_ids, not appending" - ) def remove_admin( self, room_id: int, admin_user_id: int, requesting_user_id: int