diff --git a/src/common/utils/upgrade.ts b/src/common/utils/upgrade.ts index 79c4323..d295b7c 100644 --- a/src/common/utils/upgrade.ts +++ b/src/common/utils/upgrade.ts @@ -14,7 +14,7 @@ export async function checkNewVersion() { //log('llonebot last version', latestVersion) const currentVersion: string[] = version.split('.') //log('llonebot current version', currentVersion) - for (let k of [0, 1, 2]) { + for (const k of [0, 1, 2]) { if (parseInt(latestVersion[k]) > parseInt(currentVersion[k])) { log('') return { result: true, version: latestVersionText } @@ -47,14 +47,14 @@ export async function upgradeLLOneBot() { return false } const temp_ver_dir = path.join(TEMP_DIR, 'LLOneBot' + latestVersion) - let uncompressedPromise = async function () { - return new Promise((resolve, reject) => { + const uncompressedPromise = async function () { + return new Promise(resolve => { compressing.zip .uncompress(filePath, temp_ver_dir) .then(() => { resolve(true) }) - .catch((reason: any) => { + .catch(reason => { log('llonebot upgrade failed, ', reason) if (reason?.errno == -4082) { resolve(true) @@ -75,8 +75,8 @@ export async function upgradeLLOneBot() { export async function getRemoteVersion() { let Version = '' for (let i = 0; i < checkVersionMirrorHosts.length; i++) { - let mirrorGithub = checkVersionMirrorHosts[i] - let tVersion = await getRemoteVersionByMirror(mirrorGithub) + const mirrorGithub = checkVersionMirrorHosts[i] + const tVersion = await getRemoteVersionByMirror(mirrorGithub) if (tVersion && tVersion != '') { Version = tVersion break diff --git a/src/ntqqapi/api/window.ts b/src/ntqqapi/api/window.ts index 0d4bc1f..0c0f742 100644 --- a/src/ntqqapi/api/window.ts +++ b/src/ntqqapi/api/window.ts @@ -38,7 +38,7 @@ export class NTQQWindowApi extends Service { // 打开窗口并获取对应的下发事件 async openWindow( ntQQWindow: NTQQWindow, - args: any[], + args: unknown[], cbCmd: ReceiveCmd | undefined, autoCloseSeconds: number = 2, ) { diff --git a/src/ntqqapi/helper/rkey.ts b/src/ntqqapi/helper/rkey.ts index 404fa5a..9b63a5e 100644 --- a/src/ntqqapi/helper/rkey.ts +++ b/src/ntqqapi/helper/rkey.ts @@ -35,7 +35,7 @@ export class RkeyManager { return now > this.rkeyData.expired_time } - async refreshRkey(): Promise { + async refreshRkey() { //刷新rkey this.rkeyData = await this.fetchServerRkey() } diff --git a/src/ntqqapi/services/NodeIKernelBuddyService.ts b/src/ntqqapi/services/NodeIKernelBuddyService.ts index 23ff628..eb596e4 100644 --- a/src/ntqqapi/services/NodeIKernelBuddyService.ts +++ b/src/ntqqapi/services/NodeIKernelBuddyService.ts @@ -29,7 +29,7 @@ export interface NodeIKernelBuddyService { buddyUids: Array//Uids }>> - addKernelBuddyListener(listener: any): number + addKernelBuddyListener(listener: unknown): number getAllBuddyCount(): number diff --git a/src/ntqqapi/services/NodeIKernelProfileService.ts b/src/ntqqapi/services/NodeIKernelProfileService.ts index 021e1b4..f1003ed 100644 --- a/src/ntqqapi/services/NodeIKernelProfileService.ts +++ b/src/ntqqapi/services/NodeIKernelProfileService.ts @@ -33,7 +33,7 @@ export interface NodeIKernelProfileService { fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise - addKernelProfileListener(listener: any): number + addKernelProfileListener(listener: unknown): number removeKernelProfileListener(listenerId: number): void @@ -64,7 +64,7 @@ export interface NodeIKernelProfileService { modifySelfProfile(...args: unknown[]): Promise - modifyDesktopMiniProfile(param: any): Promise + modifyDesktopMiniProfile(param: unknown): Promise setNickName(NickName: string): Promise @@ -82,9 +82,9 @@ export interface NodeIKernelProfileService { getUserDetailInfo(uid: string): Promise - getUserDetailInfoWithBizInfo(uid: string, Biz: any[]): Promise + getUserDetailInfoWithBizInfo(uid: string, Biz: unknown[]): Promise - getUserDetailInfoByUin(uin: string): Promise + getUserDetailInfoByUin(uin: string): Promise getZplanAvatarInfos(args: string[]): Promise @@ -99,7 +99,7 @@ export interface NodeIKernelProfileService { getProfileQzonePicInfo(uid: string, type: number, force: boolean): Promise //profileService.getCoreInfo("UserRemarkServiceImpl::getStrangerRemarkByUid", arrayList) - getCoreInfo(name: string, arg: any[]): unknown + getCoreInfo(name: string, arg: unknown[]): unknown //m429253e12.getOtherFlag("FriendListInfoCache_getKernelDataAndPutCache", new ArrayList<>()) isNull(): boolean diff --git a/src/ntqqapi/services/NodeIKernelSearchService.ts b/src/ntqqapi/services/NodeIKernelSearchService.ts index 64cf4c9..3c4b7f1 100644 --- a/src/ntqqapi/services/NodeIKernelSearchService.ts +++ b/src/ntqqapi/services/NodeIKernelSearchService.ts @@ -1,75 +1,75 @@ import { ChatType } from '../types' export interface NodeIKernelSearchService { - addKernelSearchListener(...args: any[]): unknown// needs 1 arguments + addKernelSearchListener(...args: unknown[]): unknown// needs 1 arguments - removeKernelSearchListener(...args: any[]): unknown// needs 1 arguments + removeKernelSearchListener(...args: unknown[]): unknown// needs 1 arguments - searchStranger(...args: any[]): unknown// needs 3 arguments + searchStranger(...args: unknown[]): unknown// needs 3 arguments - searchGroup(...args: any[]): unknown// needs 1 arguments + searchGroup(...args: unknown[]): unknown// needs 1 arguments searchLocalInfo(keywords: string, unknown: number/*4*/): unknown - cancelSearchLocalInfo(...args: any[]): unknown// needs 3 arguments + cancelSearchLocalInfo(...args: unknown[]): unknown// needs 3 arguments - searchBuddyChatInfo(...args: any[]): unknown// needs 2 arguments + searchBuddyChatInfo(...args: unknown[]): unknown// needs 2 arguments - searchMoreBuddyChatInfo(...args: any[]): unknown// needs 1 arguments + searchMoreBuddyChatInfo(...args: unknown[]): unknown// needs 1 arguments - cancelSearchBuddyChatInfo(...args: any[]): unknown// needs 3 arguments + cancelSearchBuddyChatInfo(...args: unknown[]): unknown// needs 3 arguments - searchContact(...args: any[]): unknown// needs 2 arguments + searchContact(...args: unknown[]): unknown// needs 2 arguments - searchMoreContact(...args: any[]): unknown// needs 1 arguments + searchMoreContact(...args: unknown[]): unknown// needs 1 arguments - cancelSearchContact(...args: any[]): unknown// needs 3 arguments + cancelSearchContact(...args: unknown[]): unknown// needs 3 arguments - searchGroupChatInfo(...args: any[]): unknown// needs 3 arguments + searchGroupChatInfo(...args: unknown[]): unknown// needs 3 arguments - resetSearchGroupChatInfoSortType(...args: any[]): unknown// needs 3 arguments + resetSearchGroupChatInfoSortType(...args: unknown[]): unknown// needs 3 arguments - resetSearchGroupChatInfoFilterMembers(...args: any[]): unknown// needs 3 arguments + resetSearchGroupChatInfoFilterMembers(...args: unknown[]): unknown// needs 3 arguments - searchMoreGroupChatInfo(...args: any[]): unknown// needs 1 arguments + searchMoreGroupChatInfo(...args: unknown[]): unknown// needs 1 arguments - cancelSearchGroupChatInfo(...args: any[]): unknown// needs 3 arguments + cancelSearchGroupChatInfo(...args: unknown[]): unknown// needs 3 arguments - searchChatsWithKeywords(...args: any[]): unknown// needs 3 arguments + searchChatsWithKeywords(...args: unknown[]): unknown// needs 3 arguments - searchMoreChatsWithKeywords(...args: any[]): unknown// needs 1 arguments + searchMoreChatsWithKeywords(...args: unknown[]): unknown// needs 1 arguments - cancelSearchChatsWithKeywords(...args: any[]): unknown// needs 3 arguments + cancelSearchChatsWithKeywords(...args: unknown[]): unknown// needs 3 arguments - searchChatMsgs(...args: any[]): unknown// needs 2 arguments + searchChatMsgs(...args: unknown[]): unknown// needs 2 arguments - searchMoreChatMsgs(...args: any[]): unknown// needs 1 arguments + searchMoreChatMsgs(...args: unknown[]): unknown// needs 1 arguments - cancelSearchChatMsgs(...args: any[]): unknown// needs 3 arguments + cancelSearchChatMsgs(...args: unknown[]): unknown// needs 3 arguments - searchMsgWithKeywords(...args: any[]): unknown// needs 2 arguments + searchMsgWithKeywords(...args: unknown[]): unknown// needs 2 arguments - searchMoreMsgWithKeywords(...args: any[]): unknown// needs 1 arguments + searchMoreMsgWithKeywords(...args: unknown[]): unknown// needs 1 arguments - cancelSearchMsgWithKeywords(...args: any[]): unknown// needs 3 arguments + cancelSearchMsgWithKeywords(...args: unknown[]): unknown// needs 3 arguments searchFileWithKeywords(keywords: string[], source: number): Promise// needs 2 arguments - searchMoreFileWithKeywords(...args: any[]): unknown// needs 1 arguments + searchMoreFileWithKeywords(...args: unknown[]): unknown// needs 1 arguments - cancelSearchFileWithKeywords(...args: any[]): unknown// needs 3 arguments + cancelSearchFileWithKeywords(...args: unknown[]): unknown// needs 3 arguments - searchAtMeChats(...args: any[]): unknown// needs 3 arguments + searchAtMeChats(...args: unknown[]): unknown// needs 3 arguments - searchMoreAtMeChats(...args: any[]): unknown// needs 1 arguments + searchMoreAtMeChats(...args: unknown[]): unknown// needs 1 arguments - cancelSearchAtMeChats(...args: any[]): unknown// needs 3 arguments + cancelSearchAtMeChats(...args: unknown[]): unknown// needs 3 arguments - searchChatAtMeMsgs(...args: any[]): unknown// needs 1 arguments + searchChatAtMeMsgs(...args: unknown[]): unknown// needs 1 arguments - searchMoreChatAtMeMsgs(...args: any[]): unknown// needs 1 arguments + searchMoreChatAtMeMsgs(...args: unknown[]): unknown// needs 1 arguments - cancelSearchChatAtMeMsgs(...args: any[]): unknown// needs 3 arguments + cancelSearchChatAtMeMsgs(...args: unknown[]): unknown// needs 3 arguments addSearchHistory(param: { type: number,//4 @@ -120,9 +120,9 @@ export interface NodeIKernelSearchService { id?: number }> - removeSearchHistory(...args: any[]): unknown// needs 1 arguments + removeSearchHistory(...args: unknown[]): unknown// needs 1 arguments - searchCache(...args: any[]): unknown// needs 3 arguments + searchCache(...args: unknown[]): unknown// needs 3 arguments - clearSearchCache(...args: any[]): unknown// needs 1 arguments + clearSearchCache(...args: unknown[]): unknown// needs 1 arguments } \ No newline at end of file diff --git a/src/onebot11/action/BaseAction.ts b/src/onebot11/action/BaseAction.ts index bee248e..86e2a71 100644 --- a/src/onebot11/action/BaseAction.ts +++ b/src/onebot11/action/BaseAction.ts @@ -26,13 +26,13 @@ abstract class BaseAction { try { const resData = await this._handle(payload) return OB11Response.ok(resData) - } catch (e: any) { + } catch (e) { this.ctx.logger.error('发生错误', e) - return OB11Response.error(e?.toString() || e?.stack?.toString() || '未知错误,可能操作超时', 200) + return OB11Response.error(e?.toString() || (e as Error)?.stack?.toString() || '未知错误,可能操作超时', 200) } } - public async websocketHandle(payload: PayloadType, echo: any): Promise> { + public async websocketHandle(payload: PayloadType, echo: unknown): Promise> { const result = await this.check(payload) if (!result.valid) { return OB11Response.error(result.message, 1400) @@ -40,9 +40,9 @@ abstract class BaseAction { try { const resData = await this._handle(payload) return OB11Response.ok(resData, echo) - } catch (e: any) { + } catch (e) { this.ctx.logger.error('发生错误', e) - return OB11Response.error(e.stack?.toString() || e.toString(), 1200, echo) + return OB11Response.error((e as Error)?.stack?.toString() || String(e), 1200, echo) } } diff --git a/src/onebot11/action/OB11Response.ts b/src/onebot11/action/OB11Response.ts index bc74400..b86d4e7 100644 --- a/src/onebot11/action/OB11Response.ts +++ b/src/onebot11/action/OB11Response.ts @@ -13,16 +13,16 @@ export class OB11Response { } } - static ok(data: T, echo: any = null) { - let res = OB11Response.res(data, 'ok', 0) + static ok(data: T, echo?: unknown) { + const res = OB11Response.res(data, 'ok', 0) if (!isNullable(echo)) { res.echo = echo } return res } - static error(err: string, retcode: number, echo: any = null) { - let res = OB11Response.res(null, 'failed', retcode, err) + static error(err: string, retcode: number, echo?: unknown) { + const res = OB11Response.res(null, 'failed', retcode, err) if (!isNullable(echo)) { res.echo = echo } diff --git a/src/onebot11/action/file/GetRecord.ts b/src/onebot11/action/file/GetRecord.ts index 5c9745f..48e765f 100644 --- a/src/onebot11/action/file/GetRecord.ts +++ b/src/onebot11/action/file/GetRecord.ts @@ -12,7 +12,7 @@ export default class GetRecord extends GetFileBase { actionName = ActionName.GetRecord protected async _handle(payload: Payload): Promise { - let res = await super._handle(payload) + const res = await super._handle(payload) res.file = await decodeSilk(this.ctx, res.file!, payload.out_format) res.file_name = path.basename(res.file) res.file_size = fs.statSync(res.file).size.toString() diff --git a/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts b/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts index db5e7da..711689b 100644 --- a/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts +++ b/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts @@ -6,10 +6,10 @@ interface Payload { message_id: number | string } -export class DelEssenceMsg extends BaseAction { - actionName = ActionName.GoCQHTTP_DelEssenceMsg; +export class DelEssenceMsg extends BaseAction { + actionName = ActionName.GoCQHTTP_DelEssenceMsg - protected async _handle(payload: Payload): Promise { + protected async _handle(payload: Payload) { if (!payload.message_id) { throw Error('message_id不能为空') } diff --git a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts index d8a728c..bc7511d 100644 --- a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts +++ b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts @@ -1,5 +1,5 @@ import BaseAction from '../BaseAction' -import { OB11ForwardMessage, OB11Message, OB11MessageData } from '../../types' +import { OB11ForwardMessage } from '../../types' import { OB11Entities } from '../../entities' import { ActionName } from '../types' import { MessageUnique } from '@/common/utils/messageUnique' @@ -10,12 +10,12 @@ interface Payload { } interface Response { - messages: (OB11Message & { content: OB11MessageData })[] + messages: OB11ForwardMessage[] } export class GetForwardMsg extends BaseAction { actionName = ActionName.GoCQHTTP_GetForwardMsg - protected async _handle(payload: Payload): Promise { + protected async _handle(payload: Payload) { const msgId = payload.id || payload.message_id if (!msgId) { throw Error('message_id不能为空') @@ -36,15 +36,16 @@ export class GetForwardMsg extends BaseAction { resMsg.message_id = MessageUnique.createMsg({ chatType: msg.chatType, peerUid: msg.peerUid, - }, msg.msgId)! + }, msg.msgId) return resMsg }), ) - messages.map(v => { + const forwardMessages = messages.map(v => { const msg = v as Partial msg.content = msg.message delete msg.message + return msg as OB11ForwardMessage }) - return { messages } + return { messages: forwardMessages } } } diff --git a/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts b/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts index 7b6de96..ecf8c2c 100644 --- a/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts +++ b/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts @@ -27,7 +27,7 @@ interface Response { export class GetGroupSystemMsg extends BaseAction { actionName = ActionName.GoCQHTTP_GetGroupSystemMsg - async _handle(payload: void) { + async _handle() { const singleScreenNotifies = await this.ctx.ntGroupApi.getSingleScreenNotifies(10) const data: Response = { invited_requests: [], join_requests: [] } for (const notify of singleScreenNotifies) { diff --git a/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts b/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts index d3c1fef..bfe562b 100644 --- a/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts +++ b/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts @@ -6,10 +6,10 @@ interface Payload { message_id: number | string } -export class SetEssenceMsg extends BaseAction { - actionName = ActionName.GoCQHTTP_SetEssenceMsg; +export class SetEssenceMsg extends BaseAction { + actionName = ActionName.GoCQHTTP_SetEssenceMsg - protected async _handle(payload: Payload): Promise { + protected async _handle(payload: Payload) { if (!payload.message_id) { throw Error('message_id不能为空') } diff --git a/src/onebot11/action/group/GetGroupEssence.ts b/src/onebot11/action/group/GetGroupEssence.ts index b455c79..8953e97 100644 --- a/src/onebot11/action/group/GetGroupEssence.ts +++ b/src/onebot11/action/group/GetGroupEssence.ts @@ -10,7 +10,7 @@ interface PayloadType { export class GetGroupEssence extends BaseAction { actionName = ActionName.GoCQHTTP_GetEssenceMsg - protected async _handle(payload: PayloadType) { + protected async _handle() { throw '此 api 暂不支持' } } diff --git a/src/onebot11/action/group/GetGroupHonorInfo.ts b/src/onebot11/action/group/GetGroupHonorInfo.ts index a57560a..4fd781e 100644 --- a/src/onebot11/action/group/GetGroupHonorInfo.ts +++ b/src/onebot11/action/group/GetGroupHonorInfo.ts @@ -7,11 +7,10 @@ interface Payload { type?: WebHonorType } -export class GetGroupHonorInfo extends BaseAction> { +export class GetGroupHonorInfo extends BaseAction { actionName = ActionName.GetGroupHonorInfo protected async _handle(payload: Payload) { - // console.log(await NTQQUserApi.getRobotUinRange()) if (!payload.group_id) { throw '缺少参数group_id' } diff --git a/src/onebot11/action/llonebot/Debug.ts b/src/onebot11/action/llonebot/Debug.ts index ce89430..0bca979 100644 --- a/src/onebot11/action/llonebot/Debug.ts +++ b/src/onebot11/action/llonebot/Debug.ts @@ -3,13 +3,13 @@ import { ActionName } from '../types' interface Payload { method: string - args: any[] + args: unknown[] } -export default class Debug extends BaseAction { +export default class Debug extends BaseAction { actionName = ActionName.Debug - protected async _handle(payload: Payload): Promise { + protected async _handle(payload: Payload) { this.ctx.logger.info('debug call ntqq api', payload) const { ntMsgApi, ntFileApi, ntFileCacheApi, ntFriendApi, ntGroupApi, ntUserApi, ntWindowApi } = this.ctx const ntqqApi = [ntMsgApi, ntFriendApi, ntGroupApi, ntUserApi, ntFileApi, ntFileCacheApi, ntWindowApi] diff --git a/src/onebot11/action/llonebot/GetGroupAddRequest.ts b/src/onebot11/action/llonebot/GetGroupAddRequest.ts index d810f25..33b9988 100644 --- a/src/onebot11/action/llonebot/GetGroupAddRequest.ts +++ b/src/onebot11/action/llonebot/GetGroupAddRequest.ts @@ -11,7 +11,7 @@ interface OB11GroupRequestNotify { export default class GetGroupAddRequest extends BaseAction { actionName = ActionName.GetGroupIgnoreAddRequest - protected async _handle(payload: null): Promise { + protected async _handle(): Promise { const data = await this.ctx.ntGroupApi.getGroupIgnoreNotifies() const notifies: GroupNotify[] = data.notifies.filter((notify) => notify.status === GroupNotifyStatus.KUNHANDLE) const returnData: OB11GroupRequestNotify[] = [] diff --git a/src/onebot11/action/msg/SetMsgEmojiLike.ts b/src/onebot11/action/msg/SetMsgEmojiLike.ts index fad1070..3693d29 100644 --- a/src/onebot11/action/msg/SetMsgEmojiLike.ts +++ b/src/onebot11/action/msg/SetMsgEmojiLike.ts @@ -7,7 +7,7 @@ interface Payload { emoji_id: number | string } -export class SetMsgEmojiLike extends BaseAction { +export class SetMsgEmojiLike extends BaseAction { actionName = ActionName.SetMsgEmojiLike protected async _handle(payload: Payload) { diff --git a/src/onebot11/action/system/GetLoginInfo.ts b/src/onebot11/action/system/GetLoginInfo.ts index 98301d0..5255222 100644 --- a/src/onebot11/action/system/GetLoginInfo.ts +++ b/src/onebot11/action/system/GetLoginInfo.ts @@ -6,7 +6,7 @@ import { selfInfo } from '@/common/globalVars' class GetLoginInfo extends BaseAction { actionName = ActionName.GetLoginInfo - protected async _handle(payload: null) { + protected async _handle() { let nickname = selfInfo.nick try { nickname = await this.ctx.ntUserApi.getSelfNick(true) diff --git a/src/onebot11/action/system/GetStatus.ts b/src/onebot11/action/system/GetStatus.ts index e282ee7..1a3962c 100644 --- a/src/onebot11/action/system/GetStatus.ts +++ b/src/onebot11/action/system/GetStatus.ts @@ -3,10 +3,10 @@ import { OB11Status } from '../../types' import { ActionName } from '../types' import { selfInfo } from '@/common/globalVars' -export default class GetStatus extends BaseAction { +export default class GetStatus extends BaseAction { actionName = ActionName.GetStatus - protected async _handle(payload: any): Promise { + protected async _handle(): Promise { return { online: selfInfo.online!, good: true, diff --git a/src/onebot11/action/user/GetFriendList.ts b/src/onebot11/action/user/GetFriendList.ts index 420a3d6..7c6e632 100644 --- a/src/onebot11/action/user/GetFriendList.ts +++ b/src/onebot11/action/user/GetFriendList.ts @@ -21,10 +21,10 @@ export class GetFriendList extends BaseAction { } // extend -export class GetFriendWithCategory extends BaseAction { +export class GetFriendWithCategory extends BaseAction { actionName = ActionName.GetFriendsWithCategory - protected async _handle(payload: void) { + protected async _handle() { if (getBuildVersion() >= 26702) { //全新逻辑 return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2ExWithCate(true)) diff --git a/src/onebot11/cqcode.ts b/src/onebot11/cqcode.ts index 98774ca..de3da4c 100644 --- a/src/onebot11/cqcode.ts +++ b/src/onebot11/cqcode.ts @@ -10,7 +10,7 @@ function from(source: string) { const capture = pattern.exec(source) if (!capture) return null const [, type, attrs] = capture - const data: Record = {} + const data: Record = {} attrs && attrs .slice(1) @@ -22,7 +22,7 @@ function from(source: string) { return { type, data, capture } } -function h(type: string, data: any) { +function h(type: string, data: unknown) { return { type, data, @@ -30,7 +30,7 @@ function h(type: string, data: any) { } export function decodeCQCode(source: string): OB11MessageData[] { - const elements: any[] = [] + const elements: unknown[] = [] let result: ReturnType while ((result = from(source))) { const { type, data, capture } = result @@ -41,7 +41,7 @@ export function decodeCQCode(source: string): OB11MessageData[] { source = source.slice(capture.index + capture[0].length) } if (source) elements.push(h('text', { text: unescape(source) })) - return elements + return elements as OB11MessageData[] } export function encodeCQCode(input: OB11MessageData) { diff --git a/src/onebot11/entities.ts b/src/onebot11/entities.ts index 9840d4b..6cf8930 100644 --- a/src/onebot11/entities.ts +++ b/src/onebot11/entities.ts @@ -597,8 +597,8 @@ export namespace OB11Entities { if (poke_uid.length == 2) { return new OB11GroupPokeEvent( parseInt(msg.peerUid), - parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[0].uid)), - parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[1].uid)), + parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[0].uid) ?? 0), + parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[1].uid) ?? 0), pokedetail ) } diff --git a/src/onebot11/event/notice/OB11PokeEvent.ts b/src/onebot11/event/notice/OB11PokeEvent.ts index be9da90..44390c0 100644 --- a/src/onebot11/event/notice/OB11PokeEvent.ts +++ b/src/onebot11/event/notice/OB11PokeEvent.ts @@ -5,14 +5,13 @@ abstract class OB11PokeEvent extends OB11BaseNoticeEvent { sub_type = 'poke' target_id = 0 abstract user_id: number - raw_message: any } export class OB11FriendPokeEvent extends OB11PokeEvent { user_id: number - raw_info: any + raw_info: unknown - constructor(user_id: number, target_id: number, raw_message: any) { + constructor(user_id: number, target_id: number, raw_message: unknown) { super() this.target_id = target_id this.user_id = user_id @@ -24,9 +23,9 @@ export class OB11FriendPokeEvent extends OB11PokeEvent { export class OB11GroupPokeEvent extends OB11PokeEvent { user_id: number group_id: number - raw_info: any + raw_info: unknown - constructor(group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) { + constructor(group_id: number, user_id: number, target_id: number, raw_message: unknown) { super() this.group_id = group_id this.target_id = target_id diff --git a/src/preload.ts b/src/preload.ts index 9fda898..1f34204 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -14,7 +14,7 @@ const { contextBridge } = require('electron') const { ipcRenderer } = require('electron') const llonebot = { - log: (data: any) => { + log: (data: unknown) => { ipcRenderer.send(CHANNEL_LOG, data) }, checkVersion: async (): Promise => { diff --git a/src/renderer/components/select.ts b/src/renderer/components/select.ts index 344264b..996ca07 100644 --- a/src/renderer/components/select.ts +++ b/src/renderer/components/select.ts @@ -32,14 +32,14 @@ window.customElements.define( this.attachShadow({ mode: 'open' }) this.shadowRoot?.append(SelectTemplate.content.cloneNode(true)) - this._button = this.shadowRoot?.querySelector('div[part="button"]')! - this._text = this.shadowRoot?.querySelector('input[part="current-text"]')! - this._context = this.shadowRoot?.querySelector('ul[part="option-list"]')! + this._button = this.shadowRoot?.querySelector('div[part="button"]') as HTMLDivElement + this._text = this.shadowRoot?.querySelector('input[part="current-text"]') as HTMLInputElement + this._context = this.shadowRoot?.querySelector('ul[part="option-list"]') as HTMLUListElement const buttonClick = () => { const isHidden = this._context.classList.toggle('hidden') window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', ({ target }) => { - if (!this.contains(target as any)) buttonClick() + if (!this.contains(target as Node)) buttonClick() }) } @@ -67,12 +67,12 @@ window.customElements.define( ) }) - this._text.value = this.querySelector('setting-option[is-selected]')?.textContent! + this._text.value = this.querySelector('setting-option[is-selected]')?.textContent as string } }, ) -export const SettingSelect = (items: Array<{ text: string; value: string }>, configKey?: string, configValue?: any) => { +export const SettingSelect = (items: Array<{ text: string; value: string }>, configKey?: string, configValue?: unknown) => { return ` ${items .map((e, i) => {