feat: interactive inline buttons, SMTP reply, AI reply suggestions
- Inline keyboard: view original / back to summary toggle per message - SMTP config per account for sending replies - Reply button: click, type message, auto-send via SMTP - AI Reply button: generates 3 suggestions via DeepSeek - Simple replies (OK, Got it) send immediately on tap - Substantive replies require confirm before send - Hides AI Reply button when AI determines reply unnecessary - Telegram long polling integrated into main loop for real-time interaction
This commit is contained in:
@@ -2,20 +2,20 @@ import logging
|
||||
from src.config import Config
|
||||
from src.email_client import fetch_unseen_emails, mark_as_seen
|
||||
from src.ai_client import summarize_email
|
||||
from src.tg_bot import send_message, format_summary
|
||||
from src.tg_bot import send_summary, format_summary
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def process_all(cfg: Config):
|
||||
for acct in cfg.email_accounts:
|
||||
for idx, acct in enumerate(cfg.email_accounts):
|
||||
try:
|
||||
_process_account(cfg, acct)
|
||||
_process_account(cfg, acct, idx)
|
||||
except Exception as e:
|
||||
logger.error(f"处理邮箱 {acct.username} 时出错: {e}", exc_info=True)
|
||||
|
||||
|
||||
def _process_account(cfg: Config, acct):
|
||||
def _process_account(cfg: Config, acct, acct_idx: int):
|
||||
logger.info(f"检查邮箱: {acct.username}")
|
||||
emails = fetch_unseen_emails(acct)
|
||||
|
||||
@@ -32,7 +32,7 @@ def _process_account(cfg: Config, acct):
|
||||
summary = summarize_email(cfg.ai, acct.username, mail.subject, mail.sender, mail.body)
|
||||
summary["recipient"] = acct.username
|
||||
text = format_summary(summary)
|
||||
send_message(cfg.telegram, text)
|
||||
send_summary(cfg.telegram, cfg.telegram.chat_id, text, summary, mail.body, acct_idx)
|
||||
seen_uids.append(mail.uid)
|
||||
logger.info(f" 已发送到 Telegram")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user