feat(onebot): report C2C input status as notify/input_status
Decode the 0x210/0x115 input-state sys_msg (RE'd from wrapper.linux.node aio_input_state_worker) into a friend_input_status event and map it to a notify/input_status notice, matching NapCat's onInputStatusPush. event_type 1 = typing, 3 = recording voice; status_text synthesised to match the client's own strings.
This commit is contained in:
8 files changed
+138
-1
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
} from './to-message';
|
||||
import {
|
||||
convertFriendAdd,
|
||||
convertFriendInputStatus,
|
||||
convertFriendPoke,
|
||||
convertFriendRecall,
|
||||
convertGroupAdmin,
|
||||
@@ -78,6 +79,7 @@ const CONVERTERS: ConverterRegistry = {
|
||||
group_essence: convertGroupEssence,
|
||||
group_file_upload: convertGroupFileUpload,
|
||||
friend_add: convertFriendAdd,
|
||||
friend_input_status: convertFriendInputStatus,
|
||||
group_msg_emoji_like: convertGroupMsgEmojiLike,
|
||||
// Requests.
|
||||
friend_request: convertFriendRequest,
|
||||
|
||||
@@ -17,6 +17,7 @@ type GroupEssence = Extract<QQEventVariant, { kind: 'group_essence' }>;
|
||||
type GroupFileUpload = Extract<QQEventVariant, { kind: 'group_file_upload' }>;
|
||||
type FriendAdd = Extract<QQEventVariant, { kind: 'friend_add' }>;
|
||||
type GroupMsgEmojiLike = Extract<QQEventVariant, { kind: 'group_msg_emoji_like' }>;
|
||||
type FriendInputStatus = Extract<QQEventVariant, { kind: 'friend_input_status' }>;
|
||||
|
||||
export function convertGroupMemberJoin(ctx: ConverterContext, event: GroupMemberJoin): JsonObject {
|
||||
return notice(ctx, event, {
|
||||
@@ -156,6 +157,18 @@ export function convertFriendAdd(ctx: ConverterContext, event: FriendAdd): JsonO
|
||||
});
|
||||
}
|
||||
|
||||
export function convertFriendInputStatus(ctx: ConverterContext, event: FriendInputStatus): JsonObject {
|
||||
// Mirrors NapCat's OB11InputStatusEvent: notify/input_status with the peer's
|
||||
// uin, the raw event_type (1 = typing, 3 = recording voice) and status_text.
|
||||
return notice(ctx, event, {
|
||||
notice_type: 'notify',
|
||||
sub_type: 'input_status',
|
||||
user_id: event.userUin,
|
||||
event_type: event.eventType,
|
||||
status_text: event.statusText,
|
||||
});
|
||||
}
|
||||
|
||||
export function convertGroupMsgEmojiLike(ctx: ConverterContext, event: GroupMsgEmojiLike): JsonObject {
|
||||
const messageId = applyMessageIdResolver(
|
||||
ctx.messageIdResolver, true, event.groupId, event.msgSeq, GROUP_MESSAGE_EVENT,
|
||||
|
||||
Reference in new issue
Block a user