Struct miraie::messages::MessageChain[][src]

pub struct MessageChain(pub Vec<MessageBlock>);
Expand description

一条接受或者发送的消息,可能由一个或几个 MessageBlock 构成。

如果是接受到的消息,第一个 Block 一定是 Source。

Example

use miraie::prelude::*;
let chain = MessageChain::new()
    .text("text")
    .image_path("a.jpg")
    .at(QQ(12345));

Implementations

新建一条消息,通常用来回复

在消息里增加一个 at 人

在消息里增加一个 at 所有人

在消息里增加一些文字

在消息里增加一张图片,其来自 url

在消息里增加一张图片,发送本地图片,相对路径于 env:MIRAIE_RESOURCE_ROOT/images。

注意这里的路径是相对于 mirai 运行环境的路径,并不一定是机器人所在机器的路径。

在消息里增加一段语音

在消息里增加一段语音,发送本地语音,相对路径于 env:MIRAIE_RESOURCE_ROOT/voices

注意这里的路径是相对于 mirai 运行环境的路径,并不一定是机器人所在机器的路径。

获取消息的 message id,可以用于稍后回复

尝试把 message 按照 确认/取消 消息进行匹配。只会匹配常用的一些结构, 如“好”,“确认”等,并不保证准确。如果需要更准确的结果建议自行实现。

从简单的 xml 解析出 MessageChain

标签

标签内容都是路径,且是相对于 env:MIRAIE_RESOURCE_ROOT/{voices|images} 的相对路径。

  • i, img, image:图片
  • v, voice:音频

Example

let chain = MessageChain::from_xml("下面是图片:<img> image.jpg </img>");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. 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

Converts the given value to a String. 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.