mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c45f0dc289 | ||
![]() |
433ce9caef | ||
![]() |
ba1acd624e | ||
![]() |
a586796339 | ||
![]() |
2016a90198 | ||
![]() |
b4bc4da7fc | ||
![]() |
52c828192e |
BIN
external/LiteLoaderWrapper.zip
vendored
BIN
external/LiteLoaderWrapper.zip
vendored
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
"name": "NapCatQQ",
|
||||
"slug": "NapCat.Framework",
|
||||
"description": "高性能的 OneBot 11 协议实现",
|
||||
"version": "4.7.76",
|
||||
"version": "4.7.63",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -92,9 +92,7 @@ const MusicInsert = () => {
|
||||
className="w-96"
|
||||
fullWidth
|
||||
selectedKey={mode}
|
||||
onSelectionChange={(key) => {
|
||||
if (key !== null) setMode(key)
|
||||
}}
|
||||
onSelectionChange={setMode}
|
||||
>
|
||||
<Tab title="主流平台" key="default" className="flex flex-col gap-2">
|
||||
<Select
|
||||
|
@@ -24,7 +24,9 @@ const oneBotHttpApiGroup = {
|
||||
},
|
||||
'/get_group_system_msg': {
|
||||
description: '获取群系统消息',
|
||||
request: z.object({}),
|
||||
request: z.object({
|
||||
group_id: z.union([z.string(), z.number()]).describe('群号')
|
||||
}),
|
||||
response: baseResponseSchema.extend({
|
||||
data: z.object({
|
||||
InvitedRequest: z
|
||||
@@ -35,7 +37,6 @@ const oneBotHttpApiGroup = {
|
||||
invitor_uin: z.string().describe('邀请人 QQ 号'),
|
||||
invitor_nick: z.string().describe('邀请人昵称'),
|
||||
group_id: z.string().describe('群号'),
|
||||
message: z.string().describe('入群回答'),
|
||||
group_name: z.string().describe('群名称'),
|
||||
checked: z.boolean().describe('是否已处理'),
|
||||
actor: z.string().describe('处理人 QQ 号')
|
||||
@@ -49,7 +50,6 @@ const oneBotHttpApiGroup = {
|
||||
requester_uin: z.string().describe('请求人 QQ 号'),
|
||||
requester_nick: z.string().describe('请求人昵称'),
|
||||
group_id: z.string().describe('群号'),
|
||||
message: z.string().describe('入群回答'),
|
||||
group_name: z.string().describe('群名称'),
|
||||
checked: z.boolean().describe('是否已处理'),
|
||||
actor: z.string().describe('处理人 QQ 号')
|
||||
|
@@ -56,9 +56,9 @@ export default function TerminalPage() {
|
||||
|
||||
setTabs((prev) => [...prev, newTab])
|
||||
setSelectedTab(id)
|
||||
} catch (error: unknown) {
|
||||
} catch (error) {
|
||||
console.error('Failed to create terminal:', error)
|
||||
toast.error((error as Error).message)
|
||||
toast.error('创建终端失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "4.7.76",
|
||||
"version": "4.7.63",
|
||||
"scripts": {
|
||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||
@@ -42,16 +42,16 @@
|
||||
"async-mutex": "^0.5.0",
|
||||
"commander": "^13.0.0",
|
||||
"cors": "^2.8.5",
|
||||
"esbuild": "0.25.5",
|
||||
"esbuild": "0.25.4",
|
||||
"eslint": "^9.14.0",
|
||||
"eslint-import-resolver-typescript": "^4.0.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"express-rate-limit": "^7.5.0",
|
||||
"fast-xml-parser": "^4.3.6",
|
||||
"file-type": "^21.0.0",
|
||||
"file-type": "^20.0.0",
|
||||
"globals": "^16.0.0",
|
||||
"json5": "^2.2.3",
|
||||
"multer": "^2.0.1",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript-eslint": "^8.13.0",
|
||||
"vite": "^6.0.1",
|
||||
|
@@ -8,12 +8,12 @@ import { pipeline } from 'stream/promises';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { LogWrapper } from './log';
|
||||
|
||||
const downloadOri = "https://github.com/NapNeko/ffmpeg-build/releases/download/v1.0.0/ffmpeg-7.1.1-win64.zip"
|
||||
const downloadOri = 'https://github.com/NapNeko/ffmpeg-build/releases/download/v1.0.0/ffmpeg-7.1.1-win64.zip';
|
||||
const urls = [
|
||||
"https://github.moeyy.xyz/" + downloadOri,
|
||||
"https://ghp.ci/" + downloadOri,
|
||||
"https://gh.api.99988866.xyz/" + downloadOri,
|
||||
"https://gh.api.99988866.xyz/" + downloadOri,
|
||||
'https://github.moeyy.xyz/' + downloadOri,
|
||||
'https://ghp.ci/' + downloadOri,
|
||||
'https://gh.api.99988866.xyz/' + downloadOri,
|
||||
'https://gh.api.99988866.xyz/' + downloadOri,
|
||||
downloadOri
|
||||
];
|
||||
|
||||
@@ -350,11 +350,11 @@ export async function downloadFFmpegIfNotExists(log: LogWrapper) {
|
||||
return {
|
||||
path: path.join(currentPath, 'ffmpeg'),
|
||||
reset: true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
path: path.join(currentPath, 'ffmpeg'),
|
||||
reset: true
|
||||
}
|
||||
};
|
||||
}
|
@@ -182,28 +182,28 @@ export async function uriToLocalFile(dir: string, uri: string, filename: string
|
||||
const filePath = path.join(dir, filename);
|
||||
|
||||
switch (UriType) {
|
||||
case FileUriType.Local: {
|
||||
const fileExt = path.extname(HandledUri);
|
||||
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
||||
const tempFilePath = path.join(dir, filename + fileExt);
|
||||
fs.copyFileSync(HandledUri, tempFilePath);
|
||||
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
||||
}
|
||||
case FileUriType.Local: {
|
||||
const fileExt = path.extname(HandledUri);
|
||||
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
||||
const tempFilePath = path.join(dir, filename + fileExt);
|
||||
fs.copyFileSync(HandledUri, tempFilePath);
|
||||
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
||||
}
|
||||
|
||||
case FileUriType.Remote: {
|
||||
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||
}
|
||||
case FileUriType.Remote: {
|
||||
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||
}
|
||||
|
||||
case FileUriType.Base64: {
|
||||
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
||||
const base64Buffer = Buffer.from(base64, 'base64');
|
||||
fs.writeFileSync(filePath, base64Buffer);
|
||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||
}
|
||||
case FileUriType.Base64: {
|
||||
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
||||
const base64Buffer = Buffer.from(base64, 'base64');
|
||||
fs.writeFileSync(filePath, base64Buffer);
|
||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||
}
|
||||
|
||||
default:
|
||||
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
||||
default:
|
||||
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,4 @@
|
||||
import { Peer } from '@/core';
|
||||
import crypto from 'crypto';
|
||||
|
||||
export class LimitedHashTable<K, V> {
|
||||
private readonly keyToValue: Map<K, V> = new Map();
|
||||
private readonly valueToKey: Map<V, K> = new Map();
|
||||
@@ -78,65 +76,19 @@ export class LimitedHashTable<K, V> {
|
||||
}
|
||||
|
||||
class MessageUniqueWrapper {
|
||||
private readonly msgDataMap: LimitedHashTable<string, number>;
|
||||
private readonly msgIdMap: LimitedHashTable<string, number>;
|
||||
|
||||
constructor(maxMap: number = 5000) {
|
||||
this.msgIdMap = new LimitedHashTable<string, number>(maxMap);
|
||||
this.msgDataMap = new LimitedHashTable<string, number>(maxMap);
|
||||
constructor() {
|
||||
}
|
||||
|
||||
getRecentMsgIds(Peer: Peer, size: number): string[] {
|
||||
const heads = this.msgIdMap.getHeads(size);
|
||||
if (!heads) {
|
||||
return [];
|
||||
getOutputData(peer: Peer, msg_id: string, seq: string): string {
|
||||
return `${peer.chatType}|${msg_id}|${peer.peerUid}|${seq}`;
|
||||
}
|
||||
|
||||
getInnerData(shortId: string): { MsgId: string; Peer: Peer, seq: string } | undefined {
|
||||
const [chatType, msgId, peerUid, seq] = shortId.split('|');
|
||||
if (!chatType || !msgId || !peerUid || !seq) {
|
||||
return undefined;
|
||||
}
|
||||
const data = heads.map((t) => MessageUnique.getMsgIdAndPeerByShortId(t.value));
|
||||
const ret = data.filter((t) => t?.Peer.chatType === Peer.chatType && t?.Peer.peerUid === Peer.peerUid);
|
||||
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined);
|
||||
}
|
||||
|
||||
createUniqueMsgId(peer: Peer, msgId: string) {
|
||||
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`;
|
||||
const hash = crypto.createHash('md5').update(key).digest();
|
||||
if (hash[0]) {
|
||||
//设置第一个bit为0 保证shortId为正数
|
||||
hash[0] &= 0x7f;
|
||||
}
|
||||
const shortId = hash.readInt32BE(0);
|
||||
//减少性能损耗
|
||||
this.msgIdMap.set(msgId, shortId);
|
||||
this.msgDataMap.set(key, shortId);
|
||||
return shortId;
|
||||
}
|
||||
|
||||
getMsgIdAndPeerByShortId(shortId: number): { MsgId: string; Peer: Peer } | undefined {
|
||||
const data = this.msgDataMap.getKey(shortId);
|
||||
if (data) {
|
||||
const [msgId, chatTypeStr, peerUid] = data.split('|');
|
||||
const peer: Peer = {
|
||||
chatType: parseInt(chatTypeStr ?? '0'),
|
||||
peerUid: peerUid ?? '',
|
||||
guildId: '',
|
||||
};
|
||||
return { MsgId: msgId ?? '0', Peer: peer };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getShortIdByMsgId(msgId: string): number | undefined {
|
||||
return this.msgIdMap.getValue(msgId);
|
||||
}
|
||||
|
||||
getPeerByMsgId(msgId: string) {
|
||||
const shortId = this.msgIdMap.getValue(msgId);
|
||||
if (!shortId) return undefined;
|
||||
return this.getMsgIdAndPeerByShortId(shortId);
|
||||
}
|
||||
|
||||
resize(maxSize: number): void {
|
||||
this.msgIdMap.resize(maxSize);
|
||||
this.msgDataMap.resize(maxSize);
|
||||
return { MsgId: msgId, Peer: { chatType: parseInt(chatType), peerUid, guildId: '' }, seq: seq };
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,15 +13,11 @@ export class NapCatPathWrapper {
|
||||
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
||||
this.binaryPath = mainPath;
|
||||
let writePath: string;
|
||||
|
||||
if (process.env['NAPCAT_WORKDIR']) {
|
||||
writePath = process.env['NAPCAT_WORKDIR'];
|
||||
} else if (os.platform() === 'darwin') {
|
||||
if (os.platform() === 'darwin') {
|
||||
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
||||
} else {
|
||||
writePath = this.binaryPath;
|
||||
}
|
||||
|
||||
this.logsPath = path.join(writePath, 'logs');
|
||||
this.configPath = path.join(writePath, 'config');
|
||||
this.cachePath = path.join(writePath, 'cache');
|
||||
|
@@ -1 +1 @@
|
||||
export const napCatVersion = '4.7.76';
|
||||
export const napCatVersion = '4.7.63';
|
||||
|
@@ -9,7 +9,7 @@ export async function runTask<T, R>(workerScript: string, taskData: T): Promise<
|
||||
console.error('Worker Log--->:', (result as { log: string }).log);
|
||||
}
|
||||
if ((result as any)?.error) {
|
||||
reject(new Error("Worker error: " + (result as { error: string }).error));
|
||||
reject(new Error('Worker error: ' + (result as { error: string }).error));
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
|
@@ -45,7 +45,7 @@ export class NTQQFileApi {
|
||||
'https://secret-service.bietiaop.com/rkeys',
|
||||
'http://ss.xingzhige.com/music_card/rkey',
|
||||
],
|
||||
this.context.logger
|
||||
this.context.logger
|
||||
);
|
||||
}
|
||||
|
||||
@@ -379,18 +379,18 @@ export class NTQQFileApi {
|
||||
element.elementType === ElementType.FILE
|
||||
) {
|
||||
switch (element.elementType) {
|
||||
case ElementType.PIC:
|
||||
case ElementType.PIC:
|
||||
element.picElement!.sourcePath = elementResults?.[elementIndex] ?? '';
|
||||
break;
|
||||
case ElementType.VIDEO:
|
||||
break;
|
||||
case ElementType.VIDEO:
|
||||
element.videoElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||
break;
|
||||
case ElementType.PTT:
|
||||
break;
|
||||
case ElementType.PTT:
|
||||
element.pttElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||
break;
|
||||
case ElementType.FILE:
|
||||
break;
|
||||
case ElementType.FILE:
|
||||
element.fileElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||
break;
|
||||
break;
|
||||
}
|
||||
elementIndex++;
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ export class NTQQFriendApi {
|
||||
time: item.reqTime, // 信息字段
|
||||
type: 'doubt' //保留字段
|
||||
};
|
||||
}))
|
||||
}));
|
||||
return requests;
|
||||
}
|
||||
}
|
||||
|
@@ -10,14 +10,11 @@ import {
|
||||
GroupNotify,
|
||||
GroupInfoSource,
|
||||
ShutUpGroupMember,
|
||||
Peer,
|
||||
ChatType,
|
||||
} from '@/core';
|
||||
import { isNumeric, solveAsyncProblem } from '@/common/helper';
|
||||
import { LimitedHashTable } from '@/common/message-unique';
|
||||
import { NTEventWrapper } from '@/common/event';
|
||||
import { CancelableTask, TaskExecutor } from '@/common/cancel-task';
|
||||
import { createGroupDetailInfoV2Param, createGroupExtFilter, createGroupExtInfo } from '../data';
|
||||
|
||||
export class NTQQGroupApi {
|
||||
context: InstanceContext;
|
||||
@@ -50,22 +47,6 @@ export class NTQQGroupApi {
|
||||
this.initCache().then().catch(e => this.context.logger.logError(e));
|
||||
}
|
||||
|
||||
async createGrayTip(groupCode: string, tip: string) {
|
||||
return this.context.session.getMsgService().addLocalJsonGrayTipMsg(
|
||||
{
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: groupCode,
|
||||
} as Peer,
|
||||
{
|
||||
busiId: 2201,
|
||||
jsonStr: JSON.stringify({ "align": "center", "items": [{ "txt": tip, "type": "nor" }] }),
|
||||
recentAbstract: tip,
|
||||
isServer: false
|
||||
},
|
||||
true,
|
||||
true
|
||||
)
|
||||
}
|
||||
async initCache() {
|
||||
for (const group of await this.getGroups(true)) {
|
||||
this.refreshGroupMemberCache(group.groupCode, false).then().catch(e => this.context.logger.logError(e));
|
||||
@@ -114,58 +95,6 @@ export class NTQQGroupApi {
|
||||
return this.context.session.getGroupService().setHeader(groupCode, filePath);
|
||||
}
|
||||
|
||||
// 0 0 无需管理员审核
|
||||
// 0 2 需要管理员审核
|
||||
// 1 2 禁止Bot入群( 最好只传一个1 ?)
|
||||
async setGroupRobotAddOption(groupCode: string, robotMemberSwitch?: number, robotMemberExamine?: number) {
|
||||
let extInfo = createGroupExtInfo(groupCode);
|
||||
let groupExtFilter = createGroupExtFilter();
|
||||
if (robotMemberSwitch !== undefined) {
|
||||
extInfo.extInfo.inviteRobotMemberSwitch = robotMemberSwitch;
|
||||
groupExtFilter.inviteRobotMemberSwitch = 1;
|
||||
}
|
||||
if (robotMemberExamine !== undefined) {
|
||||
extInfo.extInfo.inviteRobotMemberExamine = robotMemberExamine;
|
||||
groupExtFilter.inviteRobotMemberExamine = 1;
|
||||
}
|
||||
return this.context.session.getGroupService().modifyGroupExtInfoV2(extInfo, groupExtFilter);
|
||||
}
|
||||
|
||||
async setGroupAddOption(groupCode: string, option: {
|
||||
addOption: number;
|
||||
groupQuestion?: string;
|
||||
groupAnswer?: string;
|
||||
}) {
|
||||
let param = createGroupDetailInfoV2Param(groupCode);
|
||||
// 设置要修改的目标
|
||||
param.filter.addOption = 1;
|
||||
if (option.addOption == 4 || option.addOption == 5) {
|
||||
// 4 问题进入答案 5 问题管理员批准
|
||||
param.filter.groupQuestion = 1;
|
||||
param.filter.groupAnswer = option.addOption == 4 ? 1 : 0;
|
||||
param.modifyInfo.groupQuestion = option.groupQuestion || '';
|
||||
param.modifyInfo.groupAnswer = option.addOption == 4 ? option.groupAnswer || '' : '';
|
||||
}
|
||||
param.modifyInfo.addOption = option.addOption;
|
||||
return this.context.session.getGroupService().modifyGroupDetailInfoV2(param, 0);
|
||||
}
|
||||
|
||||
async setGroupSearch(groupCode: string, option: {
|
||||
noCodeFingerOpenFlag?: number;
|
||||
noFingerOpenFlag?: number;
|
||||
}) {
|
||||
let param = createGroupDetailInfoV2Param(groupCode);
|
||||
if (option.noCodeFingerOpenFlag) {
|
||||
param.filter.noCodeFingerOpenFlag = 1;
|
||||
param.modifyInfo.noCodeFingerOpenFlag = option.noCodeFingerOpenFlag;
|
||||
}
|
||||
if (option.noFingerOpenFlag) {
|
||||
param.filter.noFingerOpenFlag = 1;
|
||||
param.modifyInfo.noFingerOpenFlag = option.noFingerOpenFlag;
|
||||
}
|
||||
return this.context.session.getGroupService().modifyGroupDetailInfoV2(param, 0);
|
||||
}
|
||||
|
||||
async getGroups(forced: boolean = false) {
|
||||
const [, , groupList] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelGroupService/getGroupList',
|
||||
|
@@ -1,245 +0,0 @@
|
||||
import { GroupDetailInfoV2Param, GroupExtInfo, GroupExtFilter } from "../types";
|
||||
|
||||
export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInfoV2Param {
|
||||
return {
|
||||
groupCode: group_code,
|
||||
filter:
|
||||
{
|
||||
noCodeFingerOpenFlag: 0,
|
||||
noFingerOpenFlag: 0,
|
||||
groupName: 0,
|
||||
classExt: 0,
|
||||
classText: 0,
|
||||
fingerMemo: 0,
|
||||
richFingerMemo: 0,
|
||||
tagRecord: 0,
|
||||
groupGeoInfo:
|
||||
{
|
||||
ownerUid: 0,
|
||||
setTime: 0,
|
||||
cityId: 0,
|
||||
longitude: 0,
|
||||
latitude: 0,
|
||||
geoContent: 0,
|
||||
poiId: 0
|
||||
},
|
||||
groupExtAdminNum: 0,
|
||||
flag: 0,
|
||||
groupMemo: 0,
|
||||
groupAioSkinUrl: 0,
|
||||
groupBoardSkinUrl: 0,
|
||||
groupCoverSkinUrl: 0,
|
||||
groupGrade: 0,
|
||||
activeMemberNum: 0,
|
||||
certificationType: 0,
|
||||
certificationText: 0,
|
||||
groupNewGuideLines:
|
||||
{
|
||||
enabled: 0,
|
||||
content: 0
|
||||
},
|
||||
groupFace: 0,
|
||||
addOption: 0,
|
||||
shutUpTime: 0,
|
||||
groupTypeFlag: 0,
|
||||
appPrivilegeFlag: 0,
|
||||
appPrivilegeMask: 0,
|
||||
groupExtOnly:
|
||||
{
|
||||
tribeId: 0,
|
||||
moneyForAddGroup: 0
|
||||
}, groupSecLevel: 0,
|
||||
groupSecLevelInfo: 0,
|
||||
subscriptionUin: 0,
|
||||
subscriptionUid: "",
|
||||
allowMemberInvite: 0,
|
||||
groupQuestion: 0,
|
||||
groupAnswer: 0,
|
||||
groupFlagExt3: 0,
|
||||
groupFlagExt3Mask: 0,
|
||||
groupOpenAppid: 0,
|
||||
rootId: 0,
|
||||
msgLimitFrequency: 0,
|
||||
hlGuildAppid: 0,
|
||||
hlGuildSubType: 0,
|
||||
hlGuildOrgId: 0,
|
||||
groupFlagExt4: 0,
|
||||
groupFlagExt4Mask: 0,
|
||||
groupSchoolInfo: {
|
||||
location: 0,
|
||||
grade: 0,
|
||||
school: 0
|
||||
},
|
||||
groupCardPrefix:
|
||||
{
|
||||
introduction: 0,
|
||||
rptPrefix: 0
|
||||
}, allianceId: 0,
|
||||
groupFlagPro1: 0,
|
||||
groupFlagPro1Mask: 0
|
||||
},
|
||||
modifyInfo: {
|
||||
noCodeFingerOpenFlag: 0,
|
||||
noFingerOpenFlag: 0,
|
||||
groupName: "",
|
||||
classExt: 0,
|
||||
classText: "",
|
||||
fingerMemo: "",
|
||||
richFingerMemo: "",
|
||||
tagRecord: [],
|
||||
groupGeoInfo: {
|
||||
ownerUid: "",
|
||||
SetTime: 0,
|
||||
CityId: 0,
|
||||
Longitude: "",
|
||||
Latitude: "",
|
||||
GeoContent: "",
|
||||
poiId: ""
|
||||
},
|
||||
groupExtAdminNum: 0,
|
||||
flag: 0,
|
||||
groupMemo: "",
|
||||
groupAioSkinUrl: "",
|
||||
groupBoardSkinUrl: "",
|
||||
groupCoverSkinUrl: "",
|
||||
groupGrade: 0,
|
||||
activeMemberNum: 0,
|
||||
certificationType: 0,
|
||||
certificationText: "",
|
||||
groupNewGuideLines: {
|
||||
enabled: false,
|
||||
content: ""
|
||||
}, groupFace: 0,
|
||||
addOption: 0,
|
||||
shutUpTime: 0,
|
||||
groupTypeFlag: 0,
|
||||
appPrivilegeFlag: 0,
|
||||
appPrivilegeMask: 0,
|
||||
groupExtOnly: {
|
||||
tribeId: 0,
|
||||
moneyForAddGroup: 0
|
||||
},
|
||||
groupSecLevel: 0,
|
||||
groupSecLevelInfo: 0,
|
||||
subscriptionUin: "",
|
||||
subscriptionUid: "",
|
||||
allowMemberInvite: 0,
|
||||
groupQuestion: "",
|
||||
groupAnswer: "",
|
||||
groupFlagExt3: 0,
|
||||
groupFlagExt3Mask: 0,
|
||||
groupOpenAppid: 0,
|
||||
rootId: "",
|
||||
msgLimitFrequency: 0,
|
||||
hlGuildAppid: 0,
|
||||
hlGuildSubType: 0,
|
||||
hlGuildOrgId: 0,
|
||||
groupFlagExt4: 0,
|
||||
groupFlagExt4Mask: 0,
|
||||
groupSchoolInfo: {
|
||||
location: "",
|
||||
grade: 0,
|
||||
school: ""
|
||||
},
|
||||
groupCardPrefix:
|
||||
{
|
||||
introduction: "",
|
||||
rptPrefix: []
|
||||
},
|
||||
allianceId: "",
|
||||
groupFlagPro1: 0,
|
||||
groupFlagPro1Mask: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
export function createGroupExtInfo(group_code: string): GroupExtInfo {
|
||||
return {
|
||||
groupCode: group_code,
|
||||
resultCode: 0,
|
||||
extInfo: {
|
||||
groupInfoExtSeq: 0,
|
||||
reserve: 0,
|
||||
luckyWordId: '',
|
||||
lightCharNum: 0,
|
||||
luckyWord: '',
|
||||
starId: 0,
|
||||
essentialMsgSwitch: 0,
|
||||
todoSeq: 0,
|
||||
blacklistExpireTime: 0,
|
||||
isLimitGroupRtc: 0,
|
||||
companyId: 0,
|
||||
hasGroupCustomPortrait: 0,
|
||||
bindGuildId: '',
|
||||
groupOwnerId: {
|
||||
memberUin: '',
|
||||
memberUid: '',
|
||||
memberQid: '',
|
||||
},
|
||||
essentialMsgPrivilege: 0,
|
||||
msgEventSeq: '',
|
||||
inviteRobotSwitch: 0,
|
||||
gangUpId: '',
|
||||
qqMusicMedalSwitch: 0,
|
||||
showPlayTogetherSwitch: 0,
|
||||
groupFlagPro1: '',
|
||||
groupBindGuildIds: {
|
||||
guildIds: [],
|
||||
},
|
||||
viewedMsgDisappearTime: '',
|
||||
groupExtFlameData: {
|
||||
switchState: 0,
|
||||
state: 0,
|
||||
dayNums: [],
|
||||
version: 0,
|
||||
updateTime: '',
|
||||
isDisplayDayNum: false,
|
||||
},
|
||||
groupBindGuildSwitch: 0,
|
||||
groupAioBindGuildId: '',
|
||||
groupExcludeGuildIds: {
|
||||
guildIds: [],
|
||||
},
|
||||
fullGroupExpansionSwitch: 0,
|
||||
fullGroupExpansionSeq: '',
|
||||
inviteRobotMemberSwitch: 0,
|
||||
inviteRobotMemberExamine: 0,
|
||||
groupSquareSwitch: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
export function createGroupExtFilter(): GroupExtFilter {
|
||||
return {
|
||||
groupInfoExtSeq: 0,
|
||||
reserve: 0,
|
||||
luckyWordId: 0,
|
||||
lightCharNum: 0,
|
||||
luckyWord: 0,
|
||||
starId: 0,
|
||||
essentialMsgSwitch: 0,
|
||||
todoSeq: 0,
|
||||
blacklistExpireTime: 0,
|
||||
isLimitGroupRtc: 0,
|
||||
companyId: 0,
|
||||
hasGroupCustomPortrait: 0,
|
||||
bindGuildId: 0,
|
||||
groupOwnerId: 0,
|
||||
essentialMsgPrivilege: 0,
|
||||
msgEventSeq: 0,
|
||||
inviteRobotSwitch: 0,
|
||||
gangUpId: 0,
|
||||
qqMusicMedalSwitch: 0,
|
||||
showPlayTogetherSwitch: 0,
|
||||
groupFlagPro1: 0,
|
||||
groupBindGuildIds: 0,
|
||||
viewedMsgDisappearTime: 0,
|
||||
groupExtFlameData: 0,
|
||||
groupBindGuildSwitch: 0,
|
||||
groupAioBindGuildId: 0,
|
||||
groupExcludeGuildIds: 0,
|
||||
fullGroupExpansionSwitch: 0,
|
||||
fullGroupExpansionSeq: 0,
|
||||
inviteRobotMemberSwitch: 0,
|
||||
inviteRobotMemberExamine: 0,
|
||||
groupSquareSwitch: 0,
|
||||
}
|
||||
};
|
@@ -1 +0,0 @@
|
||||
export * from "./group";
|
20
src/core/external/appid.json
vendored
20
src/core/external/appid.json
vendored
@@ -294,25 +294,5 @@
|
||||
"9.9.19-35184": {
|
||||
"appid": 537291048,
|
||||
"qua": "V1_WIN_NQ_9.9.19_35184_GW_B"
|
||||
},
|
||||
"3.2.17-35341": {
|
||||
"appid": 537291383,
|
||||
"qua": "V1_LNX_NQ_3.2.17_35341_GW_B"
|
||||
},
|
||||
"9.9.19-35341": {
|
||||
"appid": 537291347,
|
||||
"qua": "V1_WIN_NQ_9.9.19_35341_GW_B"
|
||||
},
|
||||
"9.9.19-35469": {
|
||||
"appid": 537291398,
|
||||
"qua": "V1_WIN_NQ_9.9.19_35469_GW_B"
|
||||
},
|
||||
"3.2.18-35951": {
|
||||
"appid": 537296013,
|
||||
"qua": "V1_LNX_NQ_3.2.18_35951_GW_B"
|
||||
},
|
||||
"9.9.20-35951": {
|
||||
"appid": 537295977,
|
||||
"qua": "V1_WIN_NQ_9.9.20_35951_GW_B"
|
||||
}
|
||||
}
|
24
src/core/external/offset.json
vendored
24
src/core/external/offset.json
vendored
@@ -378,29 +378,5 @@
|
||||
"9.9.19-35184-x64": {
|
||||
"send": "3BE5A10",
|
||||
"recv": "3BEA210"
|
||||
},
|
||||
"9.9.19-35341-x64": {
|
||||
"send": "3BF1D50",
|
||||
"recv": "3BF6550"
|
||||
},
|
||||
"9.9.19-35469-x64": {
|
||||
"send": "3BF1D50",
|
||||
"recv": "3BF6550"
|
||||
},
|
||||
"3.2.17-35341-x64": {
|
||||
"send": "AE2F700",
|
||||
"recv": "AE33120"
|
||||
},
|
||||
"3.2.17-35341-arm64": {
|
||||
"send": "778D840",
|
||||
"recv": "7791170"
|
||||
},
|
||||
"9.9.20-35951-x64": {
|
||||
"send": "3038354",
|
||||
"recv": "3C1E1D0"
|
||||
},
|
||||
"3.2.18-35951-x64": {
|
||||
"send": "AFBBB00",
|
||||
"recv": "AFBF520"
|
||||
}
|
||||
}
|
@@ -30,8 +30,13 @@ export class PacketOperationContext {
|
||||
return await this.context.client.sendOidbPacket(pkt, rsp);
|
||||
}
|
||||
|
||||
async SendPoke(is_group: boolean, peer: number, target?: number) {
|
||||
const req = trans.SendPoke.build(is_group, peer, target ?? peer);
|
||||
async GroupPoke(groupUin: number, uin: number) {
|
||||
const req = trans.SendPoke.build(uin, groupUin);
|
||||
await this.context.client.sendOidbPacket(req);
|
||||
}
|
||||
|
||||
async FriendPoke(uin: number) {
|
||||
const req = trans.SendPoke.build(uin);
|
||||
await this.context.client.sendOidbPacket(req);
|
||||
}
|
||||
|
||||
@@ -180,9 +185,9 @@ export class PacketOperationContext {
|
||||
const ps = msg.map((m) => {
|
||||
return m.msg.map(async (e) => {
|
||||
if (e instanceof PacketMsgReplyElement && !e.targetElems) {
|
||||
this.context.logger.debug(`Cannot find reply element's targetElems, prepare to fetch it...`);
|
||||
this.context.logger.debug('Cannot find reply element\'s targetElems, prepare to fetch it...');
|
||||
if (!e.targetPeer?.peerUid) {
|
||||
this.context.logger.error(`targetPeer is undefined!`);
|
||||
this.context.logger.error('targetPeer is undefined!');
|
||||
}
|
||||
let targetMsg: NapProtoEncodeStructType<typeof PushMsgBody>[] | undefined;
|
||||
if (e.isGroupReply) {
|
||||
@@ -195,7 +200,7 @@ export class PacketOperationContext {
|
||||
}
|
||||
});
|
||||
}).flat();
|
||||
await Promise.all(ps)
|
||||
await Promise.all(ps);
|
||||
await this.UploadResources(msg, groupUin);
|
||||
}
|
||||
|
||||
@@ -203,14 +208,14 @@ export class PacketOperationContext {
|
||||
const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq);
|
||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||
const res = trans.FetchGroupMessage.parse(resp);
|
||||
return res.body.messages
|
||||
return res.body.messages;
|
||||
}
|
||||
|
||||
async FetchC2CMessage(targetUid: string, startSeq: number, endSeq: number): Promise<NapProtoDecodeStructType<typeof PushMsgBody>[]> {
|
||||
const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq);
|
||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||
const res = trans.FetchC2CMessage.parse(resp);
|
||||
return res.messages
|
||||
return res.messages;
|
||||
}
|
||||
|
||||
async UploadForwardMsg(msg: PacketMsg[], groupUin: number = 0) {
|
||||
|
@@ -8,13 +8,13 @@ class SendPoke extends PacketTransformer<typeof proto.OidbSvcTrpcTcpBase> {
|
||||
super();
|
||||
}
|
||||
|
||||
build(is_group: boolean, peer: number, target: number): OidbPacket {
|
||||
const payload = {
|
||||
uin: target,
|
||||
ext: 0,
|
||||
...(is_group ? { groupUin: peer } : { friendUin: peer })
|
||||
};
|
||||
const data = new NapProtoMsg(proto.OidbSvcTrpcTcp0XED3_1).encode(payload);
|
||||
build(peer: number, group?: number): OidbPacket {
|
||||
const data = new NapProtoMsg(proto.OidbSvcTrpcTcp0XED3_1).encode({
|
||||
uin: peer,
|
||||
groupUin: group,
|
||||
friendUin: group ?? peer,
|
||||
ext: 0
|
||||
});
|
||||
return OidbBase.build(0xED3, 1, data);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@ class OidbBase extends PacketTransformer<typeof proto.OidbSvcTrpcTcpBase> {
|
||||
super();
|
||||
}
|
||||
|
||||
build(cmd: number, subCmd: number, body: Uint8Array, isUid: boolean = true, _isLafter: boolean = false): OidbPacket {
|
||||
build(cmd: number, subCmd: number, body: Uint8Array, isUid: boolean = true, isLafter: boolean = false): OidbPacket {
|
||||
const data = new NapProtoMsg(proto.OidbSvcTrpcTcpBase).encode({
|
||||
command: cmd,
|
||||
subCommand: subCmd,
|
||||
|
@@ -8,22 +8,10 @@ import {
|
||||
GroupNotifyMsgType,
|
||||
NTGroupRequestOperateTypes,
|
||||
KickMemberV2Req,
|
||||
GroupDetailInfoV2Param,
|
||||
GroupExtInfo,
|
||||
GroupExtFilter,
|
||||
} from '@/core/types';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
export interface NodeIKernelGroupService {
|
||||
|
||||
modifyGroupExtInfoV2(groupExtInfo: GroupExtInfo, groupExtFilter: GroupExtFilter): Promise<GeneralCallResult &
|
||||
{
|
||||
result: {
|
||||
groupCode: string,
|
||||
result: number
|
||||
}
|
||||
}>;
|
||||
|
||||
// --->
|
||||
// 待启用 For Next Version 3.2.0
|
||||
// isTroopMember ? 0 : 111
|
||||
@@ -181,9 +169,6 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
modifyGroupDetailInfo(groupCode: string, arg: unknown): void;
|
||||
|
||||
// 第二个参数在大多数情况为0 设置群成员权限 例如上传群文件权限和群成员付费/加入邀请加入时为8
|
||||
modifyGroupDetailInfoV2(param: GroupDetailInfoV2Param, arg: number): Promise<GeneralCallResult>;
|
||||
|
||||
setGroupMsgMask(groupCode: string, arg: unknown): void;
|
||||
|
||||
changeGroupShieldSettingTemp(groupCode: string, arg: unknown): void;
|
||||
|
@@ -58,7 +58,6 @@ export interface GrayTipRovokeElement {
|
||||
operatorUid: string;
|
||||
operatorNick: string;
|
||||
operatorRemark: string;
|
||||
isSelfOperate: boolean; // 是否是自己撤回的
|
||||
operatorMemRemark?: string;
|
||||
wording: string; // 自定义的撤回提示语
|
||||
}
|
||||
|
@@ -1,97 +1,4 @@
|
||||
import { QQLevel, NTSex } from './user';
|
||||
export interface GroupExtInfo {
|
||||
groupCode: string;
|
||||
resultCode: number;
|
||||
extInfo: EXTInfo;
|
||||
}
|
||||
export interface GroupExtFilter {
|
||||
groupInfoExtSeq: number;
|
||||
reserve: number;
|
||||
luckyWordId: number;
|
||||
lightCharNum: number;
|
||||
luckyWord: number;
|
||||
starId: number;
|
||||
essentialMsgSwitch: number;
|
||||
todoSeq: number;
|
||||
blacklistExpireTime: number;
|
||||
isLimitGroupRtc: number;
|
||||
companyId: number;
|
||||
hasGroupCustomPortrait: number;
|
||||
bindGuildId: number;
|
||||
groupOwnerId: number;
|
||||
essentialMsgPrivilege: number;
|
||||
msgEventSeq: number;
|
||||
inviteRobotSwitch: number;
|
||||
gangUpId: number;
|
||||
qqMusicMedalSwitch: number;
|
||||
showPlayTogetherSwitch: number;
|
||||
groupFlagPro1: number;
|
||||
groupBindGuildIds: number;
|
||||
viewedMsgDisappearTime: number;
|
||||
groupExtFlameData: number;
|
||||
groupBindGuildSwitch: number;
|
||||
groupAioBindGuildId: number;
|
||||
groupExcludeGuildIds: number;
|
||||
fullGroupExpansionSwitch: number;
|
||||
fullGroupExpansionSeq: number;
|
||||
inviteRobotMemberSwitch: number;
|
||||
inviteRobotMemberExamine: number;
|
||||
groupSquareSwitch: number;
|
||||
};
|
||||
|
||||
export interface EXTInfo {
|
||||
groupInfoExtSeq: number;
|
||||
reserve: number;
|
||||
luckyWordId: string;
|
||||
lightCharNum: number;
|
||||
luckyWord: string;
|
||||
starId: number;
|
||||
essentialMsgSwitch: number;
|
||||
todoSeq: number;
|
||||
blacklistExpireTime: number;
|
||||
isLimitGroupRtc: number;
|
||||
companyId: number;
|
||||
hasGroupCustomPortrait: number;
|
||||
bindGuildId: string;
|
||||
groupOwnerId: GroupOwnerID;
|
||||
essentialMsgPrivilege: number;
|
||||
msgEventSeq: string;
|
||||
inviteRobotSwitch: number;
|
||||
gangUpId: string;
|
||||
qqMusicMedalSwitch: number;
|
||||
showPlayTogetherSwitch: number;
|
||||
groupFlagPro1: string;
|
||||
groupBindGuildIds: GroupGuildIDS;
|
||||
viewedMsgDisappearTime: string;
|
||||
groupExtFlameData: GroupEXTFlameData;
|
||||
groupBindGuildSwitch: number;
|
||||
groupAioBindGuildId: string;
|
||||
groupExcludeGuildIds: GroupGuildIDS;
|
||||
fullGroupExpansionSwitch: number;
|
||||
fullGroupExpansionSeq: string;
|
||||
inviteRobotMemberSwitch: number;
|
||||
inviteRobotMemberExamine: number;
|
||||
groupSquareSwitch: number;
|
||||
}
|
||||
|
||||
export interface GroupGuildIDS {
|
||||
guildIds: any[];
|
||||
}
|
||||
|
||||
export interface GroupEXTFlameData {
|
||||
switchState: number;
|
||||
state: number;
|
||||
dayNums: any[];
|
||||
version: number;
|
||||
updateTime: string;
|
||||
isDisplayDayNum: boolean;
|
||||
}
|
||||
|
||||
export interface GroupOwnerID {
|
||||
memberUin: string;
|
||||
memberUid: string;
|
||||
memberQid: string;
|
||||
}
|
||||
|
||||
export interface KickMemberInfo {
|
||||
optFlag: number;
|
||||
@@ -100,185 +7,6 @@ export interface KickMemberInfo {
|
||||
optBytesMsg: string;
|
||||
}
|
||||
|
||||
|
||||
export interface GroupDetailInfoV2Param {
|
||||
groupCode: string;
|
||||
filter: Filter;
|
||||
modifyInfo: ModifyInfo;
|
||||
}
|
||||
|
||||
export interface Filter {
|
||||
noCodeFingerOpenFlag: number;
|
||||
noFingerOpenFlag: number;
|
||||
groupName: number;
|
||||
classExt: number;
|
||||
classText: number;
|
||||
fingerMemo: number;
|
||||
richFingerMemo: number;
|
||||
tagRecord: number;
|
||||
groupGeoInfo: FilterGroupGeoInfo;
|
||||
groupExtAdminNum: number;
|
||||
flag: number;
|
||||
groupMemo: number;
|
||||
groupAioSkinUrl: number;
|
||||
groupBoardSkinUrl: number;
|
||||
groupCoverSkinUrl: number;
|
||||
groupGrade: number;
|
||||
activeMemberNum: number;
|
||||
certificationType: number;
|
||||
certificationText: number;
|
||||
groupNewGuideLines: FilterGroupNewGuideLines;
|
||||
groupFace: number;
|
||||
addOption: number;
|
||||
shutUpTime: number;
|
||||
groupTypeFlag: number;
|
||||
appPrivilegeFlag: number;
|
||||
appPrivilegeMask: number;
|
||||
groupExtOnly: GroupEXTOnly;
|
||||
groupSecLevel: number;
|
||||
groupSecLevelInfo: number;
|
||||
subscriptionUin: number;
|
||||
subscriptionUid: string;
|
||||
allowMemberInvite: number;
|
||||
groupQuestion: number;
|
||||
groupAnswer: number;
|
||||
groupFlagExt3: number;
|
||||
groupFlagExt3Mask: number;
|
||||
groupOpenAppid: number;
|
||||
rootId: number;
|
||||
msgLimitFrequency: number;
|
||||
hlGuildAppid: number;
|
||||
hlGuildSubType: number;
|
||||
hlGuildOrgId: number;
|
||||
groupFlagExt4: number;
|
||||
groupFlagExt4Mask: number;
|
||||
groupSchoolInfo: FilterGroupSchoolInfo;
|
||||
groupCardPrefix: FilterGroupCardPrefix;
|
||||
allianceId: number;
|
||||
groupFlagPro1: number;
|
||||
groupFlagPro1Mask: number;
|
||||
}
|
||||
|
||||
export interface FilterGroupCardPrefix {
|
||||
introduction: number;
|
||||
rptPrefix: number;
|
||||
}
|
||||
|
||||
export interface GroupEXTOnly {
|
||||
tribeId: number;
|
||||
moneyForAddGroup: number;
|
||||
}
|
||||
|
||||
export interface FilterGroupGeoInfo {
|
||||
ownerUid: number;
|
||||
setTime: number;
|
||||
cityId: number;
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
geoContent: number;
|
||||
poiId: number;
|
||||
}
|
||||
|
||||
export interface FilterGroupNewGuideLines {
|
||||
enabled: number;
|
||||
content: number;
|
||||
}
|
||||
|
||||
export interface FilterGroupSchoolInfo {
|
||||
location: number;
|
||||
grade: number;
|
||||
school: number;
|
||||
}
|
||||
|
||||
export interface ModifyInfo {
|
||||
noCodeFingerOpenFlag: number;
|
||||
noFingerOpenFlag: number;
|
||||
groupName: string;
|
||||
classExt: number;
|
||||
classText: string;
|
||||
fingerMemo: string;
|
||||
richFingerMemo: string;
|
||||
tagRecord: any[];
|
||||
groupGeoInfo: ModifyInfoGroupGeoInfo;
|
||||
groupExtAdminNum: number;
|
||||
flag: number;
|
||||
groupMemo: string;
|
||||
groupAioSkinUrl: string;
|
||||
groupBoardSkinUrl: string;
|
||||
groupCoverSkinUrl: string;
|
||||
groupGrade: number;
|
||||
activeMemberNum: number;
|
||||
certificationType: number;
|
||||
certificationText: string;
|
||||
groupNewGuideLines: ModifyInfoGroupNewGuideLines;
|
||||
groupFace: number;
|
||||
addOption: number;// 0 空设置 1 任何人都可以进入 2 需要管理员批准 3 不允许任何人入群 4 问题进入答案 5 问题管理员批准
|
||||
shutUpTime: number;
|
||||
groupTypeFlag: number;
|
||||
appPrivilegeFlag: number;
|
||||
// 需要管理员审核
|
||||
// 0000 0000 0000 0000 0000 0000 0000
|
||||
// 无需审核入群
|
||||
// 0000 0001 0000 0000 0000 0000 0000
|
||||
// 成员数100内无审核
|
||||
// 0100 0000 0000 0000 0000 0000 0000
|
||||
// 禁用 群成员邀请好友
|
||||
// 0100 0000 0000 0000 0000 0000 0000
|
||||
|
||||
appPrivilegeMask: number;
|
||||
// 0110 0001 0000 0000 0000 0000 0000
|
||||
// 101711872
|
||||
groupExtOnly: GroupEXTOnly;
|
||||
groupSecLevel: number;
|
||||
groupSecLevelInfo: number;
|
||||
subscriptionUin: string;
|
||||
subscriptionUid: string;
|
||||
allowMemberInvite: number;
|
||||
groupQuestion: string;
|
||||
groupAnswer: string;
|
||||
groupFlagExt3: number;
|
||||
groupFlagExt3Mask: number;
|
||||
groupOpenAppid: number;
|
||||
rootId: string;
|
||||
msgLimitFrequency: number;
|
||||
hlGuildAppid: number;
|
||||
hlGuildSubType: number;
|
||||
hlGuildOrgId: number;
|
||||
groupFlagExt4: number;
|
||||
groupFlagExt4Mask: number;
|
||||
groupSchoolInfo: ModifyInfoGroupSchoolInfo;
|
||||
groupCardPrefix: ModifyInfoGroupCardPrefix;
|
||||
allianceId: string;
|
||||
groupFlagPro1: number;
|
||||
groupFlagPro1Mask: number;
|
||||
}
|
||||
|
||||
export interface ModifyInfoGroupCardPrefix {
|
||||
introduction: string;
|
||||
rptPrefix: any[];
|
||||
}
|
||||
|
||||
export interface ModifyInfoGroupGeoInfo {
|
||||
ownerUid: string;
|
||||
SetTime: number;
|
||||
CityId: number;
|
||||
Longitude: string;
|
||||
Latitude: string;
|
||||
GeoContent: string;
|
||||
poiId: string;
|
||||
}
|
||||
|
||||
export interface ModifyInfoGroupNewGuideLines {
|
||||
enabled: boolean;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface ModifyInfoGroupSchoolInfo {
|
||||
location: string;
|
||||
grade: number;
|
||||
school: string;
|
||||
}
|
||||
|
||||
// 获取群详细信息的来源类型
|
||||
export enum GroupInfoSource {
|
||||
KUNSPECIFIED,
|
||||
|
@@ -477,7 +477,7 @@ export enum SendStatusType {
|
||||
export interface RawMessage {
|
||||
parentMsgPeer: Peer; // 父消息的Peer
|
||||
parentMsgIdList: string[];// 父消息 ID 列表
|
||||
id?: number;// 扩展字段,与 Ob11 msg ID 有关
|
||||
id?: string;// 扩展字段,与 Ob11 msg ID 有关
|
||||
guildId: string;// 频道ID
|
||||
msgRandom: string;// 消息ID相关
|
||||
msgId: string;// 雪花ID
|
||||
|
@@ -48,12 +48,6 @@ export async function NCoreInitFramework(
|
||||
});
|
||||
}
|
||||
//直到登录成功后,执行下一步
|
||||
// const selfInfo = {
|
||||
// uid: 'u_FUSS0_x06S_9Tf4na_WpUg',
|
||||
// uin: '3684714082',
|
||||
// nick: '',
|
||||
// online: true
|
||||
// }
|
||||
const selfInfo = await new Promise<SelfInfo>((resolveSelfInfo) => {
|
||||
const loginListener = new NodeIKernelLoginListener();
|
||||
loginListener.onQRCodeLoginSucceed = async (loginResult) => {
|
||||
|
@@ -1,26 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
async function initializeNapCat(session, loginService, registerCallback) {
|
||||
//const logFile = path.join(currentPath, 'napcat.log');
|
||||
|
||||
console.log('[NapCat] [Info] 开始初始化NapCat');
|
||||
|
||||
//fs.writeFileSync(logFile, '', { flag: 'w' });
|
||||
|
||||
//fs.writeFileSync(logFile, '[NapCat] [Info] NapCat 初始化成功\n', { flag: 'a' });
|
||||
|
||||
try {
|
||||
const currentPath = path.dirname(__filename);
|
||||
const { NCoreInitFramework } = await import('file://' + path.join(currentPath, './napcat.mjs'));
|
||||
await NCoreInitFramework(session, loginService, (callback) => { registerCallback(callback) });
|
||||
|
||||
} catch (error) {
|
||||
console.log('[NapCat] [Error] 初始化NapCat', error);
|
||||
//fs.writeFileSync(logFile, `[NapCat] [Error] 初始化NapCat失败: ${error.message}\n`, { flag: 'a' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initializeNapCat: initializeNapCat
|
||||
};
|
@@ -3,7 +3,7 @@ import { OneBotAction } from '../OneBotAction';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
bot_appid: Type.String(),
|
||||
button_id: Type.String({ default: '' }),
|
||||
callback_data: Type.String({ default: '' }),
|
||||
@@ -25,6 +25,6 @@ export class ClickInlineKeyboardButton extends OneBotAction<Payload, unknown> {
|
||||
callback_data: payload.callback_data,
|
||||
dmFlag: 0,
|
||||
chatType: 2
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
count: Type.Union([Type.Number(), Type.String()], { default: 48 }),
|
||||
count: Type.Number({ default: 48 }),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -5,7 +5,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { type NTQQMsgApi } from '@/core/apis';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
emojiId: Type.Union([Type.Number(), Type.String()]),
|
||||
emojiType: Type.Union([Type.Number(), Type.String()]),
|
||||
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
||||
@@ -18,7 +18,7 @@ export class FetchEmojiLike extends OneBotAction<Payload, Awaited<ReturnType<NTQ
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
const msgIdPeer = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msgIdPeer) throw new Error('消息不存在');
|
||||
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
||||
if (!msg) throw new Error('消息不存在');
|
||||
|
@@ -4,7 +4,7 @@ import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
|
||||
import { Type, Static } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
chat_type: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
||||
});
|
||||
|
||||
|
@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Type, Static } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
category: Type.Union([Type.Number(), Type.String()]),
|
||||
count: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
||||
category: Type.Number({ default: 0 }),
|
||||
count: Type.Number({ default: 1 }),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Type, Static } from '@sinclair/typebox';
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Type, Static } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||
start: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||
count: Type.Union([Type.Number(), Type.String()], { default: 10 })
|
||||
user_id: Type.Optional(Type.String()),
|
||||
start: Type.String({ default: '0' }),
|
||||
count: Type.String({ default: '10' })
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -36,7 +36,7 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||
uint64_uin: self_id,
|
||||
uint64_top: 0,
|
||||
uint32_req_num: 99,
|
||||
bytes_cookies: ""
|
||||
bytes_cookies: ''
|
||||
};
|
||||
const packed_data = await this.pack_data(JSON.stringify(req_json));
|
||||
const data = Buffer.from(packed_data).toString('hex');
|
||||
|
@@ -3,7 +3,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_id: Type.String(),
|
||||
current_parent_directory: Type.String(),
|
||||
target_parent_directory: Type.String(),
|
||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_id: Type.String(),
|
||||
current_parent_directory: Type.String(),
|
||||
new_name: Type.String(),
|
||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
face_id: Type.Union([Type.Number(), Type.String()]),// 参考 face_config.json 的 QSid
|
||||
face_type: Type.Union([Type.Number(), Type.String()], { default: '1' }),
|
||||
face_id: Type.String(),// 参考 face_config.json 的 QSid
|
||||
face_type: Type.String({ default: '1' }),
|
||||
wording: Type.String({ default: ' ' }),
|
||||
});
|
||||
|
||||
@@ -16,9 +16,9 @@ export class SetDiyOnlineStatus extends OneBotAction<Payload, string> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const ret = await this.core.apis.UserApi.setDiySelfOnlineStatus(
|
||||
payload.face_id.toString(),
|
||||
payload.face_id,
|
||||
payload.wording,
|
||||
payload.face_type.toString(),
|
||||
payload.face_type,
|
||||
);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('设置在线状态失败');
|
||||
|
@@ -1,28 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
add_type: Type.Number(),
|
||||
group_question: Type.Optional(Type.String()),
|
||||
group_answer: Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupAddOption extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.SetGroupAddOption;
|
||||
override payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
let ret = await this.core.apis.GroupApi.setGroupAddOption(payload.group_id, {
|
||||
addOption: payload.add_type,
|
||||
groupQuestion: payload.group_question,
|
||||
groupAnswer: payload.group_answer,
|
||||
});
|
||||
if (ret.result != 0) {
|
||||
throw new Error(`设置群添加选项失败, ${ret.result}:${ret.errMsg}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
user_id: Type.Array(Type.String()),
|
||||
reject_add_request: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupKickMembers extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.SetGroupKickMembers;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const rejectReq = payload.reject_add_request?.toString() == 'true';
|
||||
const uids: string[] = await Promise.all(payload.user_id.map(async uin => await this.core.apis.UserApi.getUidByUinV2(uin)));
|
||||
await this.core.apis.GroupApi.kickMember(payload.group_id.toString(), uids.filter(uid => !!uid), rejectReq);
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
robot_member_switch: Type.Optional(Type.Number()),
|
||||
robot_member_examine: Type.Optional(Type.Number()),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupRobotAddOption extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.SetGroupRobotAddOption;
|
||||
override payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
let ret = await this.core.apis.GroupApi.setGroupRobotAddOption(
|
||||
payload.group_id,
|
||||
payload.robot_member_switch,
|
||||
payload.robot_member_examine,
|
||||
);
|
||||
if (ret.result != 0) {
|
||||
throw new Error(`设置群机器人添加选项失败, ${ret.result}:${ret.errMsg}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
no_code_finger_open: Type.Optional(Type.Number()),
|
||||
no_finger_open: Type.Optional(Type.Number()),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupSearch extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.SetGroupSearch;
|
||||
override payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
let ret = await this.core.apis.GroupApi.setGroupSearch(payload.group_id, {
|
||||
noCodeFingerOpenFlag: payload.no_code_finger_open,
|
||||
noFingerOpenFlag: payload.no_finger_open,
|
||||
});
|
||||
if (ret.result != 0) {
|
||||
throw new Error(`设置群搜索失败, ${ret.result}:${ret.errMsg}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -4,7 +4,7 @@ import { ChatType } from '@/core';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.String(),
|
||||
event_type: Type.Number(),
|
||||
});
|
||||
|
||||
|
@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
status: Type.Union([Type.Number(), Type.String()]),
|
||||
ext_status: Type.Union([Type.Number(), Type.String()]),
|
||||
battery_status: Type.Union([Type.Number(), Type.String()]),
|
||||
status: Type.Number(),
|
||||
ext_status: Type.Number(),
|
||||
battery_status: Type.Number(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -16,9 +16,9 @@ export class SetOnlineStatus extends OneBotAction<Payload, null> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
||||
+payload.status,
|
||||
+payload.ext_status,
|
||||
+payload.battery_status,
|
||||
payload.status,
|
||||
payload.ext_status,
|
||||
payload.battery_status,
|
||||
);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('设置在线状态失败');
|
||||
|
@@ -3,8 +3,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
special_title: Type.String({ default: '' }),
|
||||
});
|
||||
|
||||
|
@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||
user_id: Type.Optional(Type.String()),
|
||||
group_id: Type.Optional(Type.String()),
|
||||
phoneNumber: Type.String({ default: '' }),
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ export class SharePeer extends OneBotAction<Payload, GeneralCallResult & {
|
||||
}
|
||||
|
||||
const SchemaDataGroupEx = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type PayloadGroupEx = Static<typeof SchemaDataGroupEx>;
|
||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_id: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_id: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
folder_name: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import { Static, Type } from '@sinclair/typebox';
|
||||
import { NTQQGroupApi } from '@/core/apis';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_id: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { Static, Type } from '@sinclair/typebox';
|
||||
import { NTQQGroupApi } from '@/core/apis';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
folder_id: Type.Optional(Type.String()),
|
||||
folder: Type.Optional(Type.String()),
|
||||
});
|
||||
|
@@ -117,8 +117,7 @@ export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, {
|
||||
}
|
||||
throw new Error('ResId无效: 找不到相关的聊天记录');
|
||||
}
|
||||
const rootMsgId = MessageUnique.getShortIdByMsgId(msgId.toString());
|
||||
const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId ?? +msgId);
|
||||
const rootMsg = MessageUnique.getInnerData(msgId);
|
||||
|
||||
if (rootMsg) {
|
||||
// 5. 获取消息内容
|
||||
|
@@ -12,7 +12,7 @@ interface Response {
|
||||
}
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.String(),
|
||||
message_seq: Type.Optional(Type.String()),
|
||||
message_id: Type.Optional(Type.String()),
|
||||
count: Type.Number({ default: 20 }),
|
||||
reverseOrder: Type.Boolean({ default: false })
|
||||
});
|
||||
@@ -24,24 +24,24 @@ export default class GetFriendMsgHistory extends OneBotAction<Payload, Response>
|
||||
override actionName = ActionName.GetFriendMsgHistory;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig): Promise<Response> {
|
||||
async _handle(payload: Payload, _adapter: string, _config: NetworkAdapterConfig): Promise<Response> {
|
||||
//处理参数
|
||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!uid) throw new Error(`记录${payload.user_id}不存在`);
|
||||
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
||||
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||
const msgList = hasMessageSeq ?
|
||||
const hasMessageId = !payload.message_id ? !!payload.message_id : !(payload.message_id?.toString() === '' || payload.message_id?.toString() === '0');
|
||||
const startMsgId = hasMessageId ? (MessageUnique.getInnerData(payload.message_id!)?.MsgId ?? payload.message_id!.toString()) : '0';
|
||||
const msgList = hasMessageId ?
|
||||
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, +payload.count, payload.reverseOrder)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, +payload.count)).msgList;
|
||||
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||
if (msgList.length === 0) throw new Error(`消息${payload.message_id}不存在`);
|
||||
//转换序号
|
||||
await Promise.all(msgList.map(async msg => {
|
||||
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
msg.id = MessageUnique.getOutputData({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId, msg.msgSeq);
|
||||
}));
|
||||
//烘焙消息
|
||||
const ob11MsgList = (await Promise.all(
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat)))
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||
).filter(msg => msg !== undefined);
|
||||
return { 'messages': ob11MsgList };
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()])
|
||||
group_id: Type.String()
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()])
|
||||
group_id: Type.String()
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -5,7 +5,7 @@ import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
folder_id: Type.Optional(Type.String()),
|
||||
folder: Type.Optional(Type.String()),
|
||||
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
||||
|
@@ -4,7 +4,7 @@ import { WebHonorType } from '@/core/types';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
type: Type.Optional(Type.Enum(WebHonorType))
|
||||
});
|
||||
|
||||
|
@@ -4,15 +4,13 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { ChatType, Peer } from '@/core/types';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||
|
||||
interface Response {
|
||||
messages: OB11Message[];
|
||||
}
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
message_seq: Type.Optional(Type.String()),
|
||||
message_id: Type.Optional(Type.String()),
|
||||
count: Type.Number({ default: 20 }),
|
||||
reverseOrder: Type.Boolean({ default: false })
|
||||
});
|
||||
@@ -25,21 +23,21 @@ export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Re
|
||||
override actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig): Promise<Response> {
|
||||
async _handle(payload: Payload, _adapter: string): Promise<Response> {
|
||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||
const hasMessageSeq = !payload.message_id ? !!payload.message_id : !(payload.message_id?.toString() === '' || payload.message_id?.toString() === '0');
|
||||
//拉取消息
|
||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||
const startMsgId = hasMessageSeq ? (MessageUnique.getInnerData(payload.message_id!)?.MsgId ?? payload.message_id!.toString()) : '0';
|
||||
const msgList = hasMessageSeq ?
|
||||
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, +payload.count, payload.reverseOrder)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, +payload.count)).msgList;
|
||||
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||
if (msgList.length === 0) throw new Error(`消息${payload.message_id}不存在`);
|
||||
//转换序号
|
||||
await Promise.all(msgList.map(async msg => {
|
||||
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
msg.id = MessageUnique.getOutputData({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId, msg.msgSeq);
|
||||
}));
|
||||
//烘焙消息
|
||||
const ob11MsgList = (await Promise.all(
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat)))
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||
).filter(msg => msg !== undefined);
|
||||
return { 'messages': ob11MsgList };
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
||||
});
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import { calcQQLevel } from '@/common/helper';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.String(),
|
||||
no_cache: Type.Union([Type.Boolean(), Type.String()], { default: false }),
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11U
|
||||
...extendData.detail.simpleInfo.baseInfo,
|
||||
...extendData.detail.simpleInfo.relationFlags ?? {},
|
||||
...extendData.detail.simpleInfo.status ?? {},
|
||||
user_id: parseInt(extendData.detail.uin) ?? 0,
|
||||
user_id: extendData.detail.uin ?? 0,
|
||||
uid: info.uid ?? uid,
|
||||
nickname: extendData.detail.simpleInfo.coreInfo.nick ?? '',
|
||||
age: extendData.detail.simpleInfo.baseInfo.age ?? info.age,
|
||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
friend_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||
user_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||
friend_id: Type.Optional(Type.String()),
|
||||
user_id: Type.Optional(Type.String()),
|
||||
temp_block: Type.Optional(Type.Boolean()),
|
||||
temp_both_del: Type.Optional(Type.Boolean()),
|
||||
});
|
||||
|
@@ -1,19 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { QuickAction, QuickActionEvent } from '@/onebot/types';
|
||||
|
||||
interface Payload {
|
||||
context: QuickActionEvent,
|
||||
operation: QuickAction
|
||||
}
|
||||
|
||||
export class GoCQHTTPHandleQuickAction extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.GoCQHTTP_HandleQuickAction;
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
this.obContext.apis.QuickActionApi
|
||||
.handleQuickOperation(payload.context, payload.operation)
|
||||
.catch(e => this.core.context.logger.logError(e));
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import { ContextMode, normalize, ReturnDataType, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||
import { normalize, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||
import { OB11PostSendMsg } from '@/onebot/types';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
|
||||
@@ -19,14 +19,8 @@ export class GoCQHTTPSendForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
}
|
||||
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
override actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
||||
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Private);
|
||||
}
|
||||
}
|
||||
|
||||
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
override actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
|
||||
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Group);
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import { unlink } from 'node:fs/promises';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
content: Type.String(),
|
||||
image: Type.Optional(Type.String()),
|
||||
pinned: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||
|
@@ -6,7 +6,7 @@ import fs from 'node:fs/promises';
|
||||
import { GeneralCallResult } from '@/core';
|
||||
const SchemaData = Type.Object({
|
||||
file: Type.String(),
|
||||
group_id: Type.Union([Type.Number(), Type.String()])
|
||||
group_id: Type.String()
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -7,7 +7,7 @@ import { SendMessageContext } from '@/onebot/api';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
file: Type.String(),
|
||||
name: Type.String(),
|
||||
folder: Type.Optional(Type.String()),
|
||||
|
@@ -8,7 +8,7 @@ import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.String(),
|
||||
file: Type.String(),
|
||||
name: Type.String(),
|
||||
});
|
||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -13,7 +13,7 @@ export default class DelEssenceMsg extends OneBotAction<Payload, unknown> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<unknown> {
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msg) {
|
||||
const data = this.core.apis.GroupApi.essenceLRU.getValue(+payload.message_id);
|
||||
if(!data) throw new Error('消息不存在');
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
notice_id: Type.String()
|
||||
});
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
character: Type.String(),
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
text: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -1,27 +0,0 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export class GetGroupDetailInfo extends OneBotAction<Payload, unknown> {
|
||||
override actionName = ActionName.GetGroupDetailInfo;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const data = await this.core.apis.GroupApi.fetchGroupDetail(payload.group_id.toString());
|
||||
return {
|
||||
...data,
|
||||
group_all_shut: data.shutUpAllTimestamp > 0 ? -1 : 0,
|
||||
group_remark: '',
|
||||
group_id: +payload.group_id,
|
||||
group_name: data.groupName,
|
||||
member_count: data.memberNum,
|
||||
max_member_count: data.maxMemberNum,
|
||||
};
|
||||
}
|
||||
}
|
@@ -4,10 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import crypto from 'crypto';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -22,12 +20,12 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
id: MessageUnique.createUniqueMsgId(peer, replyMsgList.msgId),
|
||||
id: MessageUnique.getOutputData(peer, replyMsgList.msgId, replyMsgList.msgSeq),
|
||||
msg: replyMsgList
|
||||
};
|
||||
}
|
||||
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||
async _handle(payload: Payload, _adapter: string) {
|
||||
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
|
||||
if (!msglist) {
|
||||
throw new Error('获取失败');
|
||||
@@ -48,7 +46,7 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
|
||||
operator_nick: msg.add_digest_nick,
|
||||
message_id: message_id,
|
||||
operator_time: msg.add_digest_time,
|
||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage, config.messagePostFormat))?.message
|
||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage))?.message
|
||||
};
|
||||
}
|
||||
const msgTempData = JSON.stringify({
|
||||
|
@@ -5,7 +5,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -5,8 +5,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import { Static, Type } from '@sinclair/typebox';
|
||||
import { GroupMember } from '@/core';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@ interface GroupNotice {
|
||||
}
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
19
src/onebot/action/group/GroupPoke.ts
Normal file
19
src/onebot/action/group/GroupPoke.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export class GroupPoke extends GetPacketStatusDepends<Payload, void> {
|
||||
override actionName = ActionName.GroupPoke;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
await this.core.apis.PacketApi.pkt.operation.GroupPoke(+payload.group_id, +payload.user_id);
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
character: Type.String(),
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
text: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -1,19 +1,17 @@
|
||||
import { ContextMode, ReturnDataType, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||
import { ContextMode, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
import { OB11PostSendMsg } from '@/onebot/types';
|
||||
|
||||
// 未检测参数
|
||||
class SendGroupMsg extends SendMsgBase {
|
||||
override actionName = ActionName.SendGroupMsg;
|
||||
override contextMode: ContextMode = ContextMode.Group;
|
||||
|
||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||
delete payload.user_id;
|
||||
payload.message_type = 'group';
|
||||
return super.check(payload);
|
||||
}
|
||||
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Group);
|
||||
}
|
||||
}
|
||||
|
||||
export default SendGroupMsg;
|
||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -14,7 +14,7 @@ export default class SetEssenceMsg extends OneBotAction<Payload, unknown> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msg) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
|
@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
duration: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
duration: Type.String({ default: '0' }),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
card: Type.Optional(Type.String())
|
||||
});
|
||||
|
||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
user_id: Type.String(),
|
||||
reject_add_request: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
is_dismiss: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
group_name: Type.String(),
|
||||
});
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.String(),
|
||||
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
});
|
||||
|
||||
|
@@ -30,7 +30,6 @@ import SetGroupAdmin from './group/SetGroupAdmin';
|
||||
import SetGroupCard from './group/SetGroupCard';
|
||||
import GetImage from './file/GetImage';
|
||||
import GetRecord from './file/GetRecord';
|
||||
import { GoCQHTTPMarkMsgAsRead, MarkAllMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||
import SetQQAvatar from '@/onebot/action/extends/SetQQAvatar';
|
||||
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
||||
@@ -48,7 +47,6 @@ import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from '@/onebot/action/m
|
||||
import { GetFriendWithCategory } from './extends/GetFriendWithCategory';
|
||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice';
|
||||
import { GetGroupHonorInfo } from './go-cqhttp/GetGroupHonorInfo';
|
||||
import { GoCQHTTPHandleQuickAction } from './go-cqhttp/QuickAction';
|
||||
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
||||
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
||||
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
||||
@@ -78,6 +76,7 @@ import { GetGroupFileSystemInfo } from '@/onebot/action/go-cqhttp/GetGroupFileSy
|
||||
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
||||
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
||||
import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
||||
import { GroupPoke } from './group/GroupPoke';
|
||||
import { GetUserStatus } from './extends/GetUserStatus';
|
||||
import { GetRkey } from './extends/GetRkey';
|
||||
import { SetSpecialTitle } from './extends/SetSpecialTitle';
|
||||
@@ -85,6 +84,7 @@ import { GetGroupShutList } from './group/GetGroupShutList';
|
||||
import { GetGroupMemberList } from './group/GetGroupMemberList';
|
||||
import { GetGroupFileUrl } from '@/onebot/action/file/GetGroupFileUrl';
|
||||
import { GetPacketStatus } from '@/onebot/action/packet/GetPacketStatus';
|
||||
import { FriendPoke } from '@/onebot/action/user/FriendPoke';
|
||||
import { GetCredentials } from './system/GetCredentials';
|
||||
import { SendGroupSign, SetGroupSign } from './extends/SetGroupSign';
|
||||
import { GoCQHTTPGetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain';
|
||||
@@ -100,7 +100,7 @@ import { GetGuildList } from './guild/GetGuildList';
|
||||
import { GetGuildProfile } from './guild/GetGuildProfile';
|
||||
import { GetClientkey } from './extends/GetClientkey';
|
||||
import { SendPacket } from './extends/SendPacket';
|
||||
import { FriendPoke, GroupPoke, SendPoke } from '@/onebot/action/packet/SendPoke';
|
||||
import { SendPoke } from '@/onebot/action/packet/SendPoke';
|
||||
import { SetDiyOnlineStatus } from './extends/SetDiyOnlineStatus';
|
||||
import { BotExit } from './extends/BotExit';
|
||||
import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
||||
@@ -116,20 +116,10 @@ import { CleanCache } from './system/CleanCache';
|
||||
import SetFriendRemark from './user/SetFriendRemark';
|
||||
import { SetDoubtFriendsAddRequest } from './new/SetDoubtFriendsAddRequest';
|
||||
import { GetDoubtFriendsAddRequest } from './new/GetDoubtFriendsAddRequest';
|
||||
import SetGroupAddOption from './extends/SetGroupAddOption';
|
||||
import SetGroupSearch from './extends/SetGroupSearch';
|
||||
import SetGroupRobotAddOption from './extends/SetGroupRobotAddOption';
|
||||
import SetGroupKickMembers from './extends/SetGroupKickMembers';
|
||||
import { GetGroupDetailInfo } from './group/GetGroupDetailInfo';
|
||||
|
||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||
|
||||
const actionHandlers = [
|
||||
new GetGroupDetailInfo(obContext, core),
|
||||
new SetGroupKickMembers(obContext, core),
|
||||
new SetGroupAddOption(obContext, core),
|
||||
new SetGroupRobotAddOption(obContext, core),
|
||||
new SetGroupSearch(obContext, core),
|
||||
new SetDoubtFriendsAddRequest(obContext, core),
|
||||
new GetDoubtFriendsAddRequest(obContext, core),
|
||||
new SetFriendRemark(obContext, core),
|
||||
@@ -146,8 +136,6 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new SetLongNick(obContext, core),
|
||||
new ForwardFriendSingleMsg(obContext, core),
|
||||
new ForwardGroupSingleMsg(obContext, core),
|
||||
new MarkGroupMsgAsRead(obContext, core),
|
||||
new MarkPrivateMsgAsRead(obContext, core),
|
||||
new SetQQAvatar(obContext, core),
|
||||
new TranslateEnWordToZn(obContext, core),
|
||||
new GetGroupRootFiles(obContext, core),
|
||||
@@ -207,17 +195,14 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new GoCQHTTPGetStrangerInfo(obContext, core),
|
||||
new GoCQHTTPDownloadFile(obContext, core),
|
||||
new GetGuildList(obContext, core),
|
||||
new GoCQHTTPMarkMsgAsRead(obContext, core),
|
||||
new GoCQHTTPUploadGroupFile(obContext, core),
|
||||
new GoCQHTTPGetGroupMsgHistory(obContext, core),
|
||||
new GoCQHTTPGetForwardMsgAction(obContext, core),
|
||||
new GetFriendMsgHistory(obContext, core),
|
||||
new GoCQHTTPHandleQuickAction(obContext, core),
|
||||
new GetGroupIgnoredNotifies(obContext, core),
|
||||
new DelEssenceMsg(obContext, core),
|
||||
new SetEssenceMsg(obContext, core),
|
||||
new GetRecentContact(obContext, core),
|
||||
new MarkAllMsgAsRead(obContext, core),
|
||||
new GetProfileLike(obContext, core),
|
||||
new SetGroupPortrait(obContext, core),
|
||||
new FetchCustomFace(obContext, core),
|
||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -14,7 +14,7 @@ class DeleteMsg extends OneBotAction<Payload, void> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
||||
if (msg) {
|
||||
await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId);
|
||||
} else {
|
||||
|
@@ -5,9 +5,9 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||
message_id: Type.String(),
|
||||
group_id: Type.Optional(Type.String()),
|
||||
user_id: Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -25,7 +25,7 @@ class ForwardSingleMsg extends OneBotAction<Payload, null> {
|
||||
}
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msg) {
|
||||
throw new Error(`无法找到消息${payload.message_id}`);
|
||||
}
|
||||
|
@@ -4,12 +4,10 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { RawMessage } from '@/core';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||
|
||||
export type ReturnDataType = OB11Message
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
@@ -18,30 +16,27 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
|
||||
override actionName = ActionName.GetMsg;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||
async _handle(payload: Payload, _adapter: string) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('参数message_id不能为空');
|
||||
}
|
||||
const MsgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString());
|
||||
const msgIdWithPeer = MessageUnique.getMsgIdAndPeerByShortId(MsgShortId ?? +payload.message_id);
|
||||
const msgIdWithPeer = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msgIdWithPeer) {
|
||||
throw new Error('消息不存在');
|
||||
}
|
||||
const peer = { guildId: '', peerUid: msgIdWithPeer?.Peer.peerUid, chatType: msgIdWithPeer.Peer.chatType };
|
||||
const orimsg = this.obContext.recallMsgCache.get(msgIdWithPeer.MsgId);
|
||||
let msg: RawMessage|undefined;
|
||||
let msg: RawMessage | undefined;
|
||||
if (orimsg) {
|
||||
msg = orimsg;
|
||||
} else {
|
||||
msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0];
|
||||
}
|
||||
if (!msg) throw Error('消息不存在');
|
||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg);
|
||||
if (!retMsg) throw Error('消息为空');
|
||||
try {
|
||||
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!;
|
||||
retMsg.message_seq = retMsg.message_id;
|
||||
retMsg.real_id = retMsg.message_id;
|
||||
retMsg.message_id = MessageUnique.getOutputData(peer, msg.msgId, msg.msgSeq)!;
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
|
@@ -1,72 +0,0 @@
|
||||
import { ChatType, Peer } from '@/core/types';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
user_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||
group_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||
message_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||
});
|
||||
|
||||
type PlayloadType = Static<typeof SchemaData>;
|
||||
|
||||
class MarkMsgAsRead extends OneBotAction<PlayloadType, null> {
|
||||
async getPeer(payload: PlayloadType): Promise<Peer> {
|
||||
if (payload.message_id) {
|
||||
const s_peer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)?.Peer;
|
||||
if (s_peer) {
|
||||
return s_peer;
|
||||
}
|
||||
const l_peer = MessageUnique.getPeerByMsgId(payload.message_id.toString())?.Peer;
|
||||
if (l_peer) {
|
||||
return l_peer;
|
||||
}
|
||||
}
|
||||
if (payload.user_id) {
|
||||
const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
throw new Error( `私聊${payload.user_id}不存在`);
|
||||
}
|
||||
const isBuddy = await this.core.apis.FriendApi.isBuddy(peerUid);
|
||||
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||
}
|
||||
if (!payload.group_id) {
|
||||
throw new Error('缺少参数 group_id 或 user_id');
|
||||
}
|
||||
return { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||
}
|
||||
|
||||
async _handle(payload: PlayloadType): Promise<null> {
|
||||
const ret = await this.core.apis.MsgApi.setMsgRead(await this.getPeer(payload));
|
||||
if (ret.result != 0) {
|
||||
throw new Error('设置已读失败,' + ret.errMsg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 以下为非标准实现
|
||||
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
|
||||
override payloadSchema = SchemaData;
|
||||
override actionName = ActionName.MarkPrivateMsgAsRead;
|
||||
}
|
||||
|
||||
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||
override payloadSchema = SchemaData;
|
||||
override actionName = ActionName.MarkGroupMsgAsRead;
|
||||
}
|
||||
|
||||
export class GoCQHTTPMarkMsgAsRead extends MarkMsgAsRead {
|
||||
override actionName = ActionName.GoCQHTTP_MarkMsgAsRead;
|
||||
}
|
||||
|
||||
export class MarkAllMsgAsRead extends OneBotAction<void, null> {
|
||||
override actionName = ActionName._MarkAllMsgAsRead;
|
||||
|
||||
async _handle(): Promise<null> {
|
||||
await this.core.apis.MsgApi.markAllMsgAsRead();
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -7,7 +7,6 @@ import {
|
||||
OB11PostSendMsg,
|
||||
} from '@/onebot/types';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
import { decodeCQCode } from '@/onebot/helper/cqcode';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
@@ -17,9 +16,8 @@ import { PacketMsg } from '@/core/packet/message/message';
|
||||
import { rawMsgWithSendMsg } from '@/core/packet/message/converter';
|
||||
|
||||
export interface ReturnDataType {
|
||||
message_id: number;
|
||||
message_id: string;
|
||||
res_id?: string;
|
||||
forward_id?: string;
|
||||
}
|
||||
|
||||
export enum ContextMode {
|
||||
@@ -29,11 +27,9 @@ export enum ContextMode {
|
||||
}
|
||||
|
||||
// Normalizes a mixed type (CQCode/a single segment/segment array) into a segment array.
|
||||
export function normalize(message: OB11MessageMixType, autoEscape = false): OB11MessageData[] {
|
||||
export function normalize(message: OB11MessageMixType): OB11MessageData[] {
|
||||
return typeof message === 'string' ? (
|
||||
autoEscape ?
|
||||
[{ type: OB11MessageDataType.text, data: { text: message } }] :
|
||||
decodeCQCode(message)
|
||||
[{ type: OB11MessageDataType.text, data: { text: message } }]
|
||||
) : Array.isArray(message) ? message : [message];
|
||||
}
|
||||
|
||||
@@ -55,7 +51,7 @@ export async function createContext(core: NapCatCore, payload: OB11PostContext |
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: payload.group_id.toString(),
|
||||
guildId: ''
|
||||
}
|
||||
};
|
||||
}
|
||||
throw new Error('无法获取用户信息');
|
||||
}
|
||||
@@ -105,6 +101,8 @@ function getSpecialMsgNum(payload: OB11PostSendMsg, msgType: OB11MessageDataType
|
||||
}
|
||||
|
||||
export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
contextMode = ContextMode.Normal;
|
||||
|
||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||
const messages = normalize(payload.message);
|
||||
const nodeElementLength = getSpecialMsgNum(payload, OB11MessageDataType.node);
|
||||
@@ -116,18 +114,14 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
}
|
||||
return { valid: true };
|
||||
}
|
||||
async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload);
|
||||
}
|
||||
async base_handle(payload: OB11PostSendMsg, contextMode: ContextMode = ContextMode.Normal): Promise<ReturnDataType> {
|
||||
if (payload.message_type === 'group') contextMode = ContextMode.Group;
|
||||
if (payload.message_type === 'private') contextMode = ContextMode.Private;
|
||||
const peer = await createContext(this.core, payload, contextMode);
|
||||
|
||||
const messages = normalize(
|
||||
payload.message,
|
||||
typeof payload.auto_escape === 'string' ? payload.auto_escape === 'true' : !!payload.auto_escape,
|
||||
);
|
||||
async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
this.contextMode = ContextMode.Normal;
|
||||
if (payload.message_type === 'group') this.contextMode = ContextMode.Group;
|
||||
if (payload.message_type === 'private') this.contextMode = ContextMode.Private;
|
||||
const peer = await createContext(this.core, payload, this.contextMode);
|
||||
|
||||
const messages = normalize(payload.message);
|
||||
|
||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
const packetMode = this.core.apis.PacketApi.available;
|
||||
@@ -143,15 +137,15 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
throw Error('发送合并转发消息失败:returnMsgAndResId 为空!');
|
||||
}
|
||||
if (returnMsgAndResId.message) {
|
||||
const msgShortId = MessageUnique.createUniqueMsgId({
|
||||
const msgShortId = MessageUnique.getOutputData({
|
||||
guildId: '',
|
||||
peerUid: peer.peerUid,
|
||||
chatType: peer.chatType,
|
||||
}, (returnMsgAndResId.message).msgId);
|
||||
|
||||
// 对gocq的forward_id进行兼容
|
||||
const resId = returnMsgAndResId.res_id!;
|
||||
return { message_id: msgShortId!, res_id: resId, forward_id: resId };
|
||||
},
|
||||
(returnMsgAndResId.message).msgId,
|
||||
(returnMsgAndResId.message).msgSeq
|
||||
);
|
||||
return { message_id: msgShortId!, res_id: returnMsgAndResId.res_id! };
|
||||
} else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) {
|
||||
throw Error(`发送转发消息(res_id:${returnMsgAndResId.res_id} 失败`);
|
||||
}
|
||||
@@ -217,7 +211,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
packetMsg.push(transformedMsg);
|
||||
} else if (node.data.id) {
|
||||
const id = node.data.id;
|
||||
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(+id) || MessageUnique.getPeerByMsgId(id);
|
||||
const nodeMsg = MessageUnique.getInnerData(id);
|
||||
if (!nodeMsg) {
|
||||
this.core.context.logger.logError('转发消息失败,未找到消息', id);
|
||||
continue;
|
||||
@@ -276,17 +270,17 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
chatType: ChatType.KCHATTYPEC2C,
|
||||
peerUid: this.core.selfInfo.uid,
|
||||
};
|
||||
let nodeMsgIds: string[] = [];
|
||||
let nodeMsgIds: { MsgId: string, Peer: Peer }[] = [];
|
||||
for (const messageNode of messageNodes) {
|
||||
const nodeId = messageNode.data.id;
|
||||
if (nodeId) {
|
||||
// 对Msgid和OB11ID混用情况兜底
|
||||
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(nodeId)) || MessageUnique.getPeerByMsgId(nodeId);
|
||||
const nodeMsg = MessageUnique.getInnerData(nodeId);
|
||||
if (!nodeMsg) {
|
||||
this.core.context.logger.logError('转发消息失败,未找到消息', nodeId);
|
||||
continue;
|
||||
}
|
||||
nodeMsgIds.push(nodeMsg.MsgId);
|
||||
nodeMsgIds.push({ MsgId: nodeMsg.MsgId, Peer: nodeMsg.Peer });
|
||||
} else {
|
||||
// 自定义的消息
|
||||
try {
|
||||
@@ -300,8 +294,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
}
|
||||
const nodeMsg = await this.handleForwardedNodes(selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node));
|
||||
if (nodeMsg) {
|
||||
nodeMsgIds.push(nodeMsg.message!.msgId);
|
||||
MessageUnique.createUniqueMsgId(selfPeer, nodeMsg.message!.msgId);
|
||||
nodeMsgIds.push({ MsgId: nodeMsg.message!.msgId, Peer: selfPeer });
|
||||
}
|
||||
//完成子卡片生成跳过后续
|
||||
continue;
|
||||
@@ -327,8 +320,8 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
}
|
||||
(await Promise.allSettled(MsgNodeList)).map((result) => {
|
||||
if (result.status === 'fulfilled' && result.value) {
|
||||
nodeMsgIds.push(result.value.msgId);
|
||||
MessageUnique.createUniqueMsgId(selfPeer, result.value.msgId);
|
||||
nodeMsgIds.push({ MsgId: result.value.msgId, Peer: selfPeer });
|
||||
MessageUnique.getOutputData(selfPeer, result.value.msgId, result.value.msgSeq);
|
||||
}
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
@@ -340,22 +333,18 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
let srcPeer: Peer | undefined = undefined;
|
||||
let needSendSelf = false;
|
||||
//检测是否处于同一个Peer 不在同一个peer则全部消息由自身发送
|
||||
for (const msgId of nodeMsgIds) {
|
||||
const nodeMsgPeer = MessageUnique.getPeerByMsgId(msgId);
|
||||
if (!nodeMsgPeer) {
|
||||
this.core.context.logger.logError('转发消息失败,未找到消息', msgId);
|
||||
continue;
|
||||
}
|
||||
const nodeMsg = (await this.core.apis.MsgApi.getMsgsByMsgId(nodeMsgPeer.Peer, [msgId])).msgList[0];
|
||||
let new_nodeMsgIds: { MsgId: string, Peer: Peer }[] = [];
|
||||
for (const data of nodeMsgIds) {
|
||||
const nodeMsg = (await this.core.apis.MsgApi.getMsgsByMsgId(data.Peer, [data.MsgId])).msgList[0];
|
||||
if (nodeMsg) {
|
||||
srcPeer = srcPeer ?? { chatType: nodeMsg.chatType, peerUid: nodeMsg.peerUid };
|
||||
if (srcPeer.peerUid !== nodeMsg.peerUid) {
|
||||
needSendSelf = true;
|
||||
}
|
||||
nodeMsgArray.push(nodeMsg);
|
||||
new_nodeMsgIds.push({ MsgId: nodeMsg.msgId, Peer: data.Peer });
|
||||
}
|
||||
}
|
||||
nodeMsgIds = nodeMsgArray.map(msg => msg.msgId);
|
||||
nodeMsgIds = new_nodeMsgIds;
|
||||
let retMsgIds: string[] = [];
|
||||
if (needSendSelf) {
|
||||
for (const [, msg] of nodeMsgArray.entries()) {
|
||||
@@ -367,7 +356,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (ClonedMsg) retMsgIds.push(ClonedMsg.msgId);
|
||||
}
|
||||
} else {
|
||||
retMsgIds = nodeMsgIds;
|
||||
retMsgIds = nodeMsgIds.map((msg) => msg.MsgId);
|
||||
}
|
||||
if (retMsgIds.length === 0) throw Error('转发消息失败,生成节点为空');
|
||||
try {
|
||||
|
@@ -1,18 +1,16 @@
|
||||
import { ContextMode, ReturnDataType, SendMsgBase } from './SendMsg';
|
||||
import { ContextMode, SendMsgBase } from './SendMsg';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
import { OB11PostSendMsg } from '@/onebot/types';
|
||||
|
||||
// 未检测参数
|
||||
class SendPrivateMsg extends SendMsgBase {
|
||||
override actionName = ActionName.SendPrivateMsg;
|
||||
override contextMode: ContextMode = ContextMode.Private;
|
||||
|
||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||
payload.message_type = 'private';
|
||||
return super.check(payload);
|
||||
}
|
||||
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Private);
|
||||
}
|
||||
}
|
||||
|
||||
export default SendPrivateMsg;
|
||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||
message_id: Type.String(),
|
||||
emoji_id: Type.Union([Type.Number(), Type.String()]),
|
||||
set: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||
});
|
||||
@@ -16,7 +16,7 @@ export class SetMsgEmojiLike extends OneBotAction<Payload, unknown> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
||||
if (!msg) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ export class GetRkeyEx extends GetPacketStatusDepends<void, unknown> {
|
||||
let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey();
|
||||
return rkeys.map(rkey => {
|
||||
return {
|
||||
type: rkey.type === 10 ? "private" : "group",
|
||||
type: rkey.type === 10 ? 'private' : 'group',
|
||||
rkey: rkey.rkey,
|
||||
created_at: rkey.time,
|
||||
ttl: rkey.ttl,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user