Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Aug 25, 2024
1 parent f063cf4 commit 535720d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 130 deletions.
6 changes: 3 additions & 3 deletions src/common/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import crypto, { randomUUID } from 'crypto';
import util from 'util';
import path from 'node:path';
import * as fileType from 'file-type';
import { solveAsyncProblem, solveProblem } from './helper';
import { solveProblem } from './helper';

export function isGIF(path: string) {
const buffer = Buffer.alloc(4);
Expand Down Expand Up @@ -194,7 +194,7 @@ export async function checkUriType(Uri: string) {
return undefined;
}, Uri);
if (LocalFileRet) return LocalFileRet;

const OtherFileRet = await solveProblem((uri: string) => {
//再判断是否是Http
if (uri.startsWith('http://') || uri.startsWith('https://')) {
Expand All @@ -217,7 +217,7 @@ export async function checkUriType(Uri: string) {
}
}, Uri);
if (OtherFileRet) return OtherFileRet;

return { Uri: Uri, Type: FileUriType.Unknown };
}

Expand Down
6 changes: 3 additions & 3 deletions src/common/utils/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export async function getVideoInfo(filePath: string, logger: LogWrapper) {
if (videoStream) {
logger.log(`视频尺寸: ${videoStream.width}x${videoStream.height}`);
} else {
return reject('未找到视频流信息。');
return reject(new Error('未找到视频流信息。'));
}
resolve({
width: videoStream.width!, height: videoStream.height!,
time: parseInt(videoStream.duration!),
time: +(videoStream.duration ?? 10),
format: metadata.format.format_name!,
size,
filePath,
Expand All @@ -38,7 +38,7 @@ export async function getVideoInfo(filePath: string, logger: LogWrapper) {
});
}

export function checkFfmpeg(newPath: string | null = null, logger: LogWrapper): Promise<boolean> {
export function checkFfmpeg(logger: LogWrapper,newPath: string | null = null): Promise<boolean> {
return new Promise((resolve, reject) => {
logger.log('开始检查ffmpeg', newPath);
if (newPath) {
Expand Down
15 changes: 1 addition & 14 deletions src/core/adapters/NodeIDependsAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
interface IDependsAdapter {
onMSFStatusChange(arg1: number, arg2: number): void;

onMSFSsoError(args: unknown): void;

getGroupCode(args: unknown): void;
}

export interface NodeIDependsAdapter extends IDependsAdapter {
// eslint-disable-next-line @typescript-eslint/no-misused-new
new(adapter: IDependsAdapter): NodeIDependsAdapter;
}

export class DependsAdapter implements IDependsAdapter {
export class NodeIDependsAdapter {
onMSFStatusChange(arg1: number, arg2: number) {
// console.log(arg1, arg2);
// if (arg1 == 2 && arg2 == 2) {
Expand Down
15 changes: 1 addition & 14 deletions src/core/adapters/NodeIDispatcherAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
interface IDispatcherAdapter {
dispatchRequest(arg: unknown): void;

dispatchCall(arg: unknown): void;

dispatchCallWithJson(arg: unknown): void;
}

export interface NodeIDispatcherAdapter extends IDispatcherAdapter {
// eslint-disable-next-line @typescript-eslint/no-misused-new
new(adapter: IDispatcherAdapter): NodeIDispatcherAdapter;
}

export class DispatcherAdapter implements IDispatcherAdapter {
export class NodeIDispatcherAdapter {
dispatchRequest(arg: unknown) {
}

Expand Down
71 changes: 0 additions & 71 deletions src/core/apis/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,6 @@ import { RequestUtil } from '@/common/utils/request';
import { MiniAppLuaJsonType } from '@/core';
import { InstanceContext, NapCatCore } from '..';

// let t = await napCatCore.session.getGroupService().shareDigest({
// appId: "100497308",
// appType: 1,
// msgStyle: 0,
// recvUin: "726067488",
// sendType: 1,
// clientInfo: {
// platform: 1
// },
// richMsg: {
// usingArk: true,
// title: "Bot测试title",
// summary: "Bot测试summary",
// url: "https://www.bilibili.com",
// pictureUrl: "https://y.qq.com/music/photo_new/T002R300x300M0000035DC6W4ZpSqf_1.jpg?max_age=2592000",
// brief: "Bot测试brief",
// }
// });
// {
// errCode: 0,
// errMsg: '',
// rsp: {
// sendType: 1,
// recvUin: '726067488',
// recvOpenId: '',
// errCode: 901501,
// errMsg: 'imagent service_error:150_OIDB_NO_PRIV',
// extInfo: {
// wording: '消息下发失败(错误码:901501)',
// jumpResult: 0,
// jumpUrl: '',
// level: 0,
// subLevel: 0,
// developMsg: 'imagent error'
// }
// }
// }

// export class MusicSign {
// private readonly url: string;

// constructor(url: string) {
// this.url = url;
// }

// sign(postData: CustomMusicSignPostData | IdMusicSignPostData): Promise<any> {
// return new Promise((resolve, reject) => {
// fetch(this.url, {
// method: 'POST', // 指定请求方法为 POST
// headers: {
// 'Content-Type': 'application/json' // 设置请求头,指明发送的数据类型为 JSON
// },
// body: JSON.stringify(postData) // 将 JavaScript 对象转换为 JSON 字符串作为请求体
// })
// .then(response => {
// if (!response.ok) {
// reject(response.statusText); // 请求失败,返回错误信息
// }
// return response.json(); // 解析 JSON 格式的响应体
// })
// .then(data => {
// logDebug('音乐消息生成成功', data);
// resolve(data);
// })
// .catch(error => {
// reject(error);
// });
// });
// }
// }

export class NTQQMusicSignApi {
context: InstanceContext;
core: NapCatCore;
Expand Down
21 changes: 1 addition & 20 deletions src/core/listeners/NodeIKernelSessionListener.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
export interface ISessionListener {
onNTSessionCreate(args: unknown): void;

onGProSessionCreate(args: unknown): void;

onSessionInitComplete(args: unknown): void;

onOpentelemetryInit(args: unknown): void;

onUserOnlineResult(args: unknown): void;

onGetSelfTinyId(args: unknown): void;
}

export interface NodeIKernelSessionListener extends ISessionListener {
// eslint-disable-next-line @typescript-eslint/no-misused-new
new(adapter: ISessionListener): NodeIKernelSessionListener;
}

export class SessionListener implements ISessionListener {
export class NodeIKernelSessionListener {
onNTSessionCreate(args: unknown) {

}
Expand Down
10 changes: 5 additions & 5 deletions src/shell/napcat.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { SelfInfo } from '@/core/entities';

import { LogWrapper } from '@/common/utils/log';
import { LoginListener, SessionListener } from '@/core/listeners';
import { DependsAdapter, DispatcherAdapter, GlobalAdapter } from '@/core/adapters';
import { LoginListener, NodeIKernelSessionListener } from '@/core/listeners';
import { NodeIDispatcherAdapter, GlobalAdapter, NodeIDependsAdapter } from '@/core/adapters';
import { NapCatPathWrapper } from '@/common/framework/napcat';
import {
InstanceContext,
Expand Down Expand Up @@ -208,7 +208,7 @@ export async function NCoreInitShell() {
selfInfo.uid,
dataPath,
);
const sessionListener = new SessionListener();
const sessionListener = new NodeIKernelSessionListener();
sessionListener.onSessionInitComplete = (r: unknown) => {
if (r === 0) {
resolve();
Expand All @@ -218,8 +218,8 @@ export async function NCoreInitShell() {
};
session.init(
sessionConfig,
new DependsAdapter() as any,
new DispatcherAdapter() as any,
new NodeIDependsAdapter(),
new NodeIDispatcherAdapter(),
sessionListener as any,
);
try {
Expand Down

0 comments on commit 535720d

Please sign in to comment.