fix: ignore non-query Feishu messages

This commit is contained in:
ar51 committed 2026-08-08 18:09:05 +08:00
1 parent 0aaedb8b66
commit d97b788e0e
7 files changed
+187 -19

No files matched your search

+22 -1
View File
@@ -154,6 +154,18 @@ def parse_request(text: str) -> RequestInput:
return RequestInput(model=model, quantity=quantity)
def parse_trigger_request(text: str) -> RequestInput | None:
"""Return a query only when one complete model and one quantity are present.
Feishu group messages that do not satisfy the complete AM516 input contract
are unrelated traffic from the bridge's point of view and must stay silent.
"""
try:
return parse_request(text)
except InputError:
return None
def build_model(fields: dict[str, str]) -> str:
closing_bracket = "]" if fields["bracket"] == "[" else ")"
return (
@@ -818,8 +830,17 @@ def handle_message(client: lark.Client, data: lark.im.v1.P2ImMessageReceiveV1) -
message_id = data.event.message.message_id
if not text or not message_id:
return
request = parse_trigger_request(text)
if request is None:
logging.info(
"Feishu message ignored: no complete AM516 model-and-quantity request; message_id=%s",
message_id,
)
return
try:
report = build_report(parse_request(text))
report = build_report(request)
except InputError as exc:
report = f"AM516 内部候选查询已停止:{exc}\n\n{DISCLAIMER}"
except RuntimeError as exc:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.