diff --git a/handlers/bind.py b/handlers/bind.py index 9dc5be4..f6c2f14 100644 --- a/handlers/bind.py +++ b/handlers/bind.py @@ -107,6 +107,31 @@ async def handle_private_bind_text(update: Update, context: ContextTypes.DEFAULT await safe_reply(update, context, f"❌ 验证失败:{result.get('msg') or result.get('reason') or '授权信息无效'}\n请重新发送:邮箱 Token") +async def cmd_me(update: Update, context: ContextTypes.DEFAULT_TYPE): + """查看当前 TG 用户绑定的授权信息。""" + user = update.effective_user + binding = await get_binding(user.id) + if not binding: + text = ( + "👤 当前账号还没有绑定授权信息\n\n" + "绑定后我可以帮你识别授权状态和到期时间。\n" + "请发送 /bind,然后按提示到私聊里提交邮箱和 Token。" + ) + else: + text = ( + "👤 我的授权信息\n" + "━━━━━━━━━━━━━━━━━━━━\n" + f"📧 授权邮箱:{binding.get('email') or '-'}\n" + f"⏳ 到期时间:{binding.get('time_expire') or '未返回'}\n" + f"🔗 绑定时间:{binding.get('bound_at') or '-'}\n\n" + "如需更换授权,请先 /unbind,再 /bind 重新绑定。" + ) + reply = await safe_reply(update, context, text) + if update.effective_chat.type != "private": + asyncio.create_task(auto_delete(update.message, seconds=60)) + asyncio.create_task(auto_delete(reply, seconds=60)) + + async def cmd_unbind(update: Update, context: ContextTypes.DEFAULT_TYPE): """解绑 harvest 账号""" user = update.effective_user @@ -131,5 +156,6 @@ async def auto_delete(message, seconds=60): def register_bind(app): app.add_handler(CommandHandler("start", cmd_start, filters.ChatType.PRIVATE)) app.add_handler(CommandHandler("bind", cmd_bind)) + app.add_handler(CommandHandler("me", cmd_me)) app.add_handler(CommandHandler("unbind", cmd_unbind)) app.add_handler(MessageHandler(filters.TEXT & filters.ChatType.PRIVATE & ~filters.COMMAND, handle_private_bind_text), group=0) diff --git a/main.py b/main.py index 922747e..8f3a7c4 100644 --- a/main.py +++ b/main.py @@ -66,11 +66,27 @@ async def start_tg_bot(): from telegram.request import HTTPXRequest - proxy_request = HTTPXRequest(proxy=PROXY_URL, connect_timeout=20.0, read_timeout=20.0, write_timeout=20.0, pool_timeout=5.0) + proxy_request = HTTPXRequest( + proxy=PROXY_URL, + connection_pool_size=64, + connect_timeout=30.0, + read_timeout=30.0, + write_timeout=30.0, + pool_timeout=30.0, + ) + get_updates_request = HTTPXRequest( + proxy=PROXY_URL, + connection_pool_size=8, + connect_timeout=30.0, + read_timeout=60.0, + write_timeout=30.0, + pool_timeout=30.0, + ) tg_app = ( Application.builder() .token(config.TG_BOT_TOKEN) .request(proxy_request) + .get_updates_request(get_updates_request) .build() ) @@ -88,6 +104,7 @@ async def start_tg_bot(): BotCommand("checkin", "✅ 每日签到"), BotCommand("trivia", "🎮 知识答题"), BotCommand("bind", "🔗 绑定账号"), + BotCommand("me", "👤 查看授权信息"), BotCommand("dban", "🗑️ 删除并封禁"), BotCommand("dmute", "🔇 删除并禁言"), BotCommand("dwarn", "⚠️ 删除并警告"),