mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
refactor: inline all NTQQXxxApi uses
This commit is contained in:
@@ -30,16 +30,13 @@ export class OneBotGroupApi {
|
||||
}
|
||||
|
||||
async parseGroupEvent(msg: RawMessage) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||
const logger = this.core.context.logger;
|
||||
if (msg.chatType !== ChatType.KCHATTYPEGROUP) {
|
||||
return;
|
||||
}
|
||||
//log("group msg", msg);
|
||||
if (msg.senderUin && msg.senderUin !== '0') {
|
||||
const member = await NTQQGroupApi.getGroupMember(msg.peerUid, msg.senderUin);
|
||||
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUid, msg.senderUin);
|
||||
if (member && member.cardName !== msg.sendMemberName) {
|
||||
const newCardName = msg.sendMemberName || '';
|
||||
const event = new OB11GroupCardEvent(this.core, parseInt(msg.peerUid), parseInt(msg.senderUin), newCardName, member.cardName);
|
||||
@@ -58,7 +55,7 @@ export class OneBotGroupApi {
|
||||
const BanEvent = await this.obContext.apis.GroupApi.parseGroupBanEvent(msg.peerUid, element.grayTipElement);
|
||||
if (BanEvent) return BanEvent;
|
||||
} else if (groupElement.type == TipGroupElementType.kicked) {
|
||||
NTQQGroupApi.quitGroup(msg.peerUid).then();
|
||||
this.core.apis.GroupApi.quitGroup(msg.peerUid).then();
|
||||
try {
|
||||
const KickEvent = await this.obContext.apis.GroupApi.parseGroupKickEvent(msg.peerUid, element.grayTipElement);
|
||||
if (KickEvent) return KickEvent;
|
||||
@@ -110,8 +107,8 @@ export class OneBotGroupApi {
|
||||
return new OB11GroupPokeEvent(
|
||||
this.core,
|
||||
parseInt(msg.peerUid),
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(poke_uid[0].uid))!),
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(poke_uid[1].uid))!),
|
||||
parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[0].uid))!),
|
||||
parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[1].uid))!),
|
||||
pokedetail,
|
||||
);
|
||||
}
|
||||
@@ -127,7 +124,7 @@ export class OneBotGroupApi {
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: Group,
|
||||
};
|
||||
const msgData = await NTQQMsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
|
||||
const msgData = await this.core.apis.MsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
|
||||
const msgList = (await this.core.apis.WebApi.getGroupEssenceMsgAll(Group)).flatMap((e) => e.data.msg_list);
|
||||
const realMsg = msgList.find((e) => e.msg_seq.toString() == msgSeq);
|
||||
return new OB11GroupEssenceEvent(
|
||||
@@ -158,7 +155,6 @@ export class OneBotGroupApi {
|
||||
|
||||
async parseGroupBanEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const groupElement = grayTipElement?.groupElement;
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
if (!groupElement?.shutUp) return undefined;
|
||||
const memberUid = groupElement.shutUp!.member.uid;
|
||||
const adminUid = groupElement.shutUp!.admin.uid;
|
||||
@@ -166,14 +162,14 @@ export class OneBotGroupApi {
|
||||
let duration = parseInt(groupElement.shutUp!.duration);
|
||||
const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban';
|
||||
if (memberUid) {
|
||||
memberUin = (await NTQQGroupApi.getGroupMember(GroupCode, memberUid))?.uin || '';
|
||||
memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin || '';
|
||||
} else {
|
||||
memberUin = '0'; // 0表示全员禁言
|
||||
if (duration > 0) {
|
||||
duration = -1;
|
||||
}
|
||||
}
|
||||
const adminUin = (await NTQQGroupApi.getGroupMember(GroupCode, adminUid))?.uin;
|
||||
const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, adminUid))?.uin;
|
||||
if (memberUin && adminUin) {
|
||||
return new OB11GroupBanEvent(
|
||||
this.core,
|
||||
@@ -215,12 +211,11 @@ export class OneBotGroupApi {
|
||||
}
|
||||
|
||||
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const groupElement = grayTipElement?.groupElement;
|
||||
if (!groupElement) return undefined;
|
||||
const member = await NTQQGroupApi.getGroupMember(GroupCode, groupElement.memberUid);
|
||||
const member = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.memberUid);
|
||||
const memberUin = member?.uin;
|
||||
const adminMember = await NTQQGroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
||||
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
||||
if (memberUin) {
|
||||
const operatorUin = adminMember?.uin || memberUin;
|
||||
return new OB11GroupIncreaseEvent(
|
||||
@@ -235,11 +230,9 @@ export class OneBotGroupApi {
|
||||
}
|
||||
|
||||
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const groupElement = grayTipElement?.groupElement;
|
||||
if (!groupElement) return undefined;
|
||||
const adminUin = (await NTQQGroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin || (await NTQQUserApi.getUidByUinV2(groupElement.adminUid));
|
||||
const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin || (await this.core.apis.UserApi.getUidByUinV2(groupElement.adminUid));
|
||||
if (adminUin) {
|
||||
return new OB11GroupDecreaseEvent(
|
||||
this.core,
|
||||
|
||||
Reference in New Issue
Block a user