Expand description
§BotRS - Rust QQ Bot Framework
BotRS is a Rust implementation of the QQ Guild Bot API framework, inspired by the Python botpy library. It provides an easy-to-use, efficient, and type-safe way to create QQ Guild bots.
§Features
- Async/await support with Tokio
- WebSocket connection management
- HTTP API client
- Event-driven architecture
- Type-safe message handling
- Intent-based event filtering
§Quick Start
use botrs::{Client, Token, Intents, EventHandler};
struct MyHandler;
#[async_trait::async_trait]
impl EventHandler for MyHandler {}
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = Token::new("your_app_id", "your_secret");
let intents = Intents::default();
let handler = MyHandler;
let mut client = Client::new(token, intents, handler, false)?;
client.start().await?;
Ok(())
}Re-exports§
pub use api::BotApi;pub use audio::Audio;pub use audio::AudioControl;pub use audio::AudioStatus;pub use audio::PublicAudio;pub use audio::PublicAudioType;pub use client::Client;pub use client::Context;pub use client::EventHandler;pub use connection::ConnectionSession;pub use connection::ConnectionState;pub use connection::Session;pub use error::BotError;pub use error::Result;pub use forum::Content;pub use forum::Format;pub use forum::OpenThread;pub use forum::Thread;pub use forum::ThreadInfo;pub use forum::Title;pub use intents::Intents;pub use interaction::Interaction;pub use interaction::InteractionData;pub use interaction::InteractionDataType;pub use interaction::InteractionType;pub use manage::C2CManageEvent;pub use manage::GroupManageEvent;pub use manage::ManageEventType;pub use models::gateway::Ready;pub use reaction::Reaction;pub use reaction::ReactionTarget;pub use reaction::ReactionTargetType;pub use reaction::ReactionUsers;pub use token::Token;pub use models::*;
Modules§
- api
- Bot API implementation for the QQ Guild Bot API.
- audio
- Audio-related functionality for QQ Bot
- client
- Main client implementation for the QQ Guild Bot API.
- connection
- Connection state management for QQ Bot
- error
- Error types for the BotRS library.
- forum
- Forum-related functionality for QQ Bot
- gateway
- WebSocket gateway implementation for the QQ Guild Bot API.
- http
- HTTP client implementation for the QQ Guild Bot API.
- intents
- Intent flags for controlling which events the bot receives.
- interaction
- Interaction-related functionality for QQ Bot
- manage
- Management event functionality for QQ Bot
- models
- Data models for the BotRS library.
- reaction
- Reaction-related functionality for QQ Bot
- token
- Authentication token management for QQ Guild Bot API.
Constants§
- DEFAULT_
API_ URL - Default API base URL for QQ Guild API
- DEFAULT_
TIMEOUT - Default timeout for HTTP requests in seconds
- DEFAULT_
WS_ URL - Default WebSocket URL for QQ Guild API
- SANDBOX_
API_ URL - Sandbox API base URL for testing
- VERSION
- The current version of the library