kovi::bot::plugin_builder::event::msg_event

Struct MsgEvent

Source
pub struct MsgEvent {
Show 16 fields pub time: i64, pub self_id: i64, pub post_type: String, pub message_type: String, pub sub_type: String, pub message: Message, pub message_id: i32, pub group_id: Option<i64>, pub user_id: i64, pub anonymous: Option<Anonymous>, pub raw_message: String, pub font: i32, pub sender: Sender, pub text: Option<String>, pub human_text: String, pub original_json: Value, /* private fields */
}

Fields§

§time: i64

事件发生的时间戳

§self_id: i64

收到事件的机器人 登陆号

§post_type: String

上报类型

§message_type: String

消息类型

§sub_type: String

消息子类型,如果是好友则是 friend,如果是群临时会话则是 group

§message: Message

消息内容

§message_id: i32

消息 ID

§group_id: Option<i64>

群号

§user_id: i64

发送者号

§anonymous: Option<Anonymous>

匿名信息,如果不是匿名消息则为 null

§raw_message: String

原始消息内容

§font: i32

字体

§sender: Sender

发送人信息

§text: Option<String>

处理过的纯文本,如果是纯图片或无文本,此处为None

§human_text: String

处理过的文本,会解析成人类易读形式,里面会包含[image][face]等解析后字符串

§original_json: Value

原始的onebot消息,已处理成json格式

Implementations§

Source§

impl MsgEvent

Source

pub fn reply<T>(&self, msg: T)
where Message: From<T>, T: Serialize,

快速回复消息

Source

pub fn reply_and_quote<T>(&self, msg: T)
where Message: From<T>, T: Serialize,

快速回复消息并且引用

Source

pub fn get_text(&self) -> String

便捷获取文本,如果没有文本则会返回空字符串,如果只需要借用,请使用 borrow_text()

Source

pub fn get_sender_nickname(&self) -> String

便捷获取发送者昵称,如果无名字,此处为空字符串

Source

pub fn borrow_text(&self) -> Option<&str>

借用 event 的 text,只是做了一下self.text.as_deref()的包装

Source

pub fn is_group(&self) -> bool

Source

pub fn is_private(&self) -> bool

Trait Implementations§

Source§

impl Clone for MsgEvent

Source§

fn clone(&self) -> MsgEvent

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MsgEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T