style: lint check

This commit is contained in:
手瓜一十雪
2024-12-05 14:50:27 +08:00
parent 9f31cdbf5b
commit bb53f245cf
10 changed files with 72 additions and 60 deletions

View File

@@ -182,23 +182,26 @@ export async function uriToLocalFile(dir: string, uri: string): Promise<Uri2Loca
const filePath = path.join(dir, filename);
switch (UriType) {
case FileUriType.Local:
case FileUriType.Local: {
const fileExt = path.extname(HandledUri);
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
const tempFilePath = path.join(dir, filename + fileExt);
fs.copyFileSync(HandledUri, tempFilePath);
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
}
case FileUriType.Remote:
case FileUriType.Remote: {
const buffer = await httpDownload(HandledUri);
fs.writeFileSync(filePath, buffer, { flag: 'wx' });
return { success: true, errMsg: '', fileName: filename, path: filePath };
}
case FileUriType.Base64:
case FileUriType.Base64: {
const base64 = HandledUri.replace(/^base64:\/\//, '');
const base64Buffer = Buffer.from(base64, 'base64');
fs.writeFileSync(filePath, base64Buffer, { flag: 'wx' });
return { success: true, errMsg: '', fileName: filename, path: filePath };
}
default:
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };

View File

@@ -61,7 +61,7 @@ export class NTQQFileApi {
async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC, elementSubType: number = 0) {
const fileMd5 = await calculateFileMD5(filePath);
let extOrEmpty = await fileTypeFromFile(filePath).then(e => e?.ext ?? '').catch(e => '');
const extOrEmpty = await fileTypeFromFile(filePath).then(e => e?.ext ?? '').catch(e => '');
const ext = extOrEmpty ? `.${extOrEmpty}` : '';
let fileName = `${path.basename(filePath)}`;
if (fileName.indexOf('.') === -1) {

View File

@@ -3,16 +3,16 @@ import { ProtoField, ScalarType } from "@napneko/nap-proto-core";
export const GroupAdminExtra = {
adminUid: ProtoField(1, ScalarType.STRING),
isPromote: ProtoField(2, ScalarType.BOOL),
}
};
export const GroupAdminBody = {
extraDisable: ProtoField(1, () => GroupAdminExtra),
extraEnable: ProtoField(2, () => GroupAdminExtra),
}
};
export const GroupAdmin = {
groupUin: ProtoField(1, ScalarType.UINT32),
flag: ProtoField(2, ScalarType.UINT32),
isPromote: ProtoField(3, ScalarType.BOOL),
body: ProtoField(4, () => GroupAdminBody),
}
};

View File

@@ -20,7 +20,7 @@ export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
const approve = payload.approve?.toString() !== 'false';
const reason = payload.reason ?? ' ';
let notify = await this.findNotify(flag);
const notify = await this.findNotify(flag);
if (!notify) {
throw new Error('No such request');
}

View File

@@ -16,7 +16,7 @@ export default class SetFriendAddRequest extends OneBotAction<Payload, null> {
async _handle(payload: Payload): Promise<null> {
const approve = payload.approve?.toString() !== 'false';
let notify = (await this.core.apis.FriendApi.getBuddyReq()).buddyReqs.find(e => e.reqTime == payload.flag.toString());
const notify = (await this.core.apis.FriendApi.getBuddyReq()).buddyReqs.find(e => e.reqTime == payload.flag.toString());
if (!notify) {
throw new Error('No such request');
}

View File

@@ -160,7 +160,7 @@ export class OneBotMsgApi {
type: element?.pokeType?.toString() ?? '0',
id: faceIndex.toString(),
}
}
};
}
@@ -461,7 +461,7 @@ export class OneBotMsgApi {
},
[OB11MessageDataType.face]: async ({ data: { id } }) => {
let parsedFaceId = +id;
const parsedFaceId = +id;
// 从face_config.json中获取表情名称
const sysFaces = faceConfig.sysface;
const face: any = sysFaces.find((systemFace) => systemFace.QSid === parsedFaceId.toString());

View File

@@ -521,21 +521,27 @@ export class NapCatOneBot11Adapter {
// 群名片修改事件解析 任何都该判断
if (message.senderUin && message.senderUin !== '0') {
const cardChangedEvent = await this.apis.GroupApi.parseCardChangedEvent(message);
cardChangedEvent && await this.networkManager.emitEvent(cardChangedEvent);
if (cardChangedEvent) {
await this.networkManager.emitEvent(cardChangedEvent);
}
}
if (message.msgType === NTMsgType.KMSGTYPEFILE) {
// 文件为单元素消息
const elementWrapper = message.elements.find(e => !!e.fileElement);
if (elementWrapper?.fileElement) {
const uploadGroupFileEvent = await this.apis.GroupApi.parseGroupUploadFileEvene(message, elementWrapper.fileElement, elementWrapper);
uploadGroupFileEvent && await this.networkManager.emitEvent(uploadGroupFileEvent);
if (uploadGroupFileEvent) {
await this.networkManager.emitEvent(uploadGroupFileEvent);
}
}
} else if (message.msgType === NTMsgType.KMSGTYPEGRAYTIPS) {
// 灰条为单元素消息
const grayTipElement = message.elements[0].grayTipElement;
if (grayTipElement) {
const event = await this.apis.GroupApi.parseGrayTipElement(message, grayTipElement);
event && await this.networkManager.emitEvent(event);
if (event) {
await this.networkManager.emitEvent(event);
}
}
}
} catch (e) {
@@ -550,7 +556,10 @@ export class NapCatOneBot11Adapter {
const grayTipElement = message.elements[0].grayTipElement;
if (grayTipElement) {
const event = await this.apis.MsgApi.parsePrivateMsgEvent(message, grayTipElement);
event && await this.networkManager.emitEvent(event);
if (event) {
await this.networkManager.emitEvent(event);
}
}
}
} catch (e) {