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:
9 files changed
+120
-1
No files matched your search
@@ -294,6 +294,17 @@ export interface PttTransResultEvent extends QQEvent {
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The bot account was forced offline (kicked / logged in elsewhere / risk-control)
|
||||
* — SSO push `StatusService.KickNT`. Mirrors NapCat's OB11BotOfflineEvent →
|
||||
* `notice_type:'bot_offline'`. `tag` = short title, `message` = description.
|
||||
*/
|
||||
export interface BotOfflineEvent extends QQEvent {
|
||||
kind: 'bot_offline';
|
||||
tag: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A group member's card (群名片) changed — detected from message traffic when
|
||||
* the sender's live card differs from the cached one (same mechanism as NapCat's
|
||||
@@ -377,4 +388,5 @@ export type QQEventVariant =
|
||||
| GroupNameChangeEvent
|
||||
| GroupCardChangeEvent
|
||||
| GroupTitleChangeEvent
|
||||
| FriendProfileLikeEvent;
|
||||
| FriendProfileLikeEvent
|
||||
| BotOfflineEvent;
|
||||
@@ -0,0 +1,33 @@
|
||||
// Forced-offline push. QQ NT tells a client it was kicked / logged in elsewhere /
|
||||
// dropped for risk-control via the SSO command
|
||||
// `trpc.qq_new_tech.status_svc.StatusService.KickNT`, whose body is a
|
||||
// `KickNTResponse`. We surface it as a `bot_offline` event (NapCat parity).
|
||||
//
|
||||
// The push arrives on the same StatusService channel SnowLuma already receives
|
||||
// (e.g. StatusService.SsoHeartBeat), so it just needs its own cmd handler.
|
||||
// Command + field layout RE-confirmed against wrapper.linux.node + Lagrange's
|
||||
// KickNTService/ServiceKickNTResponse.
|
||||
|
||||
import { protobuf_decode } from '@snowluma/proton';
|
||||
import type { KickNTResponse } from '@snowluma/proto-defs/notify';
|
||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||
import type { IdentityService } from './identity-service';
|
||||
import type { QQEventVariant } from './events';
|
||||
|
||||
export const KICK_NT_CMD = 'trpc.qq_new_tech.status_svc.StatusService.KickNT';
|
||||
|
||||
type BotOfflineEvent = Extract<QQEventVariant, { kind: 'bot_offline' }>;
|
||||
|
||||
export function parseKickNT(pkt: PacketInfo, identity: IdentityService): QQEventVariant[] {
|
||||
const resp = protobuf_decode<KickNTResponse>(pkt.body);
|
||||
if (!resp) return [];
|
||||
const ev: BotOfflineEvent = {
|
||||
kind: 'bot_offline',
|
||||
// KickNT carries no timestamp — stamp with receive time.
|
||||
time: Math.floor(Date.now() / 1000),
|
||||
selfUin: Number(pkt.uin) || Number(identity.uin) || 0,
|
||||
tag: resp.title ?? '', // tips_title — the short title
|
||||
message: resp.tips ?? '', // tips_content — the description / reason
|
||||
};
|
||||
return [ev];
|
||||
}
|
||||
Reference in new issue
Block a user