Skip to main content

botkit_matrix/
lib.rs

1//! Matrix implementation for botkit
2//!
3//! This crate provides Matrix platform support for the botkit unified bot framework.
4//! It uses the `matrix-sdk` crate for protocol handling, including E2E encryption.
5//!
6//! # Example
7//! ```ignore
8//! use botkit_matrix::{MatrixBot, MatrixConfig};
9//! use botkit_core::extractor::User;
10//!
11//! async fn ping() -> &'static str { "Pong!" }
12//! async fn greet(user: User) -> String { format!("Hello, {}!", user.name) }
13//!
14//! let config = MatrixConfig::new("https://matrix.org")
15//!     .password_auth("@bot:matrix.org", "password")
16//!     .command_prefix("!");
17//!
18//! MatrixBot::new(config)
19//!     .command("ping", ping)
20//!     .command("greet", greet)
21//!     .reaction("👍", on_thumbsup)
22//!     .run()
23//!     .await
24//!     .unwrap();
25//! ```
26
27#[cfg(target_arch = "wasm32")]
28use getrandom as _;
29
30pub mod action;
31mod bot;
32mod client;
33mod config;
34mod event;
35
36pub use bot::MatrixBot;
37pub use client::MatrixClient;
38pub use config::{MatrixAuth, MatrixConfig};
39pub use event::MatrixContextData;
40
41// Re-export commonly used matrix-sdk types for convenience
42pub use matrix_sdk::ruma::{OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedUserId};
43pub use matrix_sdk::{Room, RoomState};