pub mod channel_setup;
pub mod helpers;
#[allow(unused_macros)]
macro_rules! channel_stub {
($name:ident, $descriptor:ident, $id:literal, $display:literal) => {
#[allow(dead_code)]
pub struct $name;
pub const $descriptor: crate::ChannelDescriptor = crate::ChannelDescriptor {
id: $id,
display_name: $display,
};
#[async_trait::async_trait]
impl crate::Channel for $name {
fn name(&self) -> &str {
$id
}
async fn send(&self, _message: &crate::SendMessage) -> anyhow::Result<()> {
anyhow::bail!("channel `{}` is not implemented yet", $id)
}
async fn listen(
&self,
_tx: tokio::sync::mpsc::Sender<crate::ChannelMessage>,
) -> anyhow::Result<()> {
anyhow::bail!("channel `{}` is not implemented yet", $id)
}
async fn health_check(&self) -> bool {
false
}
}
};
}
#[allow(unused_imports)]
pub(crate) use channel_stub;
macro_rules! channel_meta {
($descriptor:ident, $id:literal, $display:literal) => {
pub const $descriptor: crate::ChannelDescriptor = crate::ChannelDescriptor {
id: $id,
display_name: $display,
};
};
}
pub(crate) use channel_meta;
macro_rules! channel_catalog {
($( $module:ident => ($name:ident, $descriptor:ident) ),+ $(,)?) => {
$(mod $module;)+
$(#[allow(unused_imports)] pub use $module::$name;)+
$(use $module::$descriptor;)+
pub const CHANNEL_CATALOG: &[crate::ChannelDescriptor] = &[
$($descriptor,)+
];
};
}
channel_catalog!(
cli => (CliChannel, CLI_DESCRIPTOR),
telegram => (TelegramChannel, TELEGRAM_DESCRIPTOR),
discord => (DiscordChannel, DISCORD_DESCRIPTOR),
slack => (SlackChannel, SLACK_DESCRIPTOR),
mattermost => (MattermostChannel, MATTERMOST_DESCRIPTOR),
imessage => (ImessageChannel, IMESSAGE_DESCRIPTOR),
matrix => (MatrixChannel, MATRIX_DESCRIPTOR),
signal => (SignalChannel, SIGNAL_DESCRIPTOR),
whatsapp => (WhatsappChannel, WHATSAPP_DESCRIPTOR),
mqtt => (MqttChannel, MQTT_DESCRIPTOR),
transcription => (TranscriptionChannel, TRANSCRIPTION_DESCRIPTOR),
whatsapp_storage => (WhatsappStorageChannel, WHATSAPP_STORAGE_DESCRIPTOR),
whatsapp_web => (WhatsappWebChannel, WHATSAPP_WEB_DESCRIPTOR),
linq => (LinqChannel, LINQ_DESCRIPTOR),
wati => (WatiChannel, WATI_DESCRIPTOR),
nextcloud_talk => (NextcloudTalkChannel, NEXTCLOUD_TALK_DESCRIPTOR),
email => (EmailChannel, EMAIL_DESCRIPTOR),
irc => (IrcChannel, IRC_DESCRIPTOR),
lark => (LarkChannel, LARK_DESCRIPTOR),
feishu => (FeishuChannel, FEISHU_DESCRIPTOR),
dingtalk => (DingtalkChannel, DINGTALK_DESCRIPTOR),
qq_official => (QqOfficialChannel, QQ_OFFICIAL_DESCRIPTOR),
nostr => (NostrChannel, NOSTR_DESCRIPTOR),
clawdtalk => (ClawdtalkChannel, CLAWDTALK_DESCRIPTOR),
webhook => (WebhookChannel, WEBHOOK_DESCRIPTOR),
napcat => (NapcatChannel, NAPCAT_DESCRIPTOR),
acp => (AcpChannel, ACP_DESCRIPTOR),
);