|
29 | 29 | from src.features.cmd_perm.metadata_text import SCENE_GROUP, SCENE_PRIVATE, join_usage, usage_line |
30 | 30 | from src.foundation.config import BotConfig, GroupConfig, UserConfig, get_bot_admins, user_is_bot_admin |
31 | 31 | from src.foundation.paths import plugin_data_dir |
| 32 | +from src.plugins.request_handler.approval_reply_text import ( |
| 33 | + classify_approval_reply_text, |
| 34 | + extract_approval_reply_text_from_body, |
| 35 | +) |
32 | 36 | from src.plugins.request_handler.config import Config |
33 | 37 | from src.plugins.request_handler.texts import ( |
34 | 38 | APPROVE_ALL_FRIENDS_COMMAND, |
@@ -540,18 +544,6 @@ def clear_quick_approve_state(bot_key: str, kind: str, target_id: str) -> None: |
540 | 544 | if _approval_notice_dirty: |
541 | 545 | save_json(APPROVAL_NOTICE_FILE, approval_notice_map) |
542 | 546 |
|
543 | | -# 引用审批通知时允许的正文(小写比较);空字符串表示仅引用不打字(视为同意) |
544 | | -_APPROVE_REPLY_TEXT = frozenset({"", "同意", "好", "yes", "y", "ok"}) |
545 | | -_REJECT_REPLY_TEXT = frozenset({"拒绝", "不要", "否", "no", "n"}) |
546 | | - |
547 | | - |
548 | | -def classify_approval_reply_text(text: str) -> str | None: |
549 | | - if text in _APPROVE_REPLY_TEXT: |
550 | | - return "approve" |
551 | | - if text in _REJECT_REPLY_TEXT: |
552 | | - return "reject" |
553 | | - return None |
554 | | - |
555 | 547 |
|
556 | 548 | def rows_from_doubt_friends_api(result: object) -> list[dict]: |
557 | 549 | if isinstance(result, list): |
@@ -898,7 +890,10 @@ async def handle_approval_reply(bot: Bot, event: PrivateMessageEvent): |
898 | 890 | meta = approval_notice_map.get(bot_key, {}).get(mid) |
899 | 891 | if not meta: |
900 | 892 | return |
901 | | - text = event.get_plaintext().strip().lower() |
| 893 | + quoted_body = None |
| 894 | + if event.reply and event.reply.message is not None: |
| 895 | + quoted_body = event.reply.message.extract_plain_text() |
| 896 | + text = extract_approval_reply_text_from_body(event.get_plaintext() or "", quoted_body) |
902 | 897 | action = classify_approval_reply_text(text) |
903 | 898 | if action is None: |
904 | 899 | await approval_reply_cmd.finish("引用审批消息后,正文须为:同意 / 好 / 留空,或 拒绝 / 不要 / 否。") |
|
0 commit comments