walle-core 0.2.1

Onebot Lib in Rust
Documentation
walle-core-0.2.1 has been yanked.

Walle-core

OneBot11 OneBot12

Walle-core 是一个 Rust OneBot Lib ( 不同于 libonebot 他同样可以应用于 OneBot 应用端 )

Walle 的名字来源于机械总动员的 WALL-E ( A Rusty Bot )

功能

  • 提供 OneBot v12 标准 Event、Action、ActionResp 序列化与反序列化功能,并支持自定义扩展
  • 提供 OneBot v12 实现端标准网络通讯协议
  • 提供 OneBot v12 应用端标准网络通讯协议(Http HttpWebhook 未支持)

features

  • echo: 启用 echo 字段 ( echo 字段默认实现,才不是因为分离太难了 )
  • http: 启用 Http 与 HttpWebhook 通讯协议
  • websocket: 启用正向 WebSocket 与反向 WebSocket 通讯协议
  • impl: 启用实现端 lib api
  • app: 启用应用端 lib api

How to use

仅展示最小实例

Implementation

use walle_core::{ImplConfig, impls::OneBot, DefaultHandler};

#[tokio::main]
async fn main() {
    tracing_subscriber::fmt().init(); // 初始化 tracing
    let config = ImplConfig::default();
    let ob = OneBot::new(
        "Your impl name".to_owned(),
        "Your impl platform".to_owned(),
        "Your bot self id".to_owned(),
        config,
        DefaultHandler::arc(), // ActionHandler
        ).arc();
    ob.run().await
    ... // run is not blocking do your own things
}

Application

use walle_core::{AppConfig, app::OneBot, DefaultHandler};

#[tokio::main]
async fn main() { 
    tracing_subscriber::fmt().init(); // 初始化 tracing
    let config = AppConfig::default();
    let ob = OneBot::new(
        config, 
        DefaultHandler::arc(), // EventHandler
    ).arc();
    ob.run().await
    ... 
    // run is not blocking do your own things
    // or use run_block().await
}