From 6d3aa84af9277db1afd20ac4d7c94a8fb325146b Mon Sep 17 00:00:00 2001 From: kyx236 Date: Fri, 30 Jan 2026 10:15:26 +0800 Subject: [PATCH] feat(telegram_bot): Add simplified team registration format with output options - Add support for simplified team_reg callback format (team_reg:1, team_reg:3, team_reg:5) - Implement direct count parsing from callback data without intermediate steps - Add output method selection UI with JSON file and team.json options - Add custom count input handler for flexible registration quantities (1-50) - Improve user experience by reducing callback navigation steps - Set user state flag for awaiting custom count input --- telegram_bot.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/telegram_bot.py b/telegram_bot.py index 7c5ac40..107551e 100644 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -3342,6 +3342,43 @@ class ProvisionerBot: action = data[1] if len(data) > 1 else "" value = data[2] if len(data) > 2 else "" + # 处理简化格式: team_reg:1, team_reg:3, team_reg:5, team_reg:custom + if action.isdigit(): + # team_reg:1 -> 直接是数量 + count = int(action) + # 显示输出方式选择 + keyboard = [ + [ + InlineKeyboardButton("📄 JSON 文件", callback_data=f"team_reg:output:json:{count}"), + ], + [ + InlineKeyboardButton("📥 添加到 team.json", callback_data=f"team_reg:output:team:{count}"), + ], + ] + reply_markup = InlineKeyboardMarkup(keyboard) + + await query.edit_message_text( + f"⚙️ 配置完成\n\n" + f"注册数量: {count} 个\n\n" + f"请选择输出方式:", + parse_mode="HTML", + reply_markup=reply_markup + ) + return + + if action == "custom": + # team_reg:custom -> 自定义数量 + await query.edit_message_text( + "📝 自定义数量\n\n" + "请发送数量 (1-50):\n" + "直接回复一个数字即可\n\n" + "例如: 20", + parse_mode="HTML" + ) + # 设置等待输入状态 + context.user_data["team_waiting_count"] = True + return + if action == "count": if value == "custom": await query.edit_message_text(