mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
refactor: chattype
This commit is contained in:
@@ -12,7 +12,7 @@ import { OB11GroupTitleEvent } from "../event/notice/OB11GroupTitleEvent";
|
||||
import { NapCatCore, RawMessage, ChatType, NTGrayTipElementSubTypeV2, TipGroupElementType, Peer } from '@/core';
|
||||
|
||||
export async function NT2PrivateEvent(core: NapCatCore, obContext: NapCatOneBot11Adapter, msg: RawMessage): Promise<OB11BaseNoticeEvent | undefined> {
|
||||
if (msg.chatType !== ChatType.friend) {
|
||||
if (msg.chatType !== ChatType.KCHATTYPEC2C) {
|
||||
return;
|
||||
}
|
||||
for (const element of msg.elements) {
|
||||
@@ -38,7 +38,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
const NTQQUserApi = core.apis.UserApi;
|
||||
const NTQQMsgApi = core.apis.MsgApi;
|
||||
const logger = core.context.logger;
|
||||
if (msg.chatType !== ChatType.group) {
|
||||
if (msg.chatType !== ChatType.KCHATTYPEGROUP) {
|
||||
return;
|
||||
}
|
||||
//log("group msg", msg);
|
||||
@@ -124,7 +124,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
// const businessId = searchParams.get('businessid');
|
||||
const Peer: Peer = {
|
||||
guildId: '',
|
||||
chatType: ChatType.group,
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: Group!,
|
||||
};
|
||||
const msgData = await NTQQMsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function RawNTMsg2Onebot(
|
||||
message_id: msg.id!,
|
||||
message_seq: msg.id!,
|
||||
real_id: msg.id!,
|
||||
message_type: msg.chatType == ChatType.group ? 'group' : 'private',
|
||||
message_type: msg.chatType == ChatType.KCHATTYPEGROUP ? 'group' : 'private',
|
||||
sender: {
|
||||
user_id: parseInt(msg.senderUin || '0'),
|
||||
nickname: msg.sendNickName,
|
||||
@@ -41,7 +41,7 @@ export async function RawNTMsg2Onebot(
|
||||
message_format: messagePostFormat === 'string' ? 'string' : 'array',
|
||||
post_type: core.selfInfo.uin == msg.senderUin ? EventType.MESSAGE_SENT : EventType.MESSAGE,
|
||||
};
|
||||
if (msg.chatType == ChatType.group) {
|
||||
if (msg.chatType == ChatType.KCHATTYPEGROUP) {
|
||||
resMsg.sub_type = 'normal'; // 这里go-cqhttp是group,而onebot11标准是normal, 蛋疼
|
||||
resMsg.group_id = parseInt(msg.peerUin);
|
||||
//直接去QQNative取
|
||||
@@ -51,14 +51,14 @@ export async function RawNTMsg2Onebot(
|
||||
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
|
||||
resMsg.sender.nickname = member.nick;
|
||||
}
|
||||
} else if (msg.chatType == ChatType.friend) {
|
||||
} else if (msg.chatType == ChatType.KCHATTYPEC2C) {
|
||||
resMsg.sub_type = 'friend';
|
||||
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
|
||||
//const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
||||
//resMsg.sender.nickname = user.info.nick;
|
||||
} else if (msg.chatType == ChatType.temp) {
|
||||
} else if (msg.chatType == ChatType.KCHATTYPETEMPC2CFROMGROUP) {
|
||||
resMsg.sub_type = 'group';
|
||||
const ret = await NTQQMsgApi.getTempChatInfo(ChatType.temp, msg.senderUid);
|
||||
const ret = await NTQQMsgApi.getTempChatInfo(ChatType.KCHATTYPETEMPC2CFROMGROUP, msg.senderUid);
|
||||
if (ret.result === 0) {
|
||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
||||
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick;
|
||||
|
||||
@@ -20,15 +20,15 @@ async function handleMsg(coreContext: NapCatCore, obContext: NapCatOneBot11Adapt
|
||||
msg = msg as OB11Message;
|
||||
const reply = quickAction.reply;
|
||||
const peer: Peer = {
|
||||
chatType: ChatType.friend,
|
||||
chatType: ChatType.KCHATTYPEC2C,
|
||||
peerUid: await coreContext.apis.UserApi.getUidByUinV2(msg.user_id.toString()) as string,
|
||||
};
|
||||
if (msg.message_type == 'private') {
|
||||
if (msg.sub_type === 'group') {
|
||||
peer.chatType = ChatType.temp;
|
||||
peer.chatType = ChatType.KCHATTYPETEMPC2CFROMGROUP;
|
||||
}
|
||||
} else {
|
||||
peer.chatType = ChatType.group;
|
||||
peer.chatType = ChatType.KCHATTYPETEMPC2CFROMGROUP;
|
||||
peer.peerUid = msg.group_id!.toString();
|
||||
}
|
||||
if (reply) {
|
||||
|
||||
Reference in New Issue
Block a user