Interface PrivateMessageEvent

私聊消息

interface PrivateMessageEvent {
    auto_reply: boolean;
    body: Proto;
    div: number;
    font: string;
    frag: Proto;
    friend: Friend;
    from_id: number;
    from_uid: string;
    head: Proto;
    index: number;
    info: Proto;
    message: MessageElem[];
    message_id: string;
    message_type: "private";
    msg_id: bigint;
    nt: boolean;
    parsed: Parser;
    pktnum: number;
    post_type: "message";
    proto: Proto;
    rand: number;
    raw_message: string;
    sender: {
        discuss_id: undefined | number;
        group_id: undefined | number;
        nickname: string;
        uid: string;
        user_id: number;
    };
    seq: number;
    source?: Quotable;
    sub_type:
        | "friend"
        | "group"
        | "other"
        | "self";
    time: number;
    to_id: number;
    to_uid: string;
    uid: string;
    user_id: number;
    get nickname(): string;
    reply(content: Sendable, quote?: boolean): Promise<MessageRet>;
    serialize(): Buffer;
    toCqcode(): string;
    toJSON(keys: string[]): Record<string, any>;
    toString(): string;
}

Hierarchy (view full)

Properties

auto_reply: boolean

是否为自动回复

body: Proto
div: number
font: string
frag: Proto
friend: Friend

好友对象

from_id: number

发送方账号

from_uid: string

发送方uid

head: Proto
index: number
info: Proto
message: MessageElem[]

消息元素数组

message_id: string = ""

cqhttp方法用

message_type: "private" = ...
msg_id: bigint

消息id

nt: boolean

是否nt版本消息

parsed: Parser
pktnum: number
post_type: "message" = ...
proto: Proto
rand: number

消息随机数

raw_message: string

字符串形式的消息

sender: {
    discuss_id: undefined | number;
    group_id: undefined | number;
    nickname: string;
    uid: string;
    user_id: number;
} = ...

发送方信息

Type declaration

  • discuss_id: undefined | number

    讨论组号,当消息来自讨论组时有效

  • group_id: undefined | number

    群号,当消息来自群聊时有效

  • nickname: string

    昵称

  • uid: string

    uid

  • user_id: number

    账号

seq: number

消息编号,在群消息中是唯一的 (私聊消息建议至少使用time,seq,rand中的两个判断唯一性)

source?: Quotable

引用回复

sub_type:
    | "friend"
    | "group"
    | "other"
    | "self" = "friend"
time: number

消息时间

to_id: number

接收方账号

to_uid: string

接收方uid

uid: string

发送者uid

user_id: number

该值永远指向消息发送者。 对于私聊消息,请使用from_idto_id来确定发送者和接收者。 建议使用 sender.user_id

未来会改为访问器,仅供内部转发消息时使用。

Accessors

  • get nickname(): string
  • 发送方昵称,仅供内部转发消息时使用

    Returns string

Methods