style: simplify media accumulation - silent accumulate, immediate send on text
This commit is contained in:
@@ -477,25 +477,23 @@ def _handle_message(tg_cfg: TelegramConfig, cfg: Config, msg: dict):
|
||||
logger.info(" 上下文已丢失,清理")
|
||||
return
|
||||
|
||||
# 有附件但没文字:累积附件,等用户输入文字
|
||||
# 有附件但没文字:静默累积附件,等用户输入文字
|
||||
if media and not text:
|
||||
pending = conv.get("pending_attachments", [])
|
||||
for att in media:
|
||||
pending.append(att)
|
||||
pending.extend(media)
|
||||
conv["pending_attachments"] = pending
|
||||
save_conversation(chat_id, conv)
|
||||
delete_message(tg_cfg, chat_id_str, user_msg_id)
|
||||
count = len(pending)
|
||||
send_text(tg_cfg, chat_id_str,
|
||||
f"📎 已添加 {len(pending)} 个附件,请输入回复内容发送",
|
||||
reply_markup=_cancel_keyboard())
|
||||
f"📎 已收到 {count} 个附件{',请输入回复文字' if count == 1 else ',请继续或输入回复文字'}")
|
||||
return
|
||||
|
||||
# 有文字(可能也有附件):发送邮件
|
||||
# 有文字(可能也有附件):合并所有附件,一起发送
|
||||
delete_message(tg_cfg, chat_id_str, user_msg_id)
|
||||
if prompt_msg_id:
|
||||
delete_message(tg_cfg, chat_id_str, prompt_msg_id)
|
||||
|
||||
# 合并累积的附件
|
||||
all_attachments = conv.get("pending_attachments", [])
|
||||
all_attachments.extend(media)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user