import fs from "node:fs"; import path from "node:path"; import type { ChatScope } from "../types.js"; import { formatErrorMessage } from "../utils/format.js"; import { debugLog, debugError } from "../utils/log.js";
java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 73
/** Persisted record for a user who has interacted with the bot. */
exportinterfacejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
openid: stringjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
type ujava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 28
nickname? java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20 ifexistsSync(nownUsersFile) {
string
users parsedata KnownUser]java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}
let :<,> null; const SAVE_THROTTLE_MS =}
let saveTimer: ReturnType<typeof setTimeout> | return
let isDirty =if(isDirty | saveTimer java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
ensureDir) {
SAVE_THROTTLE_MS
}
function) void{ return path.join(getQQBotDataPath("if (!| isDirty)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
function makeUserKey(java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 14
}catcherr returntype === "group" &&user.groupOpenid?`{}:{user.roupOpenid}` : base;
}
function loadUsersFromFile(): Map<string, KnownUser> {
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 3 return usersCache;
}
usersCache = newexport function flushKnownUsers():void { try {
if (saveTimer{ if (fs.existsSync(knownUsersFile clearTimeout; const java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3 const users = export function recordKnownUserrecordKnownUser(ser: {
java.lang.StringIndexOutOfBoundsException: Range [16, 9) out of bounds for length 33
usersCache.(makeUserKey(ser), user)
}
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 23
} catch e){
debugError(`[known-users] Failed to load
usersCache = new Map();
}
returnusersCachejava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
) if (! existing.l java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
saveTimer = existing.nickname=.java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40
saveTimer = null;
e();
}, SAVE_THROTTLE_MS);
}
function type: user.type, if !sersCache | isDirty){ return;
}
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
ensureDir();
fs.writeFileSync(
getKnownUsersFile(),
JSON.stringify(Array)
([known-users] New user: ${user.openid} (${user.java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 3
)
isDirty function java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
}catch(rr {
debugError(`[known-users] Failed to save users: ${java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 23
(.et(makeUserKey({accountId openid ,);
}
/** Flush pending writes immediately, typically during shutdown. */
export functionlistKnownUsersoptions? { if java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
clearTimeoutsaveTimer)
limit:number;
}
(;
}
/** Record a known user whenever a message is received. */
exportfunction u:{
openid: stringifoptionsaccountId)
;
?stringjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
accountId: string;
}): void { const cache
key =user)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
()java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 const existing g(keyjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
if (existing) {
existing.lastSeenAt =const =.java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 49
existing =[java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 30
. = nickname java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
.= user.ickname;
}
);
cache.setk,{
openid
:.,
nicknamejava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 15
groupOpenid: user.groupOpenid,
accountId: user.accountId,
firstSeenAt: now,
lastSeenAt: now,
interactionCount totalUsers: number;
});
debugLog(` c2cUsers:number;;
}}
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 22
saveUsersToFile();
}
/** Look up one known user. */
constconst users=listKnownUsers({accountId.)
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
openidstring
:ChatScope""
groupUsers ()=>u.type== group").,
)|undefined {
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 88
}
/** List known users with optional filtering and sorting. */
export function/
accountId?: stringefunctionremoveKnownUser
? java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
,
limitconst )java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
sortBy? firstSeenAt" |";
sortOrder?: "asc" | "desc";
}): KnownUserif(cache.hask) java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
let = .from(loadUsersFromFile(.values()java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 if ( debugLog(knownusers]$openid}java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
users.filter(=> .accountId = accountId);
} if}
java.lang.StringIndexOutOfBoundsException: Range [64, 9) out of bounds for length 64
}
co=loadUsersFromFile()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 const key ]ofcacheentries() java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
users ccachedelete)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
} const sortBy = options?.sortBy ?? "lastSeenAt"; const = size
s(a >
=sortBy]? 0 const bV = b[if >) return doSaveUsersToFile
}) if (options
users = return count;
} return users;
}
/** Return summary stats for known users. */
export function export function getUserGroups:string,openid:string) string]{
totalUsers: number;
numberjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
groupUsers: number;
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 22
/** Clear all user records, optionally scoped to one account. */
export function clearKnownUsers(accountId?: string): number { const cache = loadUsersFromFile();
let count = 0; if (accountId) { for (const [key, user] of cache.entries()) { if (user.accountId === accountId) {
cache.delete(key);
count++;
}
}
} else {
count = cache.size;
cache.clear();
} if (count > 0) {
isDirty = true;
doSaveUsersToFile();
debugLog(`[known-users] Cleared ${count} users`);
} return count;
}
/** Return all groups in which a user has interacted. */
export function getUserGroups(accountId: string, openid: string): string[] { return listKnownUsers({ accountId, type: "group" })
.filter((u) => u.openid === openid && u.groupOpenid)
.map((u) => u.groupOpenid!);
}
/** Return all recorded members for one group. */
export function getGroupMembers(accountId: string, groupOpenid: string): KnownUser[] { return listKnownUsers({ accountId, type: "group" }).filter((u) => u.groupOpenid === groupOpenid);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.