From 14822c9599566db32fc6a604824c6d9b321556c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 21 Jun 2024 23:04:56 +0800 Subject: [PATCH] style&fix: lint & poke --- src/common/utils/MessageUnique.ts | 78 +++++++++---------- src/common/utils/Packet.ts | 10 +-- src/common/utils/helper.ts | 32 ++++---- src/common/utils/request.ts | 5 +- .../action/extends/CreateCollection.ts | 22 +++--- .../action/extends/GetCollectionList.ts | 22 +++--- src/onebot11/action/extends/SetLongNick.ts | 22 +++--- src/onebot11/action/extends/SetSelfProfile.ts | 38 ++++----- src/onebot11/action/extends/sharePeer.ts | 48 ++++++------ .../action/go-cqhttp/GetStrangerInfo.ts | 10 +-- src/onebot11/action/group/SetGroupKick.ts | 2 +- .../msg/SendMsg/create-send-elements.ts | 2 +- src/onebot11/action/msg/SendMsg/index.ts | 6 +- src/onebot11/action/types.ts | 8 +- src/onebot11/action/user/SendLike.ts | 2 +- src/onebot11/constructor.ts | 4 +- src/onebot11/main.ts | 28 +++---- 17 files changed, 169 insertions(+), 170 deletions(-) diff --git a/src/common/utils/MessageUnique.ts b/src/common/utils/MessageUnique.ts index 72fd9814..509dc750 100644 --- a/src/common/utils/MessageUnique.ts +++ b/src/common/utils/MessageUnique.ts @@ -1,53 +1,53 @@ import crypto from 'crypto'; class LimitedHashTable { - private keyToValue: Map = new Map(); - private valueToKey: Map = new Map(); - private maxSize: number; - private KeyQueneList: K[] = []; - private ValueQueneList: V[] = []; - constructor(maxSize: number) { - this.maxSize = maxSize; - } - set(key: K, value: V): void { - this.keyToValue.set(key, value); - this.valueToKey.set(value, key); - if (this.KeyQueneList.length >= this.maxSize || this.ValueQueneList.length >= this.maxSize) { - this.KeyQueneList.shift(); - this.ValueQueneList.shift(); - } + private keyToValue: Map = new Map(); + private valueToKey: Map = new Map(); + private maxSize: number; + private KeyQueneList: K[] = []; + private ValueQueneList: V[] = []; + constructor(maxSize: number) { + this.maxSize = maxSize; + } + set(key: K, value: V): void { + this.keyToValue.set(key, value); + this.valueToKey.set(value, key); + if (this.KeyQueneList.length >= this.maxSize || this.ValueQueneList.length >= this.maxSize) { + this.KeyQueneList.shift(); + this.ValueQueneList.shift(); } + } - getValue(key: K): V | undefined { - return this.keyToValue.get(key); - } + getValue(key: K): V | undefined { + return this.keyToValue.get(key); + } - getKey(value: V): K | undefined { - return this.valueToKey.get(value); - } + getKey(value: V): K | undefined { + return this.valueToKey.get(value); + } - delete(key: K): void { - const value = this.keyToValue.get(key); - if (value !== undefined) { - this.keyToValue.delete(key); - this.valueToKey.delete(value); - } + delete(key: K): void { + const value = this.keyToValue.get(key); + if (value !== undefined) { + this.keyToValue.delete(key); + this.valueToKey.delete(value); } + } } class MessageUniqueWrapper { - private msgIdMap: LimitedHashTable = new LimitedHashTable(1000); - createMsg(MsgId: string) { - let ShortId = parseInt(crypto.createHash('sha1').update('2345').digest('hex').slice(0, 8), 16); - this.msgIdMap.set(ShortId, MsgId); - return ShortId; - } - getMsgIdByShortId(ShortId: number) { - return this.msgIdMap.getValue(ShortId); - } - getShortIdByMsgId(MsgId: string) { - return this.msgIdMap.getKey(MsgId); - } + private msgIdMap: LimitedHashTable = new LimitedHashTable(1000); + createMsg(MsgId: string) { + const ShortId = parseInt(crypto.createHash('sha1').update('2345').digest('hex').slice(0, 8), 16); + this.msgIdMap.set(ShortId, MsgId); + return ShortId; + } + getMsgIdByShortId(ShortId: number) { + return this.msgIdMap.getValue(ShortId); + } + getShortIdByMsgId(MsgId: string) { + return this.msgIdMap.getKey(MsgId); + } } export const MessageUnique = new MessageUniqueWrapper(); \ No newline at end of file diff --git a/src/common/utils/Packet.ts b/src/common/utils/Packet.ts index 087150a5..6fcbe87c 100644 --- a/src/common/utils/Packet.ts +++ b/src/common/utils/Packet.ts @@ -1,14 +1,14 @@ // 方案一 MiniApp发包方案 // 前置条件: 处于GUI环境 存在MiniApp -import { NTQQSystemApi } from "@/core"; +import { NTQQSystemApi } from '@/core'; // 前排提示: 开发验证仅Win平台开展 export class MiniAppUtil { - static async RunMiniAppWithGUI() { - //process.env.ELECTRON_RUN_AS_NODE = undefined;//没用还是得自己用cpp之类的语言写个程序转发参数 - return NTQQSystemApi.BootMiniApp(process.execPath, "miniapp://open/1007?url=https%3A%2F%2Fm.q.qq.com%2Fa%2Fs%2Fedd0a83d3b8afe233dfa07adaaf8033f%3Fscene%3D1007%26min_refer%3D10001"); - } + static async RunMiniAppWithGUI() { + //process.env.ELECTRON_RUN_AS_NODE = undefined;//没用还是得自己用cpp之类的语言写个程序转发参数 + return NTQQSystemApi.BootMiniApp(process.execPath, 'miniapp://open/1007?url=https%3A%2F%2Fm.q.qq.com%2Fa%2Fs%2Fedd0a83d3b8afe233dfa07adaaf8033f%3Fscene%3D1007%26min_refer%3D10001'); + } } // 方案二 MiniApp发包方案 替代MiniApp方案 // 前置条件: 无 diff --git a/src/common/utils/helper.ts b/src/common/utils/helper.ts index ff1fe789..66cb87a6 100644 --- a/src/common/utils/helper.ts +++ b/src/common/utils/helper.ts @@ -264,23 +264,23 @@ export function isEqual(obj1: any, obj2: any) { } export async function deleteOldFiles(directoryPath: string, daysThreshold: number) { - try { - const files = await fsPromise.readdir(directoryPath); + try { + const files = await fsPromise.readdir(directoryPath); - for (const file of files) { - const filePath = path.join(directoryPath, file); - const stats = await fsPromise.stat(filePath); - const lastModifiedTime = stats.mtimeMs; - const currentTime = Date.now(); - const timeDifference = currentTime - lastModifiedTime; - const daysDifference = timeDifference / (1000 * 60 * 60 * 24); + for (const file of files) { + const filePath = path.join(directoryPath, file); + const stats = await fsPromise.stat(filePath); + const lastModifiedTime = stats.mtimeMs; + const currentTime = Date.now(); + const timeDifference = currentTime - lastModifiedTime; + const daysDifference = timeDifference / (1000 * 60 * 60 * 24); - if (daysDifference > daysThreshold) { - await fsPromise.unlink(filePath); // Delete the file - //console.log(`Deleted: ${filePath}`); - } - } - } catch (error) { - //console.error('Error deleting files:', error); + if (daysDifference > daysThreshold) { + await fsPromise.unlink(filePath); // Delete the file + //console.log(`Deleted: ${filePath}`); + } } + } catch (error) { + //console.error('Error deleting files:', error); + } } diff --git a/src/common/utils/request.ts b/src/common/utils/request.ts index d7535147..eeb7b3b6 100644 --- a/src/common/utils/request.ts +++ b/src/common/utils/request.ts @@ -119,7 +119,7 @@ export class RequestUtil { const formDataParts = [ `------${boundary}\r\n`, `Content-Disposition: form-data; name="share_image"; filename="${filePath}"\r\n`, - `Content-Type: ` + type + `\r\n\r\n` + 'Content-Type: ' + type + '\r\n\r\n' ]; const fileContent = readFileSync(filePath); @@ -157,11 +157,10 @@ export class RequestUtil { }); res.on('end', () => { - try { if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { const responseJson = JSON.parse(responseBody) as retType; - resolve(responseJson.result?.url!); + resolve(responseJson.result!.url!); } else { reject(new Error(`Unexpected status code: ${res.statusCode}`)); } diff --git a/src/onebot11/action/extends/CreateCollection.ts b/src/onebot11/action/extends/CreateCollection.ts index 2465ac40..df4245a6 100644 --- a/src/onebot11/action/extends/CreateCollection.ts +++ b/src/onebot11/action/extends/CreateCollection.ts @@ -7,20 +7,20 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { selfInfo } from '@/core/data'; const SchemaData = { - type: 'object', - properties: { - rawData: { type: 'string' }, - brief: { type: 'string' } - }, - required: ['brief', 'rawData'], + type: 'object', + properties: { + rawData: { type: 'string' }, + brief: { type: 'string' } + }, + required: ['brief', 'rawData'], } as const satisfies JSONSchema; type Payload = FromSchema; export class CreateCollection extends BaseAction { - actionName = ActionName.CreateCollection; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - return await NTQQCollectionApi.createCollection(selfInfo.uin, selfInfo.uid, selfInfo.nick, payload.brief, payload.rawData); - } + actionName = ActionName.CreateCollection; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + return await NTQQCollectionApi.createCollection(selfInfo.uin, selfInfo.uid, selfInfo.nick, payload.brief, payload.rawData); + } } diff --git a/src/onebot11/action/extends/GetCollectionList.ts b/src/onebot11/action/extends/GetCollectionList.ts index c45ea23b..b768d555 100644 --- a/src/onebot11/action/extends/GetCollectionList.ts +++ b/src/onebot11/action/extends/GetCollectionList.ts @@ -7,20 +7,20 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { selfInfo } from '@/core/data'; const SchemaData = { - type: 'object', - properties: { - category: { type: 'number' }, - count: { type: 'number' } - }, - required: ['category', 'count'], + type: 'object', + properties: { + category: { type: 'number' }, + count: { type: 'number' } + }, + required: ['category', 'count'], } as const satisfies JSONSchema; type Payload = FromSchema; export class GetCollectionList extends BaseAction { - actionName = ActionName.GetCollectionList; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - return await NTQQCollectionApi.getAllCollection(payload.category, payload.count); - } + actionName = ActionName.GetCollectionList; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + return await NTQQCollectionApi.getAllCollection(payload.category, payload.count); + } } diff --git a/src/onebot11/action/extends/SetLongNick.ts b/src/onebot11/action/extends/SetLongNick.ts index 372f926b..2f1f8c5d 100644 --- a/src/onebot11/action/extends/SetLongNick.ts +++ b/src/onebot11/action/extends/SetLongNick.ts @@ -5,20 +5,20 @@ import { NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { - type: 'object', - properties: { - longNick: { type: 'string' }, - }, - required: [ 'longNick'], + type: 'object', + properties: { + longNick: { type: 'string' }, + }, + required: [ 'longNick'], } as const satisfies JSONSchema; type Payload = FromSchema; export class SetLongNick extends BaseAction { - actionName = ActionName.SetLongNick; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - let ret = await NTQQUserApi.setLongNick(payload.longNick) - return ret; - } + actionName = ActionName.SetLongNick; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + const ret = await NTQQUserApi.setLongNick(payload.longNick); + return ret; + } } diff --git a/src/onebot11/action/extends/SetSelfProfile.ts b/src/onebot11/action/extends/SetSelfProfile.ts index 36789240..5c85e9eb 100644 --- a/src/onebot11/action/extends/SetSelfProfile.ts +++ b/src/onebot11/action/extends/SetSelfProfile.ts @@ -5,28 +5,28 @@ import { NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { - type: 'object', - properties: { - nick: { type: 'string' }, - longNick: { type: 'string' }, - sex: { type: 'number' }//传Sex值?建议传0 - }, - required: ['nick', 'longNick', 'sex'], + type: 'object', + properties: { + nick: { type: 'string' }, + longNick: { type: 'string' }, + sex: { type: 'number' }//传Sex值?建议传0 + }, + required: ['nick', 'longNick', 'sex'], } as const satisfies JSONSchema; type Payload = FromSchema; export class SetSelfProfile extends BaseAction { - actionName = ActionName.SetSelfProfile; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - let ret = await NTQQUserApi.modifySelfProfile({ - nick: payload.nick, - longNick: payload.longNick, - sex: payload.sex, - birthday: { birthday_year: '', birthday_month: '', birthday_day: '' }, - location: undefined - }); - return ret; - } + actionName = ActionName.SetSelfProfile; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + const ret = await NTQQUserApi.modifySelfProfile({ + nick: payload.nick, + longNick: payload.longNick, + sex: payload.sex, + birthday: { birthday_year: '', birthday_month: '', birthday_day: '' }, + location: undefined + }); + return ret; + } } diff --git a/src/onebot11/action/extends/sharePeer.ts b/src/onebot11/action/extends/sharePeer.ts index 716215bb..abb63bff 100644 --- a/src/onebot11/action/extends/sharePeer.ts +++ b/src/onebot11/action/extends/sharePeer.ts @@ -5,41 +5,41 @@ import { BuddyCategoryType } from '@/core/entities/'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { - type: 'object', - properties: { - user_id: { type: 'string' }, - group_id: { type: 'string' }, - phoneNumber: { type: 'string' }, - }, + type: 'object', + properties: { + user_id: { type: 'string' }, + group_id: { type: 'string' }, + phoneNumber: { type: 'string' }, + }, } as const satisfies JSONSchema; type Payload = FromSchema; export class sharePeer extends BaseAction { - actionName = ActionName.SharePeer; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - if (payload.group_id) { - return await NTQQGroupApi.getGroupRecommendContactArkJson(payload.group_id); - } else if (payload.user_id) { - return await NTQQUserApi.getBuddyRecommendContactArkJson(payload.user_id, payload.phoneNumber || ''); - } + actionName = ActionName.SharePeer; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + if (payload.group_id) { + return await NTQQGroupApi.getGroupRecommendContactArkJson(payload.group_id); + } else if (payload.user_id) { + return await NTQQUserApi.getBuddyRecommendContactArkJson(payload.user_id, payload.phoneNumber || ''); } + } } const SchemaDataGroupEx = { - type: 'object', - properties: { - group_id: { type: 'string' }, - }, - required: ['group_id'] + type: 'object', + properties: { + group_id: { type: 'string' }, + }, + required: ['group_id'] } as const satisfies JSONSchema; type PayloadGroupEx = FromSchema; export class shareGroupEx extends BaseAction { - actionName = ActionName.ShareGroupEx; - PayloadSchema = SchemaDataGroupEx; - protected async _handle(payload: PayloadGroupEx) { - return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id); - } + actionName = ActionName.ShareGroupEx; + PayloadSchema = SchemaDataGroupEx; + protected async _handle(payload: PayloadGroupEx) { + return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id); + } } \ No newline at end of file diff --git a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts index f4576624..fb61be65 100644 --- a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts @@ -21,10 +21,10 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction { const user_id = payload.user_id.toString(); - let extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id); - let uid = (await NTQQUserApi.getUidByUin(user_id))!; + const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id); + const uid = (await NTQQUserApi.getUidByUin(user_id))!; if (!uid || uid.indexOf('*') != -1) { - let ret = { + const ret = { ...extendData, user_id: parseInt(extendData.info.uin) || 0, nickname: extendData.info.nick, @@ -34,10 +34,10 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction { if (!member) { throw `群成员${payload.user_id}不存在`; } - let rejectReq = payload.reject_add_request?.toString() == 'true'; + const rejectReq = payload.reject_add_request?.toString() == 'true'; await NTQQGroupApi.kickMember(payload.group_id.toString(), [member.uid], rejectReq); return null; } diff --git a/src/onebot11/action/msg/SendMsg/create-send-elements.ts b/src/onebot11/action/msg/SendMsg/create-send-elements.ts index bfca7171..1c09da86 100644 --- a/src/onebot11/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot11/action/msg/SendMsg/create-send-elements.ts @@ -134,7 +134,7 @@ const _handlers: { const uri2LocalRes = await uri2local(thumb); if (uri2LocalRes.success) thumb = uri2LocalRes.path; } - let videoEle = await SendMsgElementConstructor.video(path, fileName, thumb); + const videoEle = await SendMsgElementConstructor.video(path, fileName, thumb); //未测试 context.deleteAfterSentFiles.push(videoEle.videoElement.filePath); return videoEle; diff --git a/src/onebot11/action/msg/SendMsg/index.ts b/src/onebot11/action/msg/SendMsg/index.ts index dd253d80..9a5bcb7f 100644 --- a/src/onebot11/action/msg/SendMsg/index.ts +++ b/src/onebot11/action/msg/SendMsg/index.ts @@ -120,11 +120,11 @@ export class SendMsg extends BaseAction { return { valid: false, message: `群${payload.group_id}不存在` }; } if (payload.user_id && payload.message_type !== 'group') { - let uid = await NTQQUserApi.getUidByUin(payload.user_id) - let isBuddy = await NTQQFriendApi.isBuddy(uid!); + const uid = await NTQQUserApi.getUidByUin(payload.user_id); + const isBuddy = await NTQQFriendApi.isBuddy(uid!); // 此处有问题 if (!isBuddy) { - //return { valid: false, message: '异常消息' }; + //return { valid: false, message: '异常消息' }; } } return { valid: true }; diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index b53ad3ca..76b32493 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -90,8 +90,8 @@ export enum ActionName { GetOnlineClient = 'get_online_clients', OCRImage = 'ocr_image', IOCRImage = '.ocr_image', - SetSelfProfile = "set_self_profile", - CreateCollection = "create_collection", - GetCollectionList = "get_collection_list", - SetLongNick = "set_self_longnick" + SetSelfProfile = 'set_self_profile', + CreateCollection = 'create_collection', + GetCollectionList = 'get_collection_list', + SetLongNick = 'set_self_longnick' } diff --git a/src/onebot11/action/user/SendLike.ts b/src/onebot11/action/user/SendLike.ts index be88d6d5..a3197523 100644 --- a/src/onebot11/action/user/SendLike.ts +++ b/src/onebot11/action/user/SendLike.ts @@ -21,7 +21,7 @@ export default class SendLike extends BaseAction { //logDebug('点赞参数', payload); try { const qq = payload.user_id.toString(); - let uid: string = await NTQQUserApi.getUidByUin(qq) || ''; + const uid: string = await NTQQUserApi.getUidByUin(qq) || ''; const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1); //logDebug('点赞结果', result); if (result.result !== 0) { diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index d6475224..9ff08c66 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -80,7 +80,7 @@ export class OB11Constructor { } else if (msg.chatType == ChatType.friend) { resMsg.sub_type = 'friend'; - let user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!); + const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!); resMsg.sender.nickname = user.info.nick; } else if (msg.chatType == ChatType.temp) { @@ -191,7 +191,7 @@ export class OB11Constructor { else if (element.videoElement || element.fileElement) { const videoOrFileElement = element.videoElement || element.fileElement; const ob11MessageDataType = element.videoElement ? OB11MessageDataType.video : OB11MessageDataType.file; - let videoDownUrl = element.videoElement ? await NTQQFileApi.getVideoUrl(msg, element) : videoOrFileElement.filePath; + const videoDownUrl = element.videoElement ? await NTQQFileApi.getVideoUrl(msg, element) : videoOrFileElement.filePath; message_data['type'] = ob11MessageDataType; message_data['data']['file'] = videoOrFileElement.fileName; message_data['data']['path'] = videoDownUrl; diff --git a/src/onebot11/main.ts b/src/onebot11/main.ts index fc533457..4c280e27 100644 --- a/src/onebot11/main.ts +++ b/src/onebot11/main.ts @@ -37,7 +37,7 @@ import { Data as SysData } from '@/proto/SysMessage'; import { Data as DeviceData } from '@/proto/SysMessage.DeviceChange'; import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'; import { isEqual } from '@/common/utils/helper'; -import { MiniAppUtil } from '@/common/utils/Packet' +import { MiniAppUtil } from '@/common/utils/Packet'; import { RequestUtil } from '@/common/utils/request'; //下面几个其实应该移进Core-Data 缓存实现 但是现在在这里方便 @@ -115,9 +115,7 @@ export class NapCatOnebot11 { // }; try { // 生产环境会自己去掉 - if (import.meta.env.MODE == 'development') { - logDebug(buf2hex(Buffer.from(protobufData))); - } + const hex = buf2hex(Buffer.from(protobufData)); const sysMsg = SysData.fromBinary(Buffer.from(protobufData)); const peeruin = sysMsg.header[0].peerNumber; const peeruid = sysMsg.header[0].peerString; @@ -126,27 +124,29 @@ export class NapCatOnebot11 { const subType1 = sysMsg.body[0].subType1; let pokeEvent: OB11FriendPokeEvent | OB11GroupPokeEvent; //console.log(peeruid); - if (MsgType == 528 && subType0 == 290) { + if (MsgType == 528 && subType0 == 290 && hex.length < 250 && hex.endsWith('04')) { // 防止上报两次 私聊戳一戳 if (PokeCache.has(peeruid)) { - PokeCache.delete(peeruid); - } else { - PokeCache.set(peeruid, false); log('[私聊] 用户 ', peeruin, ' 对你戳一戳'); pokeEvent = new OB11FriendPokeEvent(peeruin); postOB11Event(pokeEvent); } + PokeCache.set(peeruid, false); + setTimeout(() => { + PokeCache.delete(peeruid); + }, 1000); } - if (MsgType == 732 && subType0 == 20) { + if (MsgType == 732 && subType0 == 20 && hex.length < 150 && hex.endsWith('04')) { // 防止上报两次 群聊戳一戳 if (PokeCache.has(peeruid)) { - PokeCache.delete(peeruid); - } else { - PokeCache.set(peeruid, false); log('[群聊] 群组 ', peeruin, ' 戳一戳'); pokeEvent = new OB11GroupPokeEvent(peeruin); postOB11Event(pokeEvent); } + PokeCache.set(peeruid, false); + setTimeout(() => { + PokeCache.delete(peeruid); + }, 1000); } if (MsgType == 528 && subType0 == 349) { const sysDeviceMsg = DeviceData.fromBinary(Buffer.from(protobufData)); @@ -475,7 +475,7 @@ export class NapCatOnebot11 { logDebug('收到邀请我加群通知'); const groupInviteEvent = new OB11GroupRequestEvent(); groupInviteEvent.group_id = parseInt(notify.group.groupCode); - let user_id = (await NTQQUserApi.getUinByUid(notify.user2.uid)) || ''; + const user_id = (await NTQQUserApi.getUinByUid(notify.user2.uid)) || ''; groupInviteEvent.user_id = parseInt(user_id); groupInviteEvent.sub_type = 'invite'; groupInviteEvent.flag = flag; @@ -531,7 +531,7 @@ export class NapCatOnebot11 { } catch (e) { logDebug('获取加好友者QQ号失败', e); } - friendRequestEvent.flag = req.friendUid + "|" + req.reqTime; + friendRequestEvent.flag = req.friendUid + '|' + req.reqTime; friendRequestEvent.comment = req.extWords; postOB11Event(friendRequestEvent); }