1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Channels module - Communication channels (Telegram, Discord, etc.)
//!
//! This module provides the infrastructure for managing communication channels
//! in ZeptoClaw. Channels are responsible for receiving messages from users
//! and sending responses back.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ ChannelManager │
//! │ │
//! │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
//! │ │Telegram │ │ Discord │ │ Slack │ │WhatsApp │ ... │
//! │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
//! │ │ │ │ │ │
//! │ │ │ implements │ │ │
//! │ │ │ Channel │ │ │
//! │ │ │ trait │ │ │
//! │ └────────────┴─────┬──────┴────────────┘ │
//! │ │ │
//! │ ┌─────┴─────┐ │
//! │ │MessageBus │ │
//! │ │ (inbound/ │ │
//! │ │ outbound) │ │
//! │ └───────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Implementing a New Channel
//!
//! To implement a new channel, create a struct that implements the `Channel` trait:
//!
//! ```ignore
//! use async_trait::async_trait;
//! use zeptoclaw::channels::{Channel, BaseChannelConfig};
//! use zeptoclaw::bus::{MessageBus, OutboundMessage};
//! use zeptoclaw::error::Result;
//! use std::sync::Arc;
//!
//! pub struct MyChannel {
//! config: BaseChannelConfig,
//! running: bool,
//! bus: Arc<MessageBus>,
//! }
//!
//! impl MyChannel {
//! pub fn new(name: &str, bus: Arc<MessageBus>) -> Self {
//! Self {
//! config: BaseChannelConfig::new(name),
//! running: false,
//! bus,
//! }
//! }
//! }
//!
//! #[async_trait]
//! impl Channel for MyChannel {
//! fn name(&self) -> &str {
//! &self.config.name
//! }
//!
//! async fn start(&mut self) -> Result<()> {
//! self.running = true;
//! // Start listening for messages...
//! Ok(())
//! }
//!
//! async fn stop(&mut self) -> Result<()> {
//! self.running = false;
//! Ok(())
//! }
//!
//! async fn send(&self, msg: OutboundMessage) -> Result<()> {
//! // Send message via your channel's API...
//! Ok(())
//! }
//!
//! fn is_running(&self) -> bool {
//! self.running
//! }
//!
//! fn is_allowed(&self, user_id: &str) -> bool {
//! self.config.is_allowed(user_id)
//! }
//! }
//! ```
//!
//! # Usage
//!
//! ```
//! use std::sync::Arc;
//! use zeptoclaw::bus::MessageBus;
//! use zeptoclaw::config::Config;
//! use zeptoclaw::channels::ChannelManager;
//!
//! # tokio_test::block_on(async {
//! let bus = Arc::new(MessageBus::new());
//! let config = Config::default();
//! let manager = ChannelManager::new(bus, config);
//!
//! // Register channels
//! // manager.register(Box::new(telegram_channel)).await;
//! // manager.register(Box::new(discord_channel)).await;
//!
//! // Start all channels
//! // manager.start_all().await?;
//! # })
//! ```
pub use DiscordChannel;
pub use EmailChannel;
pub use register_configured_channels;
pub use LarkChannel;
pub use ChannelManager;
pub use MqttChannel;
pub use ChannelPluginAdapter;
pub use SerialChannel;
pub use SlackChannel;
pub use TelegramChannel;
pub use ;
pub use ;
pub use WhatsAppChannel;
pub use WhatsAppCloudChannel;