mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
chore: improve code quality
chore: improve code quality
This commit is contained in:
parent
3064a6eb7c
commit
970f1a98ec
@ -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<boolean>((resolve, reject) => {
|
||||
const uncompressedPromise = async function () {
|
||||
return new Promise<boolean>(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
|
||||
|
@ -38,7 +38,7 @@ export class NTQQWindowApi extends Service {
|
||||
// 打开窗口并获取对应的下发事件
|
||||
async openWindow<R = GeneralCallResult>(
|
||||
ntQQWindow: NTQQWindow,
|
||||
args: any[],
|
||||
args: unknown[],
|
||||
cbCmd: ReceiveCmd | undefined,
|
||||
autoCloseSeconds: number = 2,
|
||||
) {
|
||||
|
@ -35,7 +35,7 @@ export class RkeyManager {
|
||||
return now > this.rkeyData.expired_time
|
||||
}
|
||||
|
||||
async refreshRkey(): Promise<any> {
|
||||
async refreshRkey() {
|
||||
//刷新rkey
|
||||
this.rkeyData = await this.fetchServerRkey()
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export interface NodeIKernelBuddyService {
|
||||
buddyUids: Array<string>//Uids
|
||||
}>>
|
||||
|
||||
addKernelBuddyListener(listener: any): number
|
||||
addKernelBuddyListener(listener: unknown): number
|
||||
|
||||
getAllBuddyCount(): number
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>
|
||||
|
||||
addKernelProfileListener(listener: any): number
|
||||
addKernelProfileListener(listener: unknown): number
|
||||
|
||||
removeKernelProfileListener(listenerId: number): void
|
||||
|
||||
@ -64,7 +64,7 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
modifySelfProfile(...args: unknown[]): Promise<unknown>
|
||||
|
||||
modifyDesktopMiniProfile(param: any): Promise<GeneralCallResult>
|
||||
modifyDesktopMiniProfile(param: unknown): Promise<GeneralCallResult>
|
||||
|
||||
setNickName(NickName: string): Promise<unknown>
|
||||
|
||||
@ -82,9 +82,9 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
getUserDetailInfo(uid: string): Promise<unknown>
|
||||
|
||||
getUserDetailInfoWithBizInfo(uid: string, Biz: any[]): Promise<GeneralCallResult>
|
||||
getUserDetailInfoWithBizInfo(uid: string, Biz: unknown[]): Promise<GeneralCallResult>
|
||||
|
||||
getUserDetailInfoByUin(uin: string): Promise<any>
|
||||
getUserDetailInfoByUin(uin: string): Promise<unknown>
|
||||
|
||||
getZplanAvatarInfos(args: string[]): Promise<unknown>
|
||||
|
||||
@ -99,7 +99,7 @@ export interface NodeIKernelProfileService {
|
||||
getProfileQzonePicInfo(uid: string, type: number, force: boolean): Promise<unknown>
|
||||
|
||||
//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
|
||||
|
@ -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<string>// 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
|
||||
}
|
@ -26,13 +26,13 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
|
||||
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<OB11Return<ReturnDataType | null>> {
|
||||
public async websocketHandle(payload: PayloadType, echo: unknown): Promise<OB11Return<ReturnDataType | null>> {
|
||||
const result = await this.check(payload)
|
||||
if (!result.valid) {
|
||||
return OB11Response.error(result.message, 1400)
|
||||
@ -40,9 +40,9 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,16 +13,16 @@ export class OB11Response {
|
||||
}
|
||||
}
|
||||
|
||||
static ok<T>(data: T, echo: any = null) {
|
||||
let res = OB11Response.res<T>(data, 'ok', 0)
|
||||
static ok<T>(data: T, echo?: unknown) {
|
||||
const res = OB11Response.res<T>(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
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export default class GetRecord extends GetFileBase {
|
||||
actionName = ActionName.GetRecord
|
||||
|
||||
protected async _handle(payload: Payload): Promise<GetFileResponse> {
|
||||
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()
|
||||
|
@ -6,10 +6,10 @@ interface Payload {
|
||||
message_id: number | string
|
||||
}
|
||||
|
||||
export class DelEssenceMsg extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_DelEssenceMsg;
|
||||
export class DelEssenceMsg extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GoCQHTTP_DelEssenceMsg
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('message_id不能为空')
|
||||
}
|
||||
|
@ -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<Payload, Response> {
|
||||
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
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<Payload, Response> {
|
||||
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<OB11ForwardMessage>
|
||||
msg.content = msg.message
|
||||
delete msg.message
|
||||
return msg as OB11ForwardMessage
|
||||
})
|
||||
return { messages }
|
||||
return { messages: forwardMessages }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ interface Response {
|
||||
export class GetGroupSystemMsg extends BaseAction<void, Response> {
|
||||
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) {
|
||||
|
@ -6,10 +6,10 @@ interface Payload {
|
||||
message_id: number | string
|
||||
}
|
||||
|
||||
export class SetEssenceMsg extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_SetEssenceMsg;
|
||||
export class SetEssenceMsg extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GoCQHTTP_SetEssenceMsg
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('message_id不能为空')
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ interface PayloadType {
|
||||
export class GetGroupEssence extends BaseAction<PayloadType, GroupEssenceMsgRet | void> {
|
||||
actionName = ActionName.GoCQHTTP_GetEssenceMsg
|
||||
|
||||
protected async _handle(payload: PayloadType) {
|
||||
protected async _handle() {
|
||||
throw '此 api 暂不支持'
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,10 @@ interface Payload {
|
||||
type?: WebHonorType
|
||||
}
|
||||
|
||||
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
||||
export class GetGroupHonorInfo extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GetGroupHonorInfo
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange())
|
||||
if (!payload.group_id) {
|
||||
throw '缺少参数group_id'
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
method: string
|
||||
args: any[]
|
||||
args: unknown[]
|
||||
}
|
||||
|
||||
export default class Debug extends BaseAction<Payload, any> {
|
||||
export default class Debug extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.Debug
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
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]
|
||||
|
@ -11,7 +11,7 @@ interface OB11GroupRequestNotify {
|
||||
export default class GetGroupAddRequest extends BaseAction<null, OB11GroupRequestNotify[]> {
|
||||
actionName = ActionName.GetGroupIgnoreAddRequest
|
||||
|
||||
protected async _handle(payload: null): Promise<OB11GroupRequestNotify[]> {
|
||||
protected async _handle(): Promise<OB11GroupRequestNotify[]> {
|
||||
const data = await this.ctx.ntGroupApi.getGroupIgnoreNotifies()
|
||||
const notifies: GroupNotify[] = data.notifies.filter((notify) => notify.status === GroupNotifyStatus.KUNHANDLE)
|
||||
const returnData: OB11GroupRequestNotify[] = []
|
||||
|
@ -7,7 +7,7 @@ interface Payload {
|
||||
emoji_id: number | string
|
||||
}
|
||||
|
||||
export class SetMsgEmojiLike extends BaseAction<Payload, any> {
|
||||
export class SetMsgEmojiLike extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetMsgEmojiLike
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
|
@ -6,7 +6,7 @@ import { selfInfo } from '@/common/globalVars'
|
||||
class GetLoginInfo extends BaseAction<null, OB11User> {
|
||||
actionName = ActionName.GetLoginInfo
|
||||
|
||||
protected async _handle(payload: null) {
|
||||
protected async _handle() {
|
||||
let nickname = selfInfo.nick
|
||||
try {
|
||||
nickname = await this.ctx.ntUserApi.getSelfNick(true)
|
||||
|
@ -3,10 +3,10 @@ import { OB11Status } from '../../types'
|
||||
import { ActionName } from '../types'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
|
||||
export default class GetStatus extends BaseAction<any, OB11Status> {
|
||||
export default class GetStatus extends BaseAction<null, OB11Status> {
|
||||
actionName = ActionName.GetStatus
|
||||
|
||||
protected async _handle(payload: any): Promise<OB11Status> {
|
||||
protected async _handle(): Promise<OB11Status> {
|
||||
return {
|
||||
online: selfInfo.online!,
|
||||
good: true,
|
||||
|
@ -21,10 +21,10 @@ export class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
}
|
||||
|
||||
// extend
|
||||
export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
export class GetFriendWithCategory extends BaseAction<void, OB11User[]> {
|
||||
actionName = ActionName.GetFriendsWithCategory
|
||||
|
||||
protected async _handle(payload: void) {
|
||||
protected async _handle() {
|
||||
if (getBuildVersion() >= 26702) {
|
||||
//全新逻辑
|
||||
return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2ExWithCate(true))
|
||||
|
@ -10,7 +10,7 @@ function from(source: string) {
|
||||
const capture = pattern.exec(source)
|
||||
if (!capture) return null
|
||||
const [, type, attrs] = capture
|
||||
const data: Record<string, any> = {}
|
||||
const data: Record<string, unknown> = {}
|
||||
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<typeof from>
|
||||
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) {
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<CheckVersion> => {
|
||||
|
@ -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 `<ob-setting-select ${configKey ? `data-config-key="${configKey}"` : ''}>
|
||||
${items
|
||||
.map((e, i) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user