mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-21 07:55:08 +00:00
refactor(gateway): migrate telegram adapter (+ telegram_network) to bundled plugin
WIP toward #41112 — the last and largest gateway channel. Telegram adapter + telegram_network satellite relocated to plugins/platforms/telegram/ with the network import rewritten to the new package path. register() exposes the platform with standalone_sender_fn (delegates to the retained _send_telegram REST sender), apply_yaml_config_fn (full telegram: YAML→env + extra bridge), setup_fn (delegates to the managed-bot QR wizard via lazy import), and a _build_adapter that applies the notification-mode resolution that used to live in gateway/run.py's factory branch. Core touchpoints stripped: run.py factory branch (was the leading if), config.py 90-line telegram_cfg bridge, gateway.py static dict + setup-map entry. send_message_tool keeps _send_telegram (the plugin delegates to it) with its TelegramAdapter imports repointed to the plugin path. Generic Platform.TELEGRAM references in core (auth maps, bridged config-loop special-cases, source-platform behavior checks) intentionally remain — same 'left generic in core' policy as the merged migrations.
This commit is contained in:
parent
552adbe082
commit
736ffb3bc1
8 changed files with 250 additions and 161 deletions
|
|
@ -593,7 +593,7 @@ async def _send_to_platform(platform, pconfig, chat_id, message, thread_id=None,
|
|||
|
||||
# Telegram adapter import is optional (requires python-telegram-bot)
|
||||
try:
|
||||
from gateway.platforms.telegram import TelegramAdapter
|
||||
from plugins.platforms.telegram.adapter import TelegramAdapter
|
||||
_telegram_available = True
|
||||
except ImportError:
|
||||
_telegram_available = False
|
||||
|
|
@ -857,7 +857,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No
|
|||
else:
|
||||
# Reuse the gateway adapter's format_message for markdown→MarkdownV2
|
||||
try:
|
||||
from gateway.platforms.telegram import TelegramAdapter
|
||||
from plugins.platforms.telegram.adapter import TelegramAdapter
|
||||
_adapter = TelegramAdapter.__new__(TelegramAdapter)
|
||||
formatted = _adapter.format_message(message)
|
||||
except Exception:
|
||||
|
|
@ -902,7 +902,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No
|
|||
# send to a forum group's General topic always errors out
|
||||
# (see issue #22267).
|
||||
try:
|
||||
from gateway.platforms.telegram import TelegramAdapter
|
||||
from plugins.platforms.telegram.adapter import TelegramAdapter
|
||||
effective_thread_id = TelegramAdapter._message_thread_id_for_send(
|
||||
str(thread_id)
|
||||
)
|
||||
|
|
@ -954,7 +954,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No
|
|||
)
|
||||
if not _has_html:
|
||||
try:
|
||||
from gateway.platforms.telegram import _strip_mdv2
|
||||
from plugins.platforms.telegram.adapter import _strip_mdv2
|
||||
plain = _strip_mdv2(formatted)
|
||||
except Exception:
|
||||
plain = message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue