SnowLuma v2.4.2 source snapshot
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
This commit is contained in:
commit
fa9c73363d
1367 files changed
+355735
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
export const GROUP_MESSAGE_EVENT = 'group_message';
|
||||
export const PRIVATE_MESSAGE_EVENT = 'private_message';
|
||||
/** Legacy/fallback namespace for private messages sent by the current account. */
|
||||
export const PRIVATE_SENT_MESSAGE_EVENT = 'private_message_sent';
|
||||
/** Namespace for private messages keyed by QQ's conversation-wide NT sequence. */
|
||||
export const PRIVATE_NT_MESSAGE_EVENT = 'private_message_nt';
|
||||
|
||||
export function privateMessageEventName(sentBySelf: boolean, hasNtSequence: boolean): string {
|
||||
if (hasNtSequence) {
|
||||
return PRIVATE_NT_MESSAGE_EVENT;
|
||||
}
|
||||
|
||||
return sentBySelf ? PRIVATE_SENT_MESSAGE_EVENT : PRIVATE_MESSAGE_EVENT;
|
||||
}
|
||||
|
||||
export function hashMessageIdInt32(sequence: number, sessionId: number, eventName: string): number {
|
||||
const seq = Number.isFinite(sequence) ? Math.trunc(sequence) : 0;
|
||||
const session = Number.isFinite(sessionId) ? Math.trunc(sessionId) : 0;
|
||||
const key = `${seq}:${session}:${eventName}`;
|
||||
const digest = createHash('sha1').update(key).digest();
|
||||
|
||||
let id = digest.readInt32BE(0);
|
||||
|
||||
if (id === 0) {
|
||||
id = 1;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
Reference in new issue
Block a user