mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
build: 1.6.6-build02
This commit is contained in:
parent
a10f007194
commit
733052720c
@ -89,7 +89,7 @@ export function CacheClassFuncAsync(ttl: number = 3600 * 1000, customKey: string
|
||||
}
|
||||
return logExecutionTime;
|
||||
}
|
||||
export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (_data: any) => { return true; }) {
|
||||
export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (...data: any[]) => { return true; }) {
|
||||
//console.log('CacheClassFuncAsync', ttl, customKey);
|
||||
function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) {
|
||||
//console.log('logExecutionTime', target, methodName, descriptor);
|
||||
@ -108,7 +108,7 @@ export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey:
|
||||
}
|
||||
// const start = Date.now();
|
||||
const result = await originalMethod.apply(this, args);
|
||||
if (!checker(result)) {
|
||||
if (!checker(...args, result)) {
|
||||
return result;//丢弃缓存
|
||||
}
|
||||
// const end = Date.now();
|
||||
|
@ -6,7 +6,7 @@ import { ProfileListener } from '@/core/listeners';
|
||||
import { rejects } from 'assert';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import { logDebug, logError } from '@/common/utils/log';
|
||||
import { log, logDebug, logError, logWarn } from '@/common/utils/log';
|
||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||
const userInfoCache: Record<string, User> = {}; // uid: User
|
||||
|
||||
@ -163,7 +163,13 @@ export class NTQQUserApi {
|
||||
}
|
||||
return skey;
|
||||
}
|
||||
@CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (data: string | undefined) => { if (data && data.indexOf('u_') != -1) { return true } return false; })
|
||||
@CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (Uin: string, Uid: string | undefined) => {
|
||||
if (Uid && Uid.indexOf('u_') != -1) {
|
||||
return true
|
||||
}
|
||||
logWarn("uin转换到uid时异常", Uin);
|
||||
return false;
|
||||
})
|
||||
static async getUidByUin(Uin: string) {
|
||||
let ret = await NTEventDispatch.CallNoListenerEvent
|
||||
<(Uin: string[]) => Promise<{ uidInfo: Map<string, string> }>>(
|
||||
@ -197,7 +203,13 @@ export class NTQQUserApi {
|
||||
}
|
||||
return uid;
|
||||
}
|
||||
@CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (data: number | undefined) => { if (data && data != 0 && !isNaN(data)) { return true } return false; })
|
||||
@CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (Uid: string | undefined, Uin: number | undefined) => {
|
||||
if (Uin && Uin != 0 && !isNaN(Uin)) {
|
||||
return true
|
||||
}
|
||||
logWarn("uin转换到uid时异常", Uid);
|
||||
return false;
|
||||
})
|
||||
static async getUinByUid(Uid: string | undefined) {
|
||||
if (!Uid) {
|
||||
return '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user