feat(cron): support Discord thread_id in deliver targets
Add Discord thread support to cron delivery and send_message_tool.
- _parse_target_ref: handle discord platform with chat_id:thread_id format
- _send_discord: add thread_id param, route to /channels/{thread_id}/messages
- _send_to_platform: pass thread_id through for Discord
- Discord adapter send(): read thread_id from metadata for gateway path
- Update tool schema description to document Discord thread targets
Cherry-picked from PR #7046 by pandacooming (maxyangcn).
Follow-up fixes:
- Restore proxy support (resolve_proxy_url/proxy_kwargs_for_aiohttp) that was
accidentally deleted — would have caused NameError at runtime
- Remove duplicate _DISCORD_TARGET_RE regex; reuse existing _TELEGRAM_TOPIC_TARGET_RE
via _NUMERIC_TOPIC_RE alias (identical pattern)
- Fix misleading test comments about Discord negative snowflake IDs
(Discord uses positive snowflakes; negative IDs are a Telegram convention)
- Rewrite misleading scheduler test that claimed to exercise home channel
fallback but actually tested the explicit platform:chat_id parsing path
This commit is contained in:
@@ -173,6 +173,40 @@ class TestResolveDeliveryTarget:
|
||||
"thread_id": None,
|
||||
}
|
||||
|
||||
def test_explicit_discord_topic_target_with_thread_id(self):
|
||||
"""deliver: 'discord:chat_id:thread_id' parses correctly."""
|
||||
job = {
|
||||
"deliver": "discord:-1001234567890:17585",
|
||||
}
|
||||
assert _resolve_delivery_target(job) == {
|
||||
"platform": "discord",
|
||||
"chat_id": "-1001234567890",
|
||||
"thread_id": "17585",
|
||||
}
|
||||
|
||||
def test_explicit_discord_chat_id_without_thread_id(self):
|
||||
"""deliver: 'discord:chat_id' sets thread_id to None."""
|
||||
job = {
|
||||
"deliver": "discord:9876543210",
|
||||
}
|
||||
assert _resolve_delivery_target(job) == {
|
||||
"platform": "discord",
|
||||
"chat_id": "9876543210",
|
||||
"thread_id": None,
|
||||
}
|
||||
|
||||
def test_explicit_discord_channel_without_thread(self):
|
||||
"""deliver: 'discord:1001234567890' resolves via explicit platform:chat_id path."""
|
||||
job = {
|
||||
"deliver": "discord:1001234567890",
|
||||
}
|
||||
result = _resolve_delivery_target(job)
|
||||
assert result == {
|
||||
"platform": "discord",
|
||||
"chat_id": "1001234567890",
|
||||
"thread_id": None,
|
||||
}
|
||||
|
||||
|
||||
class TestDeliverResultWrapping:
|
||||
"""Verify that cron deliveries are wrapped with header/footer and no longer mirrored."""
|
||||
|
||||
Reference in New Issue
Block a user