Typed Event Payloads
Gateway dispatches are decoded into Rust models for messages, guilds, channels, members, reactions, interactions, audio, manage, and forum events.
A focused async framework for QQ gateway events and core bot REST actions
BotRS is an asynchronous Rust framework for building QQ bots around the QQ gateway and a focused bot OpenAPI surface. It provides the pieces most bots need in the live event path: gateway connection management, typed event payloads, a shared REST client, token handling, and intent selection.
The central types are:
Client owns startup, gateway sessions, and event dispatch.EventHandler is the trait you implement for gateway events.BotApi.BotApi sends messages and performs the core REST actions used by the examples.Token stores credentials and supports environment loading.Intents controls which gateway categories QQ sends.BotRS handles the core event-to-action loop:
session.reply("text"), send_markdown_message, send_embed_message, send_ark_message, send_keyboard_message, or a matching params struct when you need direct field control.BotApi.use botrs::{ChannelReplySession, Client, EventHandler, Intents, ReadySession, Token};
struct MyBot;
#[async_trait::async_trait]
impl EventHandler for MyBot {
async fn ready(&self, session: ReadySession) {
println!("Bot is ready as {}", session.event().user.username);
}
async fn message_create(&self, mut session: ChannelReplySession) {
let message = session.message().clone();
if message.author.bot {
return;
}
if message.content.trim() == "!ping" {
let _ = session.reply("pong").await;
}
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = Token::from_env()?;
let intents = Intents::new().with_public_guild_messages();
let mut client = Client::new(token, intents, MyBot, true)?;
client.start().await?;
Ok(())
}BotApi through sessions or standalone.