mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-12 12:45:55 +00:00
fix(msteams): remove hardcoded quote test fallback
This commit is contained in:
parent
f73b5e26a2
commit
8e042aea0d
@ -358,17 +358,19 @@ class MSTeamsChannel(BaseChannel):
|
|||||||
if quoted and reply:
|
if quoted and reply:
|
||||||
return self._format_reply_with_quote(quoted, reply)
|
return self._format_reply_with_quote(quoted, reply)
|
||||||
|
|
||||||
# Observed compact fallback where the relay flattens everything into one line
|
# Observed compact fallback where the relay flattens quote and reply into
|
||||||
# and appends the literal reply text marker at the end.
|
# a single line after the synthetic FWDIOC-BOT prefix.
|
||||||
compact = re.sub(r"\s+", " ", normalized_newlines).strip()
|
compact = re.sub(r"\s+", " ", normalized_newlines).strip()
|
||||||
if compact.startswith("FWDIOC-BOT "):
|
if compact.startswith("FWDIOC-BOT "):
|
||||||
compact = compact[len("FWDIOC-BOT ") :].strip()
|
compact = compact[len("FWDIOC-BOT ") :].strip()
|
||||||
|
for boundary in (". ", "! ", "? ", "… "):
|
||||||
marker = " Reply with quote test"
|
idx = compact.rfind(boundary)
|
||||||
if compact.endswith(marker):
|
if idx == -1:
|
||||||
quoted = compact[: -len(marker)].strip()
|
continue
|
||||||
reply = marker.strip()
|
quoted = compact[: idx + 1].strip()
|
||||||
return self._format_reply_with_quote(quoted, reply)
|
reply = compact[idx + len(boundary) :].strip()
|
||||||
|
if quoted and reply and len(reply) <= 160:
|
||||||
|
return self._format_reply_with_quote(quoted, reply)
|
||||||
|
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
|
|||||||
@ -264,6 +264,14 @@ def test_sanitize_inbound_text_structures_live_fwdioc_quote_shape(make_channel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_normalize_teams_reply_quote_leaves_plain_text_test_phrase_untouched(make_channel):
|
||||||
|
ch = make_channel()
|
||||||
|
|
||||||
|
text = "Normal message ending with Reply with quote test"
|
||||||
|
|
||||||
|
assert ch._normalize_teams_reply_quote(text) == text
|
||||||
|
|
||||||
|
|
||||||
def test_sanitize_inbound_text_structures_multiline_fwdioc_quote_shape(make_channel):
|
def test_sanitize_inbound_text_structures_multiline_fwdioc_quote_shape(make_channel):
|
||||||
ch = make_channel()
|
ch = make_channel()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user