zeroclaw_plugins/
wasm_channel.rs1use async_trait::async_trait;
9use zeroclaw_api::channel::{Channel, ChannelMessage, SendMessage};
10
11pub struct WasmChannel {
13 name: String,
14 plugin_name: String,
15}
16
17impl WasmChannel {
18 pub fn new(name: String, plugin_name: String) -> Self {
19 Self { name, plugin_name }
20 }
21}
22
23impl ::zeroclaw_api::attribution::Attributable for WasmChannel {
24 fn role(&self) -> ::zeroclaw_api::attribution::Role {
25 ::zeroclaw_api::attribution::Role::Channel(
26 ::zeroclaw_api::attribution::ChannelKind::Webhook,
27 )
28 }
29 fn alias(&self) -> &str {
30 &self.name
31 }
32}
33
34#[async_trait]
35impl Channel for WasmChannel {
36 fn name(&self) -> &str {
37 &self.name
38 }
39
40 async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {
41 ::zeroclaw_log::record!(
43 WARN,
44 ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)
45 .with_outcome(::zeroclaw_log::EventOutcome::Unknown),
46 &format!(
47 "WasmChannel '{}' (plugin: {}) send not yet connected: {}",
48 self.name, self.plugin_name, message.content
49 )
50 );
51 Ok(())
52 }
53
54 async fn listen(&self, _tx: tokio::sync::mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {
55 ::zeroclaw_log::record!(
57 WARN,
58 ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)
59 .with_outcome(::zeroclaw_log::EventOutcome::Unknown),
60 &format!(
61 "WasmChannel '{}' (plugin: {}) listen not yet connected",
62 self.name, self.plugin_name
63 )
64 );
65 Ok(())
66 }
67}