处理用户输入 Args: text: 用户输入文本 Returns: 处理结果
(self, text: str)
| 2442 | except Exception as e: |
| 2443 | return {"success": False, "message": str(e)} |
| 2444 | |
| 2445 | def handle_unknown(self, text: str) -> Dict[str, Any]: |
| 2446 | """处理未知意图""" |
| 2447 | msg = f"抱歉,我还不太理解你的意思。\n\n我可以帮你:\n• 每日推送:说'推送'\n• 反馈选择:回复数字如'1 2 3'\n• 精读报告:说'精读'\n• 清空精读列表:说'清空精读列表'\n• 查看周报:说'周报'\n• 管理必读:说'加个必读作者'\n\n当前输入:{text[:50]}" |
| 2448 | send_message(msg, chat_id=self.chat_id, user_id=self.feishu_user_id) |
| 2449 | return {"success": False, "message": "Unknown intent"} |
| 2450 | |
| 2451 | def process(self, text: str) -> Dict[str, Any]: |
| 2452 | """ |
| 2453 | 处理用户输入 |
| 2454 | |
| 2455 | Args: |
| 2456 | text: 用户输入文本 |
| 2457 | |
| 2458 | Returns: |
| 2459 | 处理结果 |
| 2460 | """ |
| 2461 | text_clean = safe_console_text(text, 100) |
| 2462 | print(f"\n{'='*60}") |
| 2463 | print(f"Processing: {text_clean}") |
| 2464 | print(f"{'='*60}") |
| 2465 | |
| 2466 | # 检测意图 |
| 2467 | intent = self.detect_intent(text) |
| 2468 | print(f"Detected intent: {intent['intent']} (confidence: {intent['confidence']:.2f})") |
| 2469 | |
| 2470 | # 路由到对应处理器 |
| 2471 | handlers = { |
| 2472 | "ignore": lambda: {"success": True, "ignored": True}, |
| 2473 | "confirm_direction": lambda: self.handle_confirm_direction(intent["slots"].get("topic", text)), |
| 2474 | "cold_start": lambda: self.handle_cold_start(text), |
| 2475 | "daily_push": self.handle_daily_push, |
| 2476 | "feedback": lambda: self.handle_feedback(intent["slots"].get("reply", text)), |
| 2477 | "expand_push": lambda: self.handle_expand_push( |
| 2478 | category=intent["slots"].get("category", ""), |
| 2479 | query=intent["slots"].get("query", ""), |
| 2480 | ), |
| 2481 | "classification_correction": lambda: self.handle_classification_correction( |
| 2482 | int(intent["slots"].get("paper_number", 0)), |
| 2483 | intent["slots"].get("target_category", ""), |
| 2484 | ), |
| 2485 | "report_feedback": lambda: self.handle_report_feedback(intent["slots"].get("sentiment", "")), |
| 2486 | "reviewer_watch": lambda: self.handle_reviewer_watch( |
| 2487 | intent["slots"].get("conference", ""), |
| 2488 | int(intent["slots"].get("year", datetime.now().year)), |
| 2489 | text, |
| 2490 | ), |
| 2491 | "reading_report": lambda: self.handle_reading_report( |
| 2492 | paper_ids=intent["slots"].get("paper_ids"), |
| 2493 | pdf_url=intent["slots"].get("pdf_url"), |
| 2494 | title_hint=intent["slots"].get("title_hint", ""), |
| 2495 | ), |
| 2496 | "clear_reading_list": self.handle_clear_reading_list, |
| 2497 | "weekly_report": self.handle_weekly_report, |
| 2498 | "must_read": lambda: self.handle_must_read(intent["slots"].get("command", text)), |
| 2499 | "show_profile": self.handle_show_profile, |
| 2500 | "profile_update": lambda: self.handle_profile_update(text, intent["slots"]), |
| 2501 | "role_manager": lambda: self.handle_role_manager(intent["slots"].get("command", text)), |
no test coverage detected