feat(onebot): report forced offline as notice/bot_offline

Register a handler for the StatusService.KickNT push (QQ NT's unified
forced-offline notification — kick / login-elsewhere / risk-control),
decode KickNTResponse and emit bot_offline {user_id, tag, message},
matching NapCat. Command + field layout (f4=tips_title, f3=tips_content)
RE-confirmed against wrapper.linux.node + Lagrange; not yet live-captured.
This commit is contained in:
DrSmoothl committed 2026-07-07 15:25:35 +08:00
1 parent eda1c32994
commit d9dfe513ee
9 files changed
+120 -1

No files matched your search

@@ -6,6 +6,7 @@ import {
convertTempMessage,
} from './to-message';
import {
convertBotOffline,
convertFriendAdd,
convertFriendInputStatus,
convertFriendProfileLike,
@@ -85,6 +86,7 @@ const CONVERTERS: ConverterRegistry = {
friend_add: convertFriendAdd,
friend_input_status: convertFriendInputStatus,
friend_profile_like: convertFriendProfileLike,
bot_offline: convertBotOffline,
group_name_change: convertGroupNameChange,
group_title_change: convertGroupTitleChange,
group_card_change: convertGroupCardChange,
@@ -22,6 +22,7 @@ type GroupNameChange = Extract<QQEventVariant, { kind: 'group_name_change' }>;
type GroupCardChange = Extract<QQEventVariant, { kind: 'group_card_change' }>;
type GroupTitleChange = Extract<QQEventVariant, { kind: 'group_title_change' }>;
type FriendProfileLike = Extract<QQEventVariant, { kind: 'friend_profile_like' }>;
type BotOffline = Extract<QQEventVariant, { kind: 'bot_offline' }>;
export function convertGroupMemberJoin(ctx: ConverterContext, event: GroupMemberJoin): JsonObject {
return notice(ctx, event, {
@@ -173,6 +174,17 @@ export function convertGroupCardChange(ctx: ConverterContext, event: GroupCardCh
});
}
export function convertBotOffline(ctx: ConverterContext, event: BotOffline): JsonObject {
// Mirrors NapCat's OB11BotOfflineEvent: notice_type bot_offline with the bot's
// own uin plus the tag/message describing why it went offline.
return notice(ctx, event, {
notice_type: 'bot_offline',
user_id: event.selfUin,
tag: event.tag,
message: event.message,
});
}
export function convertFriendProfileLike(ctx: ConverterContext, event: FriendProfileLike): JsonObject {
// Mirrors NapCat's OB11ProfileLikeEvent: notify/profile_like with the liker's
// uin, nickname and like count.
+1
View File
@@ -72,6 +72,7 @@ const NOTICE_KINDS = [
'friend_add',
'friend_input_status',
'friend_profile_like',
'bot_offline',
'group_name_change',
'group_title_change',
'group_card_change',