Struct miraie::bot::Bot[][src]

pub struct Bot { /* fields omitted */ }
Expand description

Bot 用来保存一个 bot 中的状态,如消息队列、跟连接的沟通、数据库连接等。

Implementations

建立一个 bot,会在这里建立跟服务器的 websocket 连接。

参数

  • addr: mirai 服务器的地址,需要开启 websocket 的 adapter
  • verify_key: 鉴权 key
  • qq:机器人的 qq 号

Example

let (bot, conn) = Bot::new(
    "127.0.0.1:8080".parse().unwrap(),
    "verify_key",
    QQ(12345)
).await?;

async fn handler(msg: Message) {}

bot.handler(handler);
conn.run().await?;

对 mirai bot 发送一个请求,默认超时 10s,如果需要调整超时,使用 Self::request_timeout

对 mirai bot 发送一个请求,带有自定义超时

获取一个全部消息的 stream

获取一个全部群聊消息的 stream

获取一个私聊消息的 stream

获取一个事件的 stream

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.