Index
diapason.channels
¶
Channel abstraction for multi-platform messaging.
BaseChannel
¶
Bases: ABC
Base class for all channel implementations.
Subclasses must be registered via
@ChannelRegistry.register("name") to become discoverable.
__init_subclass__(**kwargs)
¶
Install the local-only guard on every channel subclass.
Both send and connect are wrapped. Guarding only send
would leave the standing gateways open: a Discord or Slack adapter
holds a websocket to a third party for as long as the daemon runs,
which is an outbound connection whether or not a message is ever sent.
send returns False rather than raising, so refusing a message
cannot bring down a long-running daemon loop.
connect()
abstractmethod
¶
Establish connection to the channel gateway.
disconnect()
abstractmethod
¶
Close connection to the channel gateway.
list_channels()
abstractmethod
¶
Return list of available channel names.
on_message(handler)
abstractmethod
¶
Register a callback for incoming messages.
send(channel, content, *, conversation_id='', metadata=None)
abstractmethod
¶
Send a message to a specific channel. Returns True on success.
Canonical send contract shared by every channel adapter:
channel
The DESTINATION identifier — the per-adapter native id of the
place the message goes (Discord/Slack channel id, Telegram chat
id, email recipient address, ...). This is not the channel
TYPE label. An incoming :class:ChannelMessage carries that
destination in its conversation_id field (channel there
is only the type label such as "discord"), so dispatch code
replying to a message must pass cm.conversation_id here.
conversation_id
An optional reply/thread reference — the native id of the
message being replied to (Discord message_reference, Slack
thread_ts, Telegram reply_to_message_id, email
In-Reply-To, ...). When replying to an inbound message this
should be cm.message_id, never the channel id. Passing a
channel id here yields broken references (e.g. Discord
MESSAGE_REFERENCE_UNKNOWN_MESSAGE).
status()
abstractmethod
¶
Return the current connection status.
ChannelMessage
dataclass
¶
A message received from or sent to a channel.
ChannelStatus
¶
Bases: str, Enum
Channel connection status.