群聊消息
公共字段
通过 on_group_message 接收群聊消息的公共结构体与消息段类型列表。
on_group_message 为可选导出函数。未导出时,主程序不会向插件投递群聊消息。
EXPORT void on_group_message(const GroupMessage *message);使用约定
- 结构体及所有字符串字段均非
NULL,且仅在本次回调期间有效;如需在工作线程或稍后使用,必须先复制所需字段。 message字段为 UTF-8 JSON 数组,每项为{"type": "类型", "data": {...}};接收时应容忍未知类型和字段,不要用浮点数保存 64 位整数。- 回调应尽快返回,不要将收到的
GroupMessage字段与调用send_group_message返回的SendResult混用。
GroupMessage 公共字段
| 字段 | 类型 | 说明 |
|---|---|---|
self_id | uint64_t | 收到消息的 Bot 账号 |
platform | const char * | 所属平台 PLATFORM_* |
group_id | uint64_t | 群号 |
user_id | uint64_t | 发送人 QQ 号 |
msg_seq | uint64_t | 消息序号 |
msg_uid | uint64_t | 消息唯一编号 |
random | uint64_t | 消息随机数 |
msg_time | uint64_t | 发送时间(Unix 秒) |
level | uint64_t | 发送人的群成员等级,没有时为 0 |
group_name | const char * | 群名称 |
nickname | const char * | 发送人昵称(设置了群名片时为群名片) |
role | const char * | 发送人身份:"owner" 群主、"admin" 管理员、"member" 成员 |
title | const char * | 发送人头衔,没有时为 "" |
message | const char * | 消息段 UTF-8 JSON 数组(Segment[]) |