mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
chore: style&&lint
This commit is contained in:
parent
71a2e52739
commit
50177cd6bd
@ -69,9 +69,9 @@ export class LegacyNTEventWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createListenerFunction<T>(listenerMainName: string, uniqueCode: string = ''): T {
|
createListenerFunction<T>(listenerMainName: string, uniqueCode: string = ''): T {
|
||||||
let existListener = this.listenerManager.get(listenerMainName + uniqueCode);
|
const existListener = this.listenerManager.get(listenerMainName + uniqueCode);
|
||||||
if (!existListener) {
|
if (!existListener) {
|
||||||
let Listener = this.createProxyDispatch(listenerMainName);
|
const Listener = this.createProxyDispatch(listenerMainName);
|
||||||
const ServiceSubName = listenerMainName.match(/^NodeIKernel(.*?)Listener$/)![1];
|
const ServiceSubName = listenerMainName.match(/^NodeIKernel(.*?)Listener$/)![1];
|
||||||
const Service = 'NodeIKernel' + ServiceSubName + 'Service/addKernel' + ServiceSubName + 'Listener';
|
const Service = 'NodeIKernel' + ServiceSubName + 'Service/addKernel' + ServiceSubName + 'Listener';
|
||||||
const addfunc = this.createEventFunction<(listener: T) => number>(Service);
|
const addfunc = this.createEventFunction<(listener: T) => number>(Service);
|
||||||
|
File diff suppressed because one or more lines are too long
@ -274,9 +274,9 @@ export class NTQQGroupApi {
|
|||||||
const result = await Listener as unknown;
|
const result = await Listener as unknown;
|
||||||
let member: GroupMember | undefined;
|
let member: GroupMember | undefined;
|
||||||
if (Array.isArray(result) && result?.[2] instanceof Map) {
|
if (Array.isArray(result) && result?.[2] instanceof Map) {
|
||||||
let members = result[2] as Map<string, GroupMember>;
|
const members = result[2] as Map<string, GroupMember>;
|
||||||
member = members.get(uid);
|
member = members.get(uid);
|
||||||
};
|
}
|
||||||
return member;
|
return member;
|
||||||
|
|
||||||
// 原本的方法: (no_cache 下效率很高, cache 下效率一致)
|
// 原本的方法: (no_cache 下效率很高, cache 下效率一致)
|
||||||
|
@ -129,7 +129,7 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
async getUserDetailInfo(uid: string): Promise<User> {
|
async getUserDetailInfo(uid: string): Promise<User> {
|
||||||
try {
|
try {
|
||||||
let retUser = await this.fetchUserDetailInfo(uid, UserDetailSource.KDB);
|
const retUser = await this.fetchUserDetailInfo(uid, UserDetailSource.KDB);
|
||||||
if (retUser.uin !== '0') {
|
if (retUser.uin !== '0') {
|
||||||
return retUser;
|
return retUser;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
|||||||
peer = {
|
peer = {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
peerUid: payload.group_id
|
peerUid: payload.group_id
|
||||||
}
|
};
|
||||||
} else if (payload.user_id) {
|
} else if (payload.user_id) {
|
||||||
let uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
||||||
if (!uid) throw new Error('uid is empty');
|
if (!uid) throw new Error('uid is empty');
|
||||||
peer = {
|
peer = {
|
||||||
chatType: ChatType.friend,
|
chatType: ChatType.friend,
|
||||||
peerUid: uid
|
peerUid: uid
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
throw new Error('请指定 group_id 或 user_id');
|
throw new Error('请指定 group_id 或 user_id');
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ import { TranslateEnWordToZn } from './extends/TranslateEnWordToZn';
|
|||||||
import { SetGroupFileFolder } from './file/SetGroupFileFolder';
|
import { SetGroupFileFolder } from './file/SetGroupFileFolder';
|
||||||
import { DelGroupFile } from './file/DelGroupFile';
|
import { DelGroupFile } from './file/DelGroupFile';
|
||||||
import { DelGroupFileFolder } from './file/DelGroupFileFolder';
|
import { DelGroupFileFolder } from './file/DelGroupFileFolder';
|
||||||
import { SetQQProfile } from './go-cqhttp/SetQQProfile'
|
import { SetQQProfile } from './go-cqhttp/SetQQProfile';
|
||||||
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
||||||
import { CreateCollection } from './extends/CreateCollection';
|
import { CreateCollection } from './extends/CreateCollection';
|
||||||
import { SetLongNick } from './extends/SetLongNick';
|
import { SetLongNick } from './extends/SetLongNick';
|
||||||
|
@ -73,7 +73,7 @@ export class OneBotGroupApi {
|
|||||||
}
|
}
|
||||||
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const NTQQGroupApi = this.coreContext.apis.GroupApi;
|
const NTQQGroupApi = this.coreContext.apis.GroupApi;
|
||||||
let groupElement = grayTipElement?.groupElement;
|
const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
if (!groupElement) return undefined;
|
||||||
const member = await NTQQGroupApi.getGroupMember(GroupCode, groupElement.memberUid);
|
const member = await NTQQGroupApi.getGroupMember(GroupCode, groupElement.memberUid);
|
||||||
const memberUin = member?.uin;
|
const memberUin = member?.uin;
|
||||||
@ -92,7 +92,7 @@ export class OneBotGroupApi {
|
|||||||
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const NTQQGroupApi = this.coreContext.apis.GroupApi;
|
const NTQQGroupApi = this.coreContext.apis.GroupApi;
|
||||||
const NTQQUserApi = this.coreContext.apis.UserApi;
|
const NTQQUserApi = this.coreContext.apis.UserApi;
|
||||||
let groupElement = grayTipElement?.groupElement;
|
const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
if (!groupElement) return undefined;
|
||||||
const adminUin = (await NTQQGroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin || (await NTQQUserApi.getUidByUinV2(groupElement.adminUid));
|
const adminUin = (await NTQQGroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin || (await NTQQUserApi.getUidByUinV2(groupElement.adminUid));
|
||||||
if (adminUin) {
|
if (adminUin) {
|
||||||
@ -121,7 +121,7 @@ export class OneBotGroupApi {
|
|||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: GroupCode
|
peerUid: GroupCode
|
||||||
}
|
};
|
||||||
const replyMsgList = (await NTQQMsgApi.getMsgExBySeq(peer, msgSeq)).msgList;
|
const replyMsgList = (await NTQQMsgApi.getMsgExBySeq(peer, msgSeq)).msgList;
|
||||||
if (replyMsgList.length < 1) {
|
if (replyMsgList.length < 1) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ export async function NT2PrivateEvent(core: NapCatCore, obContext: NapCatOneBot1
|
|||||||
if (element.grayTipElement) {
|
if (element.grayTipElement) {
|
||||||
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
let PokeEvent = await obContext.apiContext.FriendApi.parsePrivatePokeEvent(element.grayTipElement);
|
const PokeEvent = await obContext.apiContext.FriendApi.parsePrivatePokeEvent(element.grayTipElement);
|
||||||
if (PokeEvent) return PokeEvent;
|
if (PokeEvent) return PokeEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,15 +56,15 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
|||||||
if (element.grayTipElement && element.grayTipElement.groupElement) {
|
if (element.grayTipElement && element.grayTipElement.groupElement) {
|
||||||
const groupElement = element.grayTipElement.groupElement;
|
const groupElement = element.grayTipElement.groupElement;
|
||||||
if (groupElement.type == TipGroupElementType.memberIncrease) {
|
if (groupElement.type == TipGroupElementType.memberIncrease) {
|
||||||
let MemberIncreaseEvent = await obContext.apiContext.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, element.grayTipElement);
|
const MemberIncreaseEvent = await obContext.apiContext.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, element.grayTipElement);
|
||||||
if (MemberIncreaseEvent) return MemberIncreaseEvent;
|
if (MemberIncreaseEvent) return MemberIncreaseEvent;
|
||||||
} else if (groupElement.type === TipGroupElementType.ban) {
|
} else if (groupElement.type === TipGroupElementType.ban) {
|
||||||
let BanEvent = await obContext.apiContext.GroupApi.parseGroupBanEvent(msg.peerUid, element.grayTipElement);
|
const BanEvent = await obContext.apiContext.GroupApi.parseGroupBanEvent(msg.peerUid, element.grayTipElement);
|
||||||
if (BanEvent) return BanEvent;
|
if (BanEvent) return BanEvent;
|
||||||
} else if (groupElement.type == TipGroupElementType.kicked) {
|
} else if (groupElement.type == TipGroupElementType.kicked) {
|
||||||
NTQQGroupApi.quitGroup(msg.peerUid).then();
|
NTQQGroupApi.quitGroup(msg.peerUid).then();
|
||||||
try {
|
try {
|
||||||
let KickEvent = await obContext.apiContext.GroupApi.parseGroupKickEvent(msg.peerUid, element.grayTipElement);
|
const KickEvent = await obContext.apiContext.GroupApi.parseGroupKickEvent(msg.peerUid, element.grayTipElement);
|
||||||
if (KickEvent) return KickEvent;
|
if (KickEvent) return KickEvent;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return new OB11GroupDecreaseEvent(
|
return new OB11GroupDecreaseEvent(
|
||||||
@ -90,11 +90,11 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
|||||||
}
|
}
|
||||||
if (element.grayTipElement) {
|
if (element.grayTipElement) {
|
||||||
if (element.grayTipElement.xmlElement?.templId === '10382') {
|
if (element.grayTipElement.xmlElement?.templId === '10382') {
|
||||||
let emojiLikeEvent = await obContext.apiContext.GroupApi.parseGroupEmjioLikeEvent(msg.peerUid, element.grayTipElement);
|
const emojiLikeEvent = await obContext.apiContext.GroupApi.parseGroupEmjioLikeEvent(msg.peerUid, element.grayTipElement);
|
||||||
if (emojiLikeEvent) return emojiLikeEvent;
|
if (emojiLikeEvent) return emojiLikeEvent;
|
||||||
}
|
}
|
||||||
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
||||||
let GroupIncreaseEvent = await obContext.apiContext.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, element.grayTipElement);
|
const GroupIncreaseEvent = await obContext.apiContext.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, element.grayTipElement);
|
||||||
if (GroupIncreaseEvent) return GroupIncreaseEvent;
|
if (GroupIncreaseEvent) return GroupIncreaseEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import { OB11Constructor } from './converter';
|
|||||||
import { encodeCQCode } from './cqcode';
|
import { encodeCQCode } from './cqcode';
|
||||||
|
|
||||||
|
|
||||||
export async function RawNTMsg2Onebot(
|
export async function RawNTMsg2Onebot(
|
||||||
core: NapCatCore,
|
core: NapCatCore,
|
||||||
obcore: NapCatOneBot11Adapter,
|
obcore: NapCatOneBot11Adapter,
|
||||||
msg: RawMessage,
|
msg: RawMessage,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user