Skip to content

BotRSRust QQ Bot Framework

A focused async framework for QQ gateway events and core bot REST actions

What Is BotRS?

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.
  • Session types give each callback access to event data, bot info, and the shared 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.

Current Capabilities

BotRS handles the core event-to-action loop:

  • Receive typed gateway events for guild/channel/member changes, guild messages, direct messages, group and C2C messages, reactions, interactions, audits, manage events, audio events, and forum events.
  • Reply with 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.
  • Send guild, group, C2C, and direct messages through BotApi.
  • Upload group/C2C media, then send it as a media message.
  • Work with guild/channel resources, roles, mute state, channel permissions, announcements, schedules, API permission requests, reactions, pinned messages, and audio controls.

Quick Example

rust
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(())
}

Getting Started

  1. Installation - Add BotRS to your Rust project.
  2. Quick Start - Run a minimal bot.
  3. Client and Event Handler - Learn the event loop.
  4. Messages - Send text, media, markdown, ark, embed, and keyboard payloads.
  5. API Client - Use BotApi through sessions or standalone.

Released under the MIT License.