debug: add logging to cmd_start for troubleshooting admin promotion
Adding logging to understand why group creator admin promotion may not be working in production.
This commit is contained in:
@@ -438,14 +438,24 @@ async def cmd_untrack(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
user_id = get_user_id(update)
|
user_id = get_user_id(update)
|
||||||
room_id = get_room_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):
|
if is_group(update):
|
||||||
try:
|
try:
|
||||||
chat_member = await ctx.bot.get_chat_member(room_id, user_id)
|
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(
|
if chat_member.status == "creator" and not BOUNTY_SERVICE.is_admin(
|
||||||
room_id, user_id
|
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)
|
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(
|
await update.message.reply_text(
|
||||||
"👻 JIGAIDO is watching.\n\n"
|
"👻 JIGAIDO is watching.\n\n"
|
||||||
"This group's bounty list is now active.\n"
|
"This group's bounty list is now active.\n"
|
||||||
@@ -456,7 +466,8 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
"/my — your tracked bounties"
|
"/my — your tracked bounties"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logging.error(f"cmd_start: Exception in group start: {e}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
@@ -469,6 +480,7 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if not BOUNTY_SERVICE.is_admin(room_id, user_id):
|
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)
|
BOUNTY_SERVICE.add_admin(room_id, user_id, user_id)
|
||||||
|
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
|
|||||||
Reference in New Issue
Block a user