feat: add telegram proxy fallbacks and mobile dialog polish

This commit is contained in:
ngfchl
2026-07-07 10:51:29 +08:00
parent 32187eb9a6
commit 41b0bdf0d7
5 changed files with 62 additions and 15 deletions
+3 -3
View File
@@ -199,7 +199,7 @@ async def api_send(request: Request):
if len(text) > 3500:
return JSONResponse({"ok": False, "error": "消息太长"}, status_code=400)
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=config.PROXY_URL))
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=getattr(config, "TG_PROXY_URL", config.PROXY_URL)))
msg = await bot.send_message(chat_id=config.TG_CHAT_ID, text=text)
rec = await Message.create(
msg_id=msg.message_id,
@@ -243,7 +243,7 @@ async def api_delete_message(message_id: int, request: Request):
if not rec.chat_id or not rec.msg_id:
return JSONResponse({"ok": False, "error": "缺少 TG chat_id/msg_id,无法删除 TG 消息"}, status_code=400)
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=config.PROXY_URL, connect_timeout=20.0, read_timeout=20.0))
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=getattr(config, "TG_PROXY_URL", config.PROXY_URL), connect_timeout=20.0, read_timeout=20.0))
tg_deleted = True
tg_error = None
try:
@@ -322,7 +322,7 @@ async def api_unban(user_id: int):
from telegram import Bot
from telegram.request import HTTPXRequest
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=config.PROXY_URL))
bot = Bot(token=config.TG_BOT_TOKEN, request=HTTPXRequest(proxy=getattr(config, "TG_PROXY_URL", config.PROXY_URL)))
await bot.unban_chat_member(chat_id=config.TG_CHAT_ID, user_id=user_id)
await Ban.filter(user_id=user_id).update(auto_unban=False, unban_at=now_tz().replace(tzinfo=None))
await Action.create(action="UNBAN", user_id=user_id, details={"method": "web"})