Skip to content

Commit

Permalink
fix: close #164
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Sep 12, 2024
1 parent 7e9ac29 commit ee71426
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 11 deletions.
32 changes: 29 additions & 3 deletions src/adapter/onebot/11/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ export class OB11Event {
const self_id = data.self_id + ''
let notice = {} as KarinNotice

const user_id = data.user_id + ''
/** 别问为啥any... 我是any糕手~ */
const user_id = ((data as any).user_id || (data as any).operator_id) + ''
const event_id = `notice.${time}`
const sender = {
uid: data.user_id + '',
uin: data.user_id + '',
uid: user_id,
uin: user_id,
nick: '',
role: Role.Unknown,
}
Expand Down Expand Up @@ -370,6 +371,31 @@ export class OB11Event {
notice = new KarinNotice(options)
break
}
// Language表情动态上报
case 'reaction': {
const group_id = data.group_id + ''
const content = {
group_id,
message_id: data.message_id,
face_id: Number(data.code),
is_set: data.sub_type === 'add',
}

const options = {
raw_event: data,
time,
self_id,
user_id,
event_id,
sender,
contact,
content,
group_id,
sub_event: NoticeSubType.GroupMessageReaction,
}
notice = new KarinNotice(options)
break
}
default: {
return this.adapter.logger('error', '未知通知事件:', JSON.stringify(data))
}
Expand Down
49 changes: 41 additions & 8 deletions src/types/onebot11/event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-unused-vars */

import { OB11Segment } from './segment'
import { GroupSender, PrivateSender, ob11Sender } from './sender'

Expand All @@ -11,15 +9,15 @@ export const enum OB11PostType {
Notice = 'notice',
Request = 'request',
MetaEvent = 'meta_event',
MessageSent = 'message_sent'
MessageSent = 'message_sent',
}

/**
* 消息事件类型
*/
export const enum OB11MessageType {
Private = 'private',
Group = 'group'
Group = 'group',
}

/**
Expand All @@ -31,7 +29,7 @@ export const enum OB11MessageSubType {
Other = 'other',
Normal = 'normal',
Anonymous = 'anonymous',
Notice = 'notice'
Notice = 'notice',
}

/**
Expand Down Expand Up @@ -174,7 +172,8 @@ export const enum OB11NoticeType {
GroupRecall = 'group_recall',
FriendRecall = 'friend_recall',
Notify = 'notify',
GroupMsgEmojiLike = 'group_msg_emoji_like'
GroupMsgEmojiLike = 'group_msg_emoji_like',
GroupMsgEmojiLikeLagrange = 'reaction',
}

/**
Expand Down Expand Up @@ -502,12 +501,46 @@ export interface OneBot11GroupMessageReaction extends OneBot11Notice {
}>
}

/**
* 群表情回应事件 Lagrange
*/
export interface OneBot11GroupMessageReactionLagrange extends OneBot11Notice {
/**
* - 消息类型
*/
notice_type: OB11NoticeType.GroupMsgEmojiLikeLagrange
/**
* - 提示类型
*/
sub_type: 'remove' | 'add'
/**
* - 群号
*/
group_id: string
/**
* - 发送者 QQ 号
*/
operator_id: string
/**
* - 消息 ID
*/
message_id: string
/**
* - 表情ID
*/
code: string
/**
* - 表情数量
*/
count: number
}

/**
* 请求事件类型
*/
export const enum OB11RequestType {
Friend = 'friend',
Group = 'group'
Group = 'group',
}

/**
Expand Down Expand Up @@ -627,7 +660,7 @@ export type OB11MessageEvent = OB11PrivateMessage | OB11GroupMessage
/**
* 所有通知事件类型
*/
export type OB11NoticeEvent = OneBot11GroupUpload | OneBot11GroupAdmin | OneBot11GroupDecrease | OneBot11GroupIncrease | OneBot11GroupBan | OneBot11FriendAdd | OneBot11GroupRecall | OneBot11FriendRecall | OneBot11Poke | OneBot11LuckyKing | OneBot11Honor | OneBot11GroupMessageReaction
export type OB11NoticeEvent = OneBot11GroupUpload | OneBot11GroupAdmin | OneBot11GroupDecrease | OneBot11GroupIncrease | OneBot11GroupBan | OneBot11FriendAdd | OneBot11GroupRecall | OneBot11FriendRecall | OneBot11Poke | OneBot11LuckyKing | OneBot11Honor | OneBot11GroupMessageReaction | OneBot11GroupMessageReactionLagrange

/**
* 所有请求事件类型
Expand Down

0 comments on commit ee71426

Please sign in to comment.