Skip to main content

zeroclaw/channels/
mod.rs

1pub use zeroclaw_channels::orchestrator::*;
2#[cfg(feature = "channel-matrix")]
3pub mod matrix;
4#[cfg(feature = "channel-telegram")]
5pub mod telegram;
6pub mod session_backend {
7    pub use zeroclaw_infra::session_backend::*;
8}
9pub mod session_sqlite {
10    pub use zeroclaw_infra::session_sqlite::*;
11}
12
13use crate::config::Config;
14use anyhow::Result;
15
16pub async fn handle_command(command: crate::ChannelCommands, config: &Config) -> Result<()> {
17    match command {
18        crate::ChannelCommands::Start => {
19            anyhow::bail!("Start must be handled in main.rs (requires async runtime)")
20        }
21        crate::ChannelCommands::Doctor => {
22            anyhow::bail!("Doctor must be handled in main.rs (requires async runtime)")
23        }
24        crate::ChannelCommands::List => {
25            println!("Channels:");
26            println!("  ✅ CLI (always available)");
27            for entry in zeroclaw_channels::listing::compiled_channels(&config.channels) {
28                println!(
29                    "  {} {}",
30                    if entry.configured { "✅" } else { "❌" },
31                    entry.name
32                );
33            }
34            // Notion is a top-level config section, not part of ChannelsConfig
35            #[cfg(feature = "channel-notion")]
36            {
37                let notion_configured =
38                    config.notion.enabled && !config.notion.database_id.trim().is_empty();
39                println!("  {} Notion", if notion_configured { "✅" } else { "❌" });
40            }
41            println!("\nTo start channels: zeroclaw channel start");
42            println!("To check health:    zeroclaw channel doctor");
43            println!("To configure:      zeroclaw onboard");
44            Ok(())
45        }
46        crate::ChannelCommands::Add {
47            channel_type,
48            config: _,
49        } => {
50            anyhow::bail!(
51                "Channel type '{channel_type}' — use `zeroclaw onboard` to configure channels"
52            );
53        }
54        crate::ChannelCommands::Remove { name } => {
55            anyhow::bail!("Remove channel '{name}' — edit ~/.zeroclaw/config.toml directly");
56        }
57        crate::ChannelCommands::BindTelegram { identity } => {
58            Box::pin(bind_telegram_identity(config, &identity)).await
59        }
60        crate::ChannelCommands::Send {
61            message,
62            channel_id,
63            recipient,
64        } => send_channel_message(config, &channel_id, &recipient, &message).await,
65    }
66}