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
//! `nexo/admin/whatsapp/bot/*` handle.
//!
//! The dispatcher holds an `Arc<dyn WaBotHandle>` populated by the
//! WhatsApp channel plugin at boot. Two methods only:
//!
//! * `list_bots(agent_id)` — calls
//! `wa_agent::Session::list_bots()` against the paired session
//! for that agent.
//! * `send_to_bot(agent_id, jid, text)` — calls
//! `Session::send_text(jid, text)`. The bot reply path
//! (`MessageEvent::BotMessage`) is captured by a separate
//! subscriber that fans the chunks out as
//! `nexo/notify/whatsapp_bot_message` notifications.
//!
//! Both methods return `Err` when the agent is unknown or the
//! WhatsApp session isn't connected yet — callers surface that to
//! the operator UI.
use Arc;
use async_trait;
use BotInfo;
/// Result of a bot-channel call. Plain `anyhow::Result` so plugin
/// implementations don't have to design a bespoke error type.
pub type WaBotResult<T> = Result;
/// Per-channel hook into a paired WhatsApp session. Implemented by
/// `nexo-plugin-whatsapp` and registered with the dispatcher at
/// daemon boot.
/// Type-alias for the dispatcher field. `None` when the daemon is
/// running without a WhatsApp plugin (e.g. test harnesses,
/// non-channel demos).
pub type WaBotHandleArc = ;