Include Luna AI Assistant design docs covering channels, configuration, core architecture, memory, scheduler, and skills. Add reference docs from OpenClaw and ZeroClaw projects, plus Mistral and OpenAI API specs.
1.8 KiB
Telegram Channel
The Telegram integration consists of two classes: TelegramChannel (the IChannel implementation) and TelegramAdapter (the hosted service that manages channel lifecycles). Both live in the Luna.Channels.Telegram namespace.
TelegramChannel
Handles interaction with the Telegram Bot API, implementing the IChannel interface defined in Channels.
Message Splitting
Telegram enforces a 4096-character limit per message. TelegramChannel automatically splits long responses into sequential chunks that respect this limit.
Streaming
Rather than forwarding every ChatStreamUpdate individually (which would hit Telegram's rate limits), the channel accumulates streaming updates and sends them in periodic batches.
Typing Indicators
Uses KeepTypingAsync to maintain a "typing..." indicator in the Telegram chat while the AI generates a response. This runs as a background loop until the response completes.
User Filtering
RaiseMessageReceived filters incoming updates by AllowedUserIds (configured via TelegramOptions in Configuration). Messages from unauthorized users or with empty content are silently dropped.
TelegramAdapter
An IHostedService and IUpdateHandler that polls Telegram for updates using long polling.
Lifecycle
- On startup, begins polling the Telegram Bot API.
- For each incoming update, identifies the chat ID.
- Creates a new
TelegramChannelinstance for each unique chat (if one doesn't already exist). - Registers the channel with
IChannelManagerfrom Channels. - Routes the update to the appropriate
TelegramChannel.
Configuration
Configured via TelegramOptions (see Configuration), which includes:
BotToken— Telegram Bot API token.AllowedUserIds— Whitelist of Telegram user IDs permitted to interact with Luna.
Namespace
Luna.Channels.Telegram