diff --git a/src/common/fall-back.ts b/src/common/fall-back.ts index 52021b3a1..4cd85cd0e 100644 --- a/src/common/fall-back.ts +++ b/src/common/fall-back.ts @@ -20,7 +20,7 @@ export class Fallback { for (const handler of this.handlers) { try { const result = await handler(); - let data = await this.checker(result); + const data = await this.checker(result); if (data) { return data; } diff --git a/src/onebot/action/group/GetGroupMemberInfo.ts b/src/onebot/action/group/GetGroupMemberInfo.ts index 28525bac8..408a51cef 100644 --- a/src/onebot/action/group/GetGroupMemberInfo.ts +++ b/src/onebot/action/group/GetGroupMemberInfo.ts @@ -28,7 +28,7 @@ class GetGroupMemberInfo extends OneBotAction { private async getGroupMemberInfo(payload: Payload, uid: string, isNocache: boolean) { const groupMemberCache = this.core.apis.GroupApi.groupMemberCache.get(payload.group_id.toString()); - let groupMember = groupMemberCache?.get(uid); + const groupMember = groupMemberCache?.get(uid); const [member, info] = await Promise.all([ this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, isNocache), diff --git a/src/onebot/action/group/SetGroupAddRequest.ts b/src/onebot/action/group/SetGroupAddRequest.ts index 3e49d9647..a06be36e4 100644 --- a/src/onebot/action/group/SetGroupAddRequest.ts +++ b/src/onebot/action/group/SetGroupAddRequest.ts @@ -19,7 +19,7 @@ export default class SetGroupAddRequest extends OneBotAction { const flag = payload.flag.toString(); const approve = payload.approve?.toString() !== 'false'; const reason = payload.reason ?? ' '; - let invite_notify = this.obContext.apis.MsgApi.notifyGroupInvite.get(flag); + const invite_notify = this.obContext.apis.MsgApi.notifyGroupInvite.get(flag); const notify = invite_notify ?? await this.findNotify(flag); if (!notify) { throw new Error('No such request'); diff --git a/src/onebot/api/group.ts b/src/onebot/api/group.ts index 5a57f68e7..f9782839c 100644 --- a/src/onebot/api/group.ts +++ b/src/onebot/api/group.ts @@ -218,7 +218,7 @@ export class OneBotGroupApi { element.groupName, ); } else if (element.type === TipGroupElementType.KSHUTUP) { - let event = await this.parseGroupBanEvent(msg.peerUid, elementWrapper); + const event = await this.parseGroupBanEvent(msg.peerUid, elementWrapper); return event; } else if (element.type === TipGroupElementType.KMEMBERADD) { // 自己的通知 协议推送为type->85 在这里实现为了避免邀请出现问题 diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index 18df4d558..434479474 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -206,7 +206,7 @@ export class OneBotMsgApi { const dir = emojiId.substring(0, 2); const url = `https://gxh.vip.qq.com/club/item/parcel/item/${dir}/${emojiId}/raw300.gif`; const filename = `${dir}-${emojiId}.gif`; - FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "", filename) + FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "", filename); return { type: OB11MessageDataType.image, data: { @@ -798,7 +798,7 @@ export class OneBotMsgApi { private async handlePrivateMessage(resMsg: OB11Message, msg: RawMessage) { resMsg.sub_type = 'friend'; if (await this.core.apis.FriendApi.isBuddy(msg.senderUid)) { - let nickname = (await this.core.apis.UserApi.getCoreAndBaseInfo([msg.senderUid])).get(msg.senderUid)?.coreInfo.nick; + const nickname = (await this.core.apis.UserApi.getCoreAndBaseInfo([msg.senderUid])).get(msg.senderUid)?.coreInfo.nick; if (nickname) { resMsg.sender.nickname = nickname; return; @@ -906,16 +906,16 @@ export class OneBotMsgApi { const calculateTotalSize = async (elements: SendMessageElement[]): Promise => { const sizePromises = elements.map(async element => { switch (element.elementType) { - case ElementType.PTT: - return (await fsPromise.stat(element.pttElement.filePath)).size; - case ElementType.FILE: - return (await fsPromise.stat(element.fileElement.filePath)).size; - case ElementType.VIDEO: - return (await fsPromise.stat(element.videoElement.filePath)).size; - case ElementType.PIC: - return (await fsPromise.stat(element.picElement.sourcePath)).size; - default: - return 0; + case ElementType.PTT: + return (await fsPromise.stat(element.pttElement.filePath)).size; + case ElementType.FILE: + return (await fsPromise.stat(element.fileElement.filePath)).size; + case ElementType.VIDEO: + return (await fsPromise.stat(element.videoElement.filePath)).size; + case ElementType.PIC: + return (await fsPromise.stat(element.picElement.sourcePath)).size; + default: + return 0; } }); const sizes = await Promise.all(sizePromises); @@ -982,20 +982,20 @@ export class OneBotMsgApi { groupChangDecreseType2String(type: number): GroupDecreaseSubType { switch (type) { - case 130: - return 'leave'; - case 131: - return 'kick'; - case 3: - return 'kick_me'; - default: - return 'kick'; + case 130: + return 'leave'; + case 131: + return 'kick'; + case 3: + return 'kick_me'; + default: + return 'kick'; } } async waitGroupNotify(groupUin: string, memberUid?: string, operatorUid?: string) { - let groupRole = this.core.apis.GroupApi.groupMemberCache.get(groupUin)?.get(this.core.selfInfo.uid.toString())?.role; - let isAdminOrOwner = groupRole === 3 || groupRole === 4; + const groupRole = this.core.apis.GroupApi.groupMemberCache.get(groupUin)?.get(this.core.selfInfo.uid.toString())?.role; + const isAdminOrOwner = groupRole === 3 || groupRole === 4; if (isAdminOrOwner && !operatorUid) { let dataNotify: GroupNotify | undefined; @@ -1023,7 +1023,7 @@ export class OneBotMsgApi { if (SysMessage.contentHead.type == 33 && SysMessage.body?.msgContent) { const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent); await this.core.apis.GroupApi.refreshGroupMemberCache(groupChange.groupUin.toString(), true); - let operatorUid = await this.waitGroupNotify( + const operatorUid = await this.waitGroupNotify( groupChange.groupUin.toString(), groupChange.memberUid, groupChange.operatorInfo ? Buffer.from(groupChange.operatorInfo).toString() : '' @@ -1039,7 +1039,7 @@ export class OneBotMsgApi { } else if (SysMessage.contentHead.type == 34 && SysMessage.body?.msgContent) { const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent); // 自身被踢出时operatorInfo会是一个protobuf 否则大多数情况为一个string - let operatorUid = await this.waitGroupNotify( + const operatorUid = await this.waitGroupNotify( groupChange.groupUin.toString(), groupChange.memberUid, groupChange.decreaseType === 3 && groupChange.operatorInfo ? @@ -1080,17 +1080,17 @@ export class OneBotMsgApi { enabled ? 'set' : 'unset' ); } else if (SysMessage.contentHead.type == 87 && SysMessage.body?.msgContent) { - let groupInvite = new NapProtoMsg(GroupInvite).decode(SysMessage.body.msgContent); + const groupInvite = new NapProtoMsg(GroupInvite).decode(SysMessage.body.msgContent); let request_seq = ''; try { await this.core.eventWrapper.registerListen('NodeIKernelMsgListener/onRecvMsg', (msgs) => { for (const msg of msgs) { if (msg.senderUid === groupInvite.invitorUid && msg.msgType === 11) { - let jumpUrl = JSON.parse(msg.elements.find(e => e.elementType === 10)?.arkElement?.bytesData ?? '').meta?.news?.jumpUrl; - let jumpUrlParams = new URLSearchParams(jumpUrl); - let groupcode = jumpUrlParams.get('groupcode'); - let receiveruin = jumpUrlParams.get('receiveruin'); - let msgseq = jumpUrlParams.get('msgseq'); + const jumpUrl = JSON.parse(msg.elements.find(e => e.elementType === 10)?.arkElement?.bytesData ?? '').meta?.news?.jumpUrl; + const jumpUrlParams = new URLSearchParams(jumpUrl); + const groupcode = jumpUrlParams.get('groupcode'); + const receiveruin = jumpUrlParams.get('receiveruin'); + const msgseq = jumpUrlParams.get('msgseq'); request_seq = msgseq ?? ''; if (groupcode === groupInvite.groupUin.toString() && receiveruin === this.core.selfInfo.uin) { return true; @@ -1136,7 +1136,7 @@ export class OneBotMsgApi { waitStatus: 1, }, status: 1 - }) + }); return new OB11GroupRequestEvent( this.core, +groupInvite.groupUin, diff --git a/src/onebot/api/quick-action.ts b/src/onebot/api/quick-action.ts index 36753789b..da5484bcd 100644 --- a/src/onebot/api/quick-action.ts +++ b/src/onebot/api/quick-action.ts @@ -92,7 +92,7 @@ export class OneBotQuickActionApi { async handleGroupRequest(request: OB11GroupRequestEvent, quickAction: QuickActionGroupRequest) { - let invite_notify = this.obContext.apis.MsgApi.notifyGroupInvite.get(request.flag); + const invite_notify = this.obContext.apis.MsgApi.notifyGroupInvite.get(request.flag); const notify = invite_notify ?? await this.findNotify(request.flag); if (!isNull(quickAction.approve) && notify) { diff --git a/src/shell/base.ts b/src/shell/base.ts index 914a55cd3..7d1a15e86 100644 --- a/src/shell/base.ts +++ b/src/shell/base.ts @@ -222,7 +222,7 @@ async function handleLogin( logger.log(`可用于快速登录的 QQ:\n${historyLoginList .map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`) .join('\n') - }`); + }`); } loginService.getQRCodePicture(); }