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;
15use zeroclaw_runtime::i18n::get_required_cli_string;
16#[cfg(feature = "channel-notion")]
17use zeroclaw_runtime::i18n::get_required_cli_string_with_args;
18
19pub async fn handle_command(command: crate::ChannelCommands, config: &Config) -> Result<()> {
20    match command {
21        crate::ChannelCommands::Start => {
22            anyhow::bail!("Start must be handled in main.rs (requires async runtime)")
23        }
24        crate::ChannelCommands::Doctor => {
25            anyhow::bail!("Doctor must be handled in main.rs (requires async runtime)")
26        }
27        crate::ChannelCommands::List => {
28            println!("{}", get_required_cli_string("cli-channels-header"));
29            println!("{}", get_required_cli_string("cli-channels-cli-always"));
30            for entry in zeroclaw_channels::listing::compiled_channels(&config.channels) {
31                println!(
32                    "  {} {}",
33                    if entry.configured { "✅" } else { "❌" },
34                    entry.name
35                );
36            }
37            // Notion is a top-level config section, not part of ChannelsConfig
38            #[cfg(feature = "channel-notion")]
39            {
40                let notion_configured =
41                    config.notion.enabled && !config.notion.database_id.trim().is_empty();
42                println!(
43                    "{}",
44                    get_required_cli_string_with_args(
45                        "cli-channels-notion",
46                        &[("status", if notion_configured { "✅" } else { "❌" })],
47                    )
48                );
49            }
50            println!();
51            println!("{}", get_required_cli_string("cli-channels-start-hint"));
52            println!("{}", get_required_cli_string("cli-channels-doctor-hint"));
53            println!("{}", get_required_cli_string("cli-channels-configure-hint"));
54            Ok(())
55        }
56        crate::ChannelCommands::Add {
57            channel_type,
58            config: _,
59        } => {
60            anyhow::bail!(
61                "Channel type '{channel_type}' — use `zeroclaw config set channels.{channel_type}.<alias>.<field>=<value>` to configure"
62            );
63        }
64        crate::ChannelCommands::Remove { name } => {
65            anyhow::bail!("Remove channel '{name}' — edit ~/.zeroclaw/config.toml directly");
66        }
67        crate::ChannelCommands::BindTelegram { identity } => {
68            Box::pin(bind_telegram_identity(config, &identity)).await
69        }
70        crate::ChannelCommands::Send {
71            message,
72            channel_id,
73            recipient,
74        } => send_channel_message(config, &channel_id, &recipient, &message).await,
75    }
76}