Crates.io | oxidebot |
lib.rs | oxidebot |
version | 0.1.5 |
source | src |
created_at | 2024-08-16 07:30:54.372736 |
updated_at | 2024-09-10 03:08:25.980144 |
description | A lightweight yet powerful chatbot framework |
homepage | https://github.com/canxin121/oxidebot |
repository | https://github.com/canxin121/oxidebot |
max_upload_size | |
id | 1340021 |
size | 72,135 |
Oxidebot is a lightweight yet powerful chatbot framework based on Rust and the Tokio runtime. It aims to provide developers with a flexible and extensible environment for bot development through modular design.
Bot
is the core component of the framework, responsible for providing Event
s and offering basic API methods for developers to call. It serves as the bridge between the framework and external platforms (such as QQ, Telegram, etc.).
Event
is the object that the framework processes, representing the various events received by the bot. Event types include:
Matcher
is an abstraction over Bot
and Event
, simplifying event handling and API calls. It provides convenient methods to extract key information from events (such as users, messages, groups) and easily call related APIs.
Handler
is the core component for event processing, divided into two types:
Event
s and is triggered only when an event occurs.A Handler
can include either an EventHandler
or an ActiveHandler
, or both.
Filter
is a global event filter used to process and intercept events before they reach the Handler
. The Filter
has a higher priority than the Handler
.
OxideBotManager
is the manager of the framework, the entry point for starting and running the bot. Developers should call its run_block
method at the end of the main
function to launch the entire framework along with all registered Bot
s, Filter
s, and Handler
s.
Include a restricted BroadcastSender
that can only use subscribe
fn in your handler
pub struct WaitHandler {
pub broadcast_sender: BroadcastSender,
}
And then use wait
in you HandlerTrait
impl.
You can find all the wait
method in utils::wait
or define a new one youself.
let (number, matcher) = wait_user_text_generic::<u8>(
&matcher,
&self.broadcast_sender,
Duration::from_secs(30),
3,
Some("Please send a unsigned int8".to_string()),
)
.await?;
MIT OR Apache-2.0