Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Jan 13, 2025
1 parent ec0c2e8 commit 7c8cbc0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/common/fall-back.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Fallback<T> {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/onebot/action/group/GetGroupMemberInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {

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),
Expand Down
2 changes: 1 addition & 1 deletion src/onebot/action/group/SetGroupAddRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
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');
Expand Down
2 changes: 1 addition & 1 deletion src/onebot/api/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 在这里实现为了避免邀请出现问题
Expand Down
62 changes: 31 additions & 31 deletions src/onebot/api/msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -906,16 +906,16 @@ export class OneBotMsgApi {
const calculateTotalSize = async (elements: SendMessageElement[]): Promise<number> => {
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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() : ''
Expand All @@ -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 ?
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1136,7 +1136,7 @@ export class OneBotMsgApi {
waitStatus: 1,
},
status: 1
})
});
return new OB11GroupRequestEvent(
this.core,
+groupInvite.groupUin,
Expand Down
2 changes: 1 addition & 1 deletion src/onebot/api/quick-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/shell/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 7c8cbc0

Please sign in to comment.