feat: show thinking indicator during AI processing, accept non-numeric verification codes
This commit is contained in:
@@ -57,6 +57,25 @@ def send_text(tg_cfg: TelegramConfig, chat_id: str, text: str,
|
||||
return result["result"]["message_id"]
|
||||
|
||||
|
||||
def send_thinking(tg_cfg: TelegramConfig, chat_id: str) -> int:
|
||||
result = _tg_req(tg_cfg, "sendMessage", {
|
||||
"chat_id": chat_id,
|
||||
"text": "💭 思考中...",
|
||||
})
|
||||
return result["result"]["message_id"]
|
||||
|
||||
|
||||
def edit_message(tg_cfg: TelegramConfig, chat_id: str, msg_id: int,
|
||||
text: str, reply_markup: dict = None):
|
||||
payload = {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
"text": text, "parse_mode": "MarkdownV2",
|
||||
}
|
||||
if reply_markup:
|
||||
payload["reply_markup"] = reply_markup
|
||||
_tg_req(tg_cfg, "editMessageText", payload)
|
||||
|
||||
|
||||
def delete_message(tg_cfg: TelegramConfig, chat_id: str, msg_id: int):
|
||||
try:
|
||||
_tg_req(tg_cfg, "deleteMessage", {
|
||||
@@ -325,6 +344,11 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
||||
if not conv or conv.get("summary_msg_id") != msg_id:
|
||||
return
|
||||
logger.info(" 换一批 (已有 %d 条历史)", len(conv.get("all_suggestions", [])))
|
||||
# 先显示思考中
|
||||
_tg_req(tg_cfg, "editMessageText", {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
"text": "💭 思考中...", "parse_mode": None,
|
||||
})
|
||||
try:
|
||||
new_suggestions = generate_more_replies(
|
||||
cfg.ai, ctx["sender"], ctx["subject"], ctx["original_body"],
|
||||
@@ -365,6 +389,11 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
||||
logger.info(" 取消, 删除提示消息")
|
||||
|
||||
elif action == CALLBACK_PROMO_DETAIL and ctx:
|
||||
# 先显示思考中
|
||||
_tg_req(tg_cfg, "editMessageText", {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
"text": "💭 思考中...", "parse_mode": None,
|
||||
})
|
||||
try:
|
||||
details = expand_promo_detail(
|
||||
cfg.ai, ctx["sender"], ctx["subject"], ctx["original_body"],
|
||||
|
||||
Reference in New Issue
Block a user