onebot-11
onebot-11 copied to clipboard
【提议】:新增 reaction 事件
(2024.03)最近NTQQ 新增了群聊内表情回应。
尽管 Onebot11 标准已经很久没有更新了,但是相关需求仍然存在。 因此提议新增 GroupReactionEvent 事件。
当其他成员对 bot 所发送消息的回应会触发该事件。
| 字段名 | 数据类型 | 可能的值 | 说明 |
|---|---|---|---|
time |
number int64 | - | 事件发生的时间戳 |
self_id |
number int64 | - | 收到事件的机器人 QQ 号 |
post_type |
string | notice |
上报类型 |
notice_type |
string | group_reaction |
通知类型 |
group_id |
number int64 | - | 群号 |
user_id |
string | - | QQ 号 |
message_id |
string | - | 回应的目标消息 ID |
qface_id |
string | - | QQ 表情 ID |
QQ 方面,当新的回应出现时:
- 会收到目标消息的更新,内容是目标消息的当前状态,因此该消息中并不会明确指出这是 Emoji Reaction,只在
emojiLikesList字段中给出消息此刻的所有 Emoji Reaction(回应事件发生,如新增/删除)
"emojiLikesList": [
{
"emojiId": "277",
"emojiType": "1",
"likesCnt": "1",
"isClicked": false
}
],
- 如果该回应是对本号所发送消息的回应时,同时会收到一个群聊事件,是与群聊邀请类似的 grayTipElement,可通过
subElementType==12,通过busiId=="4" && busiType="19270"判断,如图
其xml content如下:
"xmlElement": {
"busiType": "4",
"busiId": "19270",
"c2cType": 0,
"serviceType": 0,
"ctrlFlag": 0,
"content": "<gtip align=\"center\"> <qq uin=\"replyer_qquin\" col=\"3\" jp=\"replyer_qqnumber\"/> <nor txt=\"回应了你的\"/> <url jp= \"\" msgseq=\"3893\" col=\"3\" txt=\"消息:\"/> <face type=\"1\" id=\"277\"> </face> </gtip>",
"templId": "10382",
"seqId": "1713682981753442094",
"templParam": {},
"pbReserv": null,
"members": {}
}
在该消息中,可以获取到目标消息的SeqID,发送者 QQID,以及表情 ID。
目前是出于实现方便的考虑,仅对本号发送消息的新增 reaction 生效,因为其他变更只会触发上述 1. 。
如果要完善考虑,纳入对其他消息的 reaction 进行监听或是 reaction 删除事件,可考虑将类型由 event 改为 message。