mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: chattype
This commit is contained in:
@@ -152,11 +152,11 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
|
|
||||||
const tokens: string[] = [];
|
const tokens: string[] = [];
|
||||||
|
|
||||||
if (msg.chatType == ChatType.friend) {
|
if (msg.chatType == ChatType.KCHATTYPEC2C) {
|
||||||
tokens.push(`私聊 (${msg.peerUin})`);
|
tokens.push(`私聊 (${msg.peerUin})`);
|
||||||
} else if (msg.chatType == ChatType.group) {
|
} else if (msg.chatType == ChatType.KCHATTYPEGROUP) {
|
||||||
tokens.push(`群聊 (群 ${msg.peerUin} 的 ${msg.senderUin})`);
|
tokens.push(`群聊 (群 ${msg.peerUin} 的 ${msg.senderUin})`);
|
||||||
} else if (msg.chatType == ChatType.chatDevice) {
|
} else if (msg.chatType == ChatType.KCHATTYPEDATALINE) {
|
||||||
tokens.push('移动设备');
|
tokens.push('移动设备');
|
||||||
} else /* temp */ {
|
} else /* temp */ {
|
||||||
tokens.push(`临时消息 (${msg.peerUin})`);
|
tokens.push(`临时消息 (${msg.peerUin})`);
|
||||||
|
@@ -179,7 +179,7 @@ export class NTQQFileApi {
|
|||||||
async addFileCache(peer: Peer, msgId: string, msgSeq: string, senderUid: string, elemId: string, elemType: string, fileSize: string, fileName: string) {
|
async addFileCache(peer: Peer, msgId: string, msgSeq: string, senderUid: string, elemId: string, elemType: string, fileSize: string, fileName: string) {
|
||||||
let GroupData;
|
let GroupData;
|
||||||
let BuddyData;
|
let BuddyData;
|
||||||
if (peer.chatType === ChatType.group) {
|
if (peer.chatType === ChatType.KCHATTYPEGROUP) {
|
||||||
GroupData =
|
GroupData =
|
||||||
[{
|
[{
|
||||||
groupCode: peer.peerUid,
|
groupCode: peer.peerUid,
|
||||||
@@ -189,7 +189,7 @@ export class NTQQFileApi {
|
|||||||
groupName: 'NapCat.Cached',
|
groupName: 'NapCat.Cached',
|
||||||
remark: 'NapCat.Cached',
|
remark: 'NapCat.Cached',
|
||||||
}];
|
}];
|
||||||
} else if (peer.chatType === ChatType.friend) {
|
} else if (peer.chatType === ChatType.KCHATTYPEC2C) {
|
||||||
BuddyData = [{
|
BuddyData = [{
|
||||||
category_name: 'NapCat.Cached',
|
category_name: 'NapCat.Cached',
|
||||||
peerUid: peer.peerUid,
|
peerUid: peer.peerUid,
|
||||||
|
@@ -114,7 +114,7 @@ export class NTQQGroupApi {
|
|||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
||||||
chatInfo: {
|
chatInfo: {
|
||||||
peerUid: GroupCode,
|
peerUid: GroupCode,
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
},
|
},
|
||||||
filterMsgType: [],
|
filterMsgType: [],
|
||||||
filterSendersUid: uids,
|
filterSendersUid: uids,
|
||||||
@@ -175,7 +175,7 @@ export class NTQQGroupApi {
|
|||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
||||||
chatInfo: {
|
chatInfo: {
|
||||||
peerUid: GroupCode,
|
peerUid: GroupCode,
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
},
|
},
|
||||||
filterMsgType: [],
|
filterMsgType: [],
|
||||||
filterSendersUid: uids,
|
filterSendersUid: uids,
|
||||||
|
@@ -156,7 +156,7 @@ export class NTQQMsgApi {
|
|||||||
peerOpenId: "",
|
peerOpenId: "",
|
||||||
};
|
};
|
||||||
return this.context.session.getMsgService().prepareTempChat({
|
return this.context.session.getMsgService().prepareTempChat({
|
||||||
chatType: ChatType.temp,
|
chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP,
|
||||||
peerUid: toUserUid,
|
peerUid: toUserUid,
|
||||||
peerNickname: nickname,
|
peerNickname: nickname,
|
||||||
fromGroupCode: GroupCode,
|
fromGroupCode: GroupCode,
|
||||||
@@ -171,7 +171,7 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
//唉? !我有个想法
|
//唉? !我有个想法
|
||||||
if (peer.chatType === ChatType.temp && peer.guildId && peer.guildId !== '') {
|
if (peer.chatType === ChatType.KCHATTYPETEMPC2CFROMGROUP && peer.guildId && peer.guildId !== '') {
|
||||||
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
||||||
if (member) {
|
if (member) {
|
||||||
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
|
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
|
||||||
|
@@ -511,17 +511,8 @@ export enum AtType {
|
|||||||
atAll = 1,
|
atAll = 1,
|
||||||
atUser = 2
|
atUser = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ChatType {
|
|
||||||
friend = 1,
|
|
||||||
group = 2,
|
|
||||||
chatDevice = 8, //移动设备?
|
|
||||||
temp = 100
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 来自Android分析
|
// 来自Android分析
|
||||||
export enum ChatType2 {
|
export enum ChatType {
|
||||||
KCHATTYPEADELIE = 42,
|
KCHATTYPEADELIE = 42,
|
||||||
KCHATTYPEBUDDYNOTIFY = 5,
|
KCHATTYPEBUDDYNOTIFY = 5,
|
||||||
KCHATTYPEC2C = 1,
|
KCHATTYPEC2C = 1,
|
||||||
|
@@ -24,14 +24,14 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
|||||||
let peer: Peer;
|
let peer: Peer;
|
||||||
if (payload.group_id) {
|
if (payload.group_id) {
|
||||||
peer = {
|
peer = {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: payload.group_id
|
peerUid: payload.group_id
|
||||||
};
|
};
|
||||||
} else if (payload.user_id) {
|
} else if (payload.user_id) {
|
||||||
const 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.KCHATTYPEC2C,
|
||||||
peerUid: uid
|
peerUid: uid
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@@ -47,15 +47,15 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
let peer: Peer | undefined;
|
let peer: Peer | undefined;
|
||||||
//识别Peer
|
//识别Peer
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
peer = { chatType: ChatType.group, peerUid: peerUin };
|
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: peerUin };
|
||||||
}
|
}
|
||||||
const PeerUid = await NTQQUserApi.getUidByUinV2(peerUin);
|
const PeerUid = await NTQQUserApi.getUidByUinV2(peerUin);
|
||||||
if (PeerUid) {
|
if (PeerUid) {
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
const isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
||||||
if (isBuddy) {
|
if (isBuddy) {
|
||||||
peer = { chatType: ChatType.friend, peerUid: PeerUid };
|
peer = { chatType: ChatType.KCHATTYPEC2C, peerUid: PeerUid };
|
||||||
} else {
|
} else {
|
||||||
peer = { chatType: ChatType.temp, peerUid: PeerUid };
|
peer = { chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: PeerUid };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
@@ -97,8 +97,8 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
if (NTSearchNameResult.length !== 0) {
|
if (NTSearchNameResult.length !== 0) {
|
||||||
const MsgId = NTSearchNameResult[0].msgId;
|
const MsgId = NTSearchNameResult[0].msgId;
|
||||||
let peer: Peer | undefined = undefined;
|
let peer: Peer | undefined = undefined;
|
||||||
if (NTSearchNameResult[0].chatType == ChatType.group) {
|
if (NTSearchNameResult[0].chatType == ChatType.KCHATTYPEGROUP) {
|
||||||
peer = { chatType: ChatType.group, peerUid: NTSearchNameResult[0].groupChatInfo[0].groupCode };
|
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: NTSearchNameResult[0].groupChatInfo[0].groupCode };
|
||||||
}
|
}
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
throw new Error('chattype not support');
|
throw new Error('chattype not support');
|
||||||
|
@@ -38,7 +38,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
|||||||
const isReverseOrder = payload.reverseOrder || true;
|
const isReverseOrder = payload.reverseOrder || true;
|
||||||
if (!uid) throw `记录${payload.user_id}不存在`;
|
if (!uid) throw `记录${payload.user_id}不存在`;
|
||||||
const friend = await NTQQFriendApi.isBuddy(uid);
|
const friend = await NTQQFriendApi.isBuddy(uid);
|
||||||
const peer = { chatType: friend ? ChatType.friend : ChatType.temp, peerUid: uid };
|
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||||
|
|
||||||
//拉取消息
|
//拉取消息
|
||||||
let msgList: RawMessage[];
|
let msgList: RawMessage[];
|
||||||
|
@@ -33,7 +33,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
|||||||
//处理参数
|
//处理参数
|
||||||
const isReverseOrder = payload.reverseOrder || true;
|
const isReverseOrder = payload.reverseOrder || true;
|
||||||
const MsgCount = payload.count || 20;
|
const MsgCount = payload.count || 20;
|
||||||
const peer: Peer = { chatType: ChatType.group, peerUid: payload.group_id.toString() };
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
//拉取消息
|
//拉取消息
|
||||||
let msgList: RawMessage[];
|
let msgList: RawMessage[];
|
||||||
if (!payload.message_seq || payload.message_seq == 0) {
|
if (!payload.message_seq || payload.message_seq == 0) {
|
||||||
|
@@ -36,7 +36,7 @@ export default class GoCQHTTPUploadGroupFile extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
const sendFileEle: SendFileElement = await SendMsgElementConstructor.file(this.CoreContext, downloadResult.path, payload.name, payload.folder_id);
|
const sendFileEle: SendFileElement = await SendMsgElementConstructor.file(this.CoreContext, downloadResult.path, payload.name, payload.folder_id);
|
||||||
await sendMsg(this.CoreContext, {
|
await sendMsg(this.CoreContext, {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: payload.group_id.toString(),
|
peerUid: payload.group_id.toString(),
|
||||||
}, [sendFileEle], [], true);
|
}, [sendFileEle], [], true);
|
||||||
return null;
|
return null;
|
||||||
|
@@ -32,7 +32,7 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null>
|
|||||||
throw `私聊${payload.user_id}不存在`;
|
throw `私聊${payload.user_id}不存在`;
|
||||||
}
|
}
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(peerUid);
|
const isBuddy = await NTQQFriendApi.isBuddy(peerUid);
|
||||||
return { chatType: isBuddy ? ChatType.friend : ChatType.temp, peerUid };
|
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||||
}
|
}
|
||||||
throw '缺少参数 user_id';
|
throw '缺少参数 user_id';
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,9 @@ class ForwardSingleMsg extends BaseAction<Payload, null> {
|
|||||||
if (!peerUid) {
|
if (!peerUid) {
|
||||||
throw new Error(`无法找到私聊对象${payload.user_id}`);
|
throw new Error(`无法找到私聊对象${payload.user_id}`);
|
||||||
}
|
}
|
||||||
return { chatType: ChatType.friend, peerUid };
|
return { chatType: ChatType.KCHATTYPEC2C, peerUid };
|
||||||
}
|
}
|
||||||
return { chatType: ChatType.group, peerUid: payload.group_id!.toString() };
|
return { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id!.toString() };
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
|
@@ -23,12 +23,12 @@ class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
|
|||||||
throw `私聊${payload.user_id}不存在`;
|
throw `私聊${payload.user_id}不存在`;
|
||||||
}
|
}
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(peerUid);
|
const isBuddy = await NTQQFriendApi.isBuddy(peerUid);
|
||||||
return { chatType: isBuddy ? ChatType.friend : ChatType.temp, peerUid };
|
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||||
}
|
}
|
||||||
if (!payload.group_id) {
|
if (!payload.group_id) {
|
||||||
throw '缺少参数 group_id 或 user_id';
|
throw '缺少参数 group_id 或 user_id';
|
||||||
}
|
}
|
||||||
return { chatType: ChatType.group, peerUid: payload.group_id.toString() };
|
return { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: PlayloadType): Promise<null> {
|
async _handle(payload: PlayloadType): Promise<null> {
|
||||||
|
@@ -58,7 +58,7 @@ const _handlers: {
|
|||||||
[OB11MessageDataType.text]: async (coreContext, obContext: NapCatOneBot11Adapter, { data: { text } }) => SendMsgElementConstructor.text(coreContext, text),
|
[OB11MessageDataType.text]: async (coreContext, obContext: NapCatOneBot11Adapter, { data: { text } }) => SendMsgElementConstructor.text(coreContext, text),
|
||||||
|
|
||||||
[OB11MessageDataType.at]: async (coreContext, obContext: NapCatOneBot11Adapter, { data: { qq: atQQ } }, context) => {
|
[OB11MessageDataType.at]: async (coreContext, obContext: NapCatOneBot11Adapter, { data: { qq: atQQ } }, context) => {
|
||||||
if (!context.peer || context.peer.chatType == ChatType.friend) return undefined;
|
if (!context.peer || context.peer.chatType == ChatType.KCHATTYPEGROUP) return undefined;
|
||||||
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
||||||
const NTQQGroupApi = coreContext.apis.GroupApi;
|
const NTQQGroupApi = coreContext.apis.GroupApi;
|
||||||
const NTQQUserApi = coreContext.apis.UserApi;
|
const NTQQUserApi = coreContext.apis.UserApi;
|
||||||
|
@@ -7,7 +7,7 @@ import { NapCatOneBot11Adapter } from '@/onebot';
|
|||||||
|
|
||||||
async function cloneMsg(coreContext: NapCatCore, msg: RawMessage): Promise<RawMessage | undefined> {
|
async function cloneMsg(coreContext: NapCatCore, msg: RawMessage): Promise<RawMessage | undefined> {
|
||||||
const selfPeer = {
|
const selfPeer = {
|
||||||
chatType: ChatType.friend,
|
chatType: ChatType.KCHATTYPEC2C,
|
||||||
peerUid: coreContext.selfInfo.uid,
|
peerUid: coreContext.selfInfo.uid,
|
||||||
};
|
};
|
||||||
const logger = coreContext.context.logger;
|
const logger = coreContext.context.logger;
|
||||||
@@ -34,7 +34,7 @@ async function cloneMsg(coreContext: NapCatCore, msg: RawMessage): Promise<RawMe
|
|||||||
export async function handleForwardNode(coreContext: NapCatCore, obContext: NapCatOneBot11Adapter, destPeer: Peer, messageNodes: OB11MessageNode[]): Promise<RawMessage | null> {
|
export async function handleForwardNode(coreContext: NapCatCore, obContext: NapCatOneBot11Adapter, destPeer: Peer, messageNodes: OB11MessageNode[]): Promise<RawMessage | null> {
|
||||||
const NTQQMsgApi = coreContext.apis.MsgApi;
|
const NTQQMsgApi = coreContext.apis.MsgApi;
|
||||||
const selfPeer = {
|
const selfPeer = {
|
||||||
chatType: ChatType.friend,
|
chatType: ChatType.KCHATTYPEC2C,
|
||||||
peerUid: coreContext.selfInfo.uid,
|
peerUid: coreContext.selfInfo.uid,
|
||||||
};
|
};
|
||||||
let nodeMsgIds: string[] = [];
|
let nodeMsgIds: string[] = [];
|
||||||
|
@@ -92,7 +92,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
|||||||
const NTQQUserApi = coreContext.apis.UserApi;
|
const NTQQUserApi = coreContext.apis.UserApi;
|
||||||
if ((contextMode === ContextMode.Group || contextMode === ContextMode.Normal) && payload.group_id) {
|
if ((contextMode === ContextMode.Group || contextMode === ContextMode.Normal) && payload.group_id) {
|
||||||
return {
|
return {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: payload.group_id.toString(),
|
peerUid: payload.group_id.toString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
|||||||
const isBuddy = await NTQQFriendApi.isBuddy(Uid!);
|
const isBuddy = await NTQQFriendApi.isBuddy(Uid!);
|
||||||
//console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy);
|
//console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy);
|
||||||
return {
|
return {
|
||||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP,
|
||||||
peerUid: Uid!,
|
peerUid: Uid!,
|
||||||
guildId: payload.group_id?.toString() || '',
|
guildId: payload.group_id?.toString() || '',
|
||||||
};
|
};
|
||||||
|
@@ -118,7 +118,7 @@ export class OneBotGroupApi {
|
|||||||
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
||||||
const emojiId = emojiLikeData.gtip.face.id;
|
const emojiId = emojiLikeData.gtip.face.id;
|
||||||
const peer = {
|
const peer = {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: GroupCode
|
peerUid: GroupCode
|
||||||
};
|
};
|
||||||
|
@@ -12,7 +12,7 @@ import { OB11GroupTitleEvent } from "../event/notice/OB11GroupTitleEvent";
|
|||||||
import { NapCatCore, RawMessage, ChatType, NTGrayTipElementSubTypeV2, TipGroupElementType, Peer } from '@/core';
|
import { NapCatCore, RawMessage, ChatType, NTGrayTipElementSubTypeV2, TipGroupElementType, Peer } from '@/core';
|
||||||
|
|
||||||
export async function NT2PrivateEvent(core: NapCatCore, obContext: NapCatOneBot11Adapter, msg: RawMessage): Promise<OB11BaseNoticeEvent | undefined> {
|
export async function NT2PrivateEvent(core: NapCatCore, obContext: NapCatOneBot11Adapter, msg: RawMessage): Promise<OB11BaseNoticeEvent | undefined> {
|
||||||
if (msg.chatType !== ChatType.friend) {
|
if (msg.chatType !== ChatType.KCHATTYPEC2C) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const element of msg.elements) {
|
for (const element of msg.elements) {
|
||||||
@@ -38,7 +38,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
|||||||
const NTQQUserApi = core.apis.UserApi;
|
const NTQQUserApi = core.apis.UserApi;
|
||||||
const NTQQMsgApi = core.apis.MsgApi;
|
const NTQQMsgApi = core.apis.MsgApi;
|
||||||
const logger = core.context.logger;
|
const logger = core.context.logger;
|
||||||
if (msg.chatType !== ChatType.group) {
|
if (msg.chatType !== ChatType.KCHATTYPEGROUP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//log("group msg", msg);
|
//log("group msg", msg);
|
||||||
@@ -124,7 +124,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
|||||||
// const businessId = searchParams.get('businessid');
|
// const businessId = searchParams.get('businessid');
|
||||||
const Peer: Peer = {
|
const Peer: Peer = {
|
||||||
guildId: '',
|
guildId: '',
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: Group!,
|
peerUid: Group!,
|
||||||
};
|
};
|
||||||
const msgData = await NTQQMsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
|
const msgData = await NTQQMsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
|
||||||
|
@@ -28,7 +28,7 @@ export async function RawNTMsg2Onebot(
|
|||||||
message_id: msg.id!,
|
message_id: msg.id!,
|
||||||
message_seq: msg.id!,
|
message_seq: msg.id!,
|
||||||
real_id: msg.id!,
|
real_id: msg.id!,
|
||||||
message_type: msg.chatType == ChatType.group ? 'group' : 'private',
|
message_type: msg.chatType == ChatType.KCHATTYPEGROUP ? 'group' : 'private',
|
||||||
sender: {
|
sender: {
|
||||||
user_id: parseInt(msg.senderUin || '0'),
|
user_id: parseInt(msg.senderUin || '0'),
|
||||||
nickname: msg.sendNickName,
|
nickname: msg.sendNickName,
|
||||||
@@ -41,7 +41,7 @@ export async function RawNTMsg2Onebot(
|
|||||||
message_format: messagePostFormat === 'string' ? 'string' : 'array',
|
message_format: messagePostFormat === 'string' ? 'string' : 'array',
|
||||||
post_type: core.selfInfo.uin == msg.senderUin ? EventType.MESSAGE_SENT : EventType.MESSAGE,
|
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.sub_type = 'normal'; // 这里go-cqhttp是group,而onebot11标准是normal, 蛋疼
|
||||||
resMsg.group_id = parseInt(msg.peerUin);
|
resMsg.group_id = parseInt(msg.peerUin);
|
||||||
//直接去QQNative取
|
//直接去QQNative取
|
||||||
@@ -51,14 +51,14 @@ export async function RawNTMsg2Onebot(
|
|||||||
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
|
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
|
||||||
resMsg.sender.nickname = member.nick;
|
resMsg.sender.nickname = member.nick;
|
||||||
}
|
}
|
||||||
} else if (msg.chatType == ChatType.friend) {
|
} else if (msg.chatType == ChatType.KCHATTYPEC2C) {
|
||||||
resMsg.sub_type = 'friend';
|
resMsg.sub_type = 'friend';
|
||||||
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
|
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
|
||||||
//const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
//const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
||||||
//resMsg.sender.nickname = user.info.nick;
|
//resMsg.sender.nickname = user.info.nick;
|
||||||
} else if (msg.chatType == ChatType.temp) {
|
} else if (msg.chatType == ChatType.KCHATTYPETEMPC2CFROMGROUP) {
|
||||||
resMsg.sub_type = 'group';
|
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) {
|
if (ret.result === 0) {
|
||||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
||||||
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick;
|
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick;
|
||||||
|
@@ -20,15 +20,15 @@ async function handleMsg(coreContext: NapCatCore, obContext: NapCatOneBot11Adapt
|
|||||||
msg = msg as OB11Message;
|
msg = msg as OB11Message;
|
||||||
const reply = quickAction.reply;
|
const reply = quickAction.reply;
|
||||||
const peer: Peer = {
|
const peer: Peer = {
|
||||||
chatType: ChatType.friend,
|
chatType: ChatType.KCHATTYPEC2C,
|
||||||
peerUid: await coreContext.apis.UserApi.getUidByUinV2(msg.user_id.toString()) as string,
|
peerUid: await coreContext.apis.UserApi.getUidByUinV2(msg.user_id.toString()) as string,
|
||||||
};
|
};
|
||||||
if (msg.message_type == 'private') {
|
if (msg.message_type == 'private') {
|
||||||
if (msg.sub_type === 'group') {
|
if (msg.sub_type === 'group') {
|
||||||
peer.chatType = ChatType.temp;
|
peer.chatType = ChatType.KCHATTYPETEMPC2CFROMGROUP;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
peer.chatType = ChatType.group;
|
peer.chatType = ChatType.KCHATTYPETEMPC2CFROMGROUP;
|
||||||
peer.peerUid = msg.group_id!.toString();
|
peer.peerUid = msg.group_id!.toString();
|
||||||
}
|
}
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
@@ -492,7 +492,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
if (!oriMessageId) {
|
if (!oriMessageId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (message.chatType == ChatType.friend) {
|
if (message.chatType == ChatType.KCHATTYPEC2C) {
|
||||||
const friendRecallEvent = new OB11FriendRecallNoticeEvent(
|
const friendRecallEvent = new OB11FriendRecallNoticeEvent(
|
||||||
this.core,
|
this.core,
|
||||||
parseInt(message!.senderUin),
|
parseInt(message!.senderUin),
|
||||||
@@ -500,7 +500,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
);
|
);
|
||||||
this.networkManager.emitEvent(friendRecallEvent)
|
this.networkManager.emitEvent(friendRecallEvent)
|
||||||
.catch(e => this.context.logger.logError('处理好友消息撤回失败', e));
|
.catch(e => this.context.logger.logError('处理好友消息撤回失败', e));
|
||||||
} else if (message.chatType == ChatType.group) {
|
} else if (message.chatType == ChatType.KCHATTYPETEMPC2CFROMGROUP) {
|
||||||
let operatorId = message.senderUin;
|
let operatorId = message.senderUin;
|
||||||
for (const element of message.elements) {
|
for (const element of message.elements) {
|
||||||
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
|
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
|
||||||
|
Reference in New Issue
Block a user