refactor: replace all in-memory state with SQLite database
This commit is contained in:
@@ -58,14 +58,14 @@ def tg_send_and_mark(cfg: Config, info: dict):
|
||||
if thinking_msg_id:
|
||||
# 编辑思考中消息为实际摘要
|
||||
from src.tg_bot import _summary_keyboard
|
||||
from src.database import save_email_context
|
||||
can_reply = info["data"].get("can_reply", True)
|
||||
is_promotion = info["data"].get("category") == "promotion"
|
||||
links = info["data"].get("links", [])
|
||||
edit_message(cfg.telegram, cfg.telegram.chat_id, thinking_msg_id,
|
||||
info["text"], _summary_keyboard(can_reply, is_promotion, links))
|
||||
# 保存上下文用于回调
|
||||
from src.tg_bot import _email_contexts
|
||||
_email_contexts[thinking_msg_id] = {
|
||||
save_email_context(thinking_msg_id, {
|
||||
"summary_text": info["text"],
|
||||
"summary_data": info["data"],
|
||||
"original_body": info["original_body"],
|
||||
@@ -77,7 +77,7 @@ def tg_send_and_mark(cfg: Config, info: dict):
|
||||
"sender": info["data"].get("sender", ""),
|
||||
"subject": info["data"].get("subject", ""),
|
||||
"can_reply": can_reply,
|
||||
}
|
||||
})
|
||||
else:
|
||||
# 兜底:没有思考中消息就正常发送
|
||||
send_summary(cfg.telegram, cfg.telegram.chat_id,
|
||||
|
||||
Reference in New Issue
Block a user