mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c9cc08a9ba | ||
![]() |
66e1b1662f | ||
![]() |
9372e83bd8 | ||
![]() |
b38a240dbb | ||
![]() |
76b9506395 | ||
![]() |
f1cf636aa2 | ||
![]() |
312dcd0e13 | ||
![]() |
42c2419613 | ||
![]() |
8f7f748e82 | ||
![]() |
7ad3bad1be | ||
![]() |
5cd682e69f | ||
![]() |
5d57780e84 | ||
![]() |
f399955204 | ||
![]() |
770652fe6b | ||
![]() |
9ed5fa8c67 | ||
![]() |
5a4ad29727 | ||
![]() |
1eda3f2e33 | ||
![]() |
95cb95ef96 | ||
![]() |
4e7c96634c | ||
![]() |
58587b8aea | ||
![]() |
3fbf6239db | ||
![]() |
faec53d497 | ||
![]() |
482dcc534e | ||
![]() |
854f61dda6 | ||
![]() |
fca38713a1 | ||
![]() |
5dd3bade53 | ||
![]() |
665360f48d | ||
![]() |
65719cb56a | ||
![]() |
bdb76d4639 | ||
![]() |
15634412ef | ||
![]() |
bbcf9649fa | ||
![]() |
e845d7314e | ||
![]() |
6927b1c94f | ||
![]() |
a09c6acd0d | ||
![]() |
0963650ccb | ||
![]() |
380688b353 | ||
![]() |
ad5466bff8 | ||
![]() |
a83652bf3f | ||
![]() |
c632de314d | ||
![]() |
259c9610d5 | ||
![]() |
e9936c5524 | ||
![]() |
3f60440e72 | ||
![]() |
71a15f92fb | ||
![]() |
32bc0dd820 | ||
![]() |
20d1ac9d01 | ||
![]() |
18baf89e0e | ||
![]() |
3a1d1f2e59 | ||
![]() |
e9a048721d | ||
![]() |
68f0c7ff1a | ||
![]() |
2875fe94ea | ||
![]() |
1870427c0f | ||
![]() |
636568fd30 | ||
![]() |
bbc2391bf8 | ||
![]() |
401684542a | ||
![]() |
870edb2513 | ||
![]() |
7ad09169ea |
BIN
external/LiteLoaderWrapper.zip
vendored
BIN
external/LiteLoaderWrapper.zip
vendored
Binary file not shown.
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "4.7.63",
|
"version": "4.7.75",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -92,7 +92,9 @@ const MusicInsert = () => {
|
|||||||
className="w-96"
|
className="w-96"
|
||||||
fullWidth
|
fullWidth
|
||||||
selectedKey={mode}
|
selectedKey={mode}
|
||||||
onSelectionChange={setMode}
|
onSelectionChange={(key) => {
|
||||||
|
if (key !== null) setMode(key)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Tab title="主流平台" key="default" className="flex flex-col gap-2">
|
<Tab title="主流平台" key="default" className="flex flex-col gap-2">
|
||||||
<Select
|
<Select
|
||||||
|
@@ -56,9 +56,9 @@ export default function TerminalPage() {
|
|||||||
|
|
||||||
setTabs((prev) => [...prev, newTab])
|
setTabs((prev) => [...prev, newTab])
|
||||||
setSelectedTab(id)
|
setSelectedTab(id)
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to create terminal:', error)
|
console.error('Failed to create terminal:', error)
|
||||||
toast.error('创建终端失败')
|
toast.error((error as Error).message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "4.7.63",
|
"version": "4.7.75",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||||
|
@@ -8,12 +8,12 @@ import { pipeline } from 'stream/promises';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { LogWrapper } from './log';
|
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 = [
|
const urls = [
|
||||||
'https://github.moeyy.xyz/' + downloadOri,
|
"https://github.moeyy.xyz/" + downloadOri,
|
||||||
'https://ghp.ci/' + downloadOri,
|
"https://ghp.ci/" + downloadOri,
|
||||||
'https://gh.api.99988866.xyz/' + downloadOri,
|
"https://gh.api.99988866.xyz/" + downloadOri,
|
||||||
'https://gh.api.99988866.xyz/' + downloadOri,
|
"https://gh.api.99988866.xyz/" + downloadOri,
|
||||||
downloadOri
|
downloadOri
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -350,11 +350,11 @@ export async function downloadFFmpegIfNotExists(log: LogWrapper) {
|
|||||||
return {
|
return {
|
||||||
path: path.join(currentPath, 'ffmpeg'),
|
path: path.join(currentPath, 'ffmpeg'),
|
||||||
reset: true
|
reset: true
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path: path.join(currentPath, 'ffmpeg'),
|
path: path.join(currentPath, 'ffmpeg'),
|
||||||
reset: true
|
reset: true
|
||||||
};
|
}
|
||||||
}
|
}
|
@@ -182,28 +182,28 @@ export async function uriToLocalFile(dir: string, uri: string, filename: string
|
|||||||
const filePath = path.join(dir, filename);
|
const filePath = path.join(dir, filename);
|
||||||
|
|
||||||
switch (UriType) {
|
switch (UriType) {
|
||||||
case FileUriType.Local: {
|
case FileUriType.Local: {
|
||||||
const fileExt = path.extname(HandledUri);
|
const fileExt = path.extname(HandledUri);
|
||||||
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
||||||
const tempFilePath = path.join(dir, filename + fileExt);
|
const tempFilePath = path.join(dir, filename + fileExt);
|
||||||
fs.copyFileSync(HandledUri, tempFilePath);
|
fs.copyFileSync(HandledUri, tempFilePath);
|
||||||
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileUriType.Remote: {
|
case FileUriType.Remote: {
|
||||||
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
||||||
fs.writeFileSync(filePath, buffer);
|
fs.writeFileSync(filePath, buffer);
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileUriType.Base64: {
|
case FileUriType.Base64: {
|
||||||
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
||||||
const base64Buffer = Buffer.from(base64, 'base64');
|
const base64Buffer = Buffer.from(base64, 'base64');
|
||||||
fs.writeFileSync(filePath, base64Buffer);
|
fs.writeFileSync(filePath, base64Buffer);
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
import { Peer } from '@/core';
|
import { Peer } from '@/core';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
export class LimitedHashTable<K, V> {
|
export class LimitedHashTable<K, V> {
|
||||||
private readonly keyToValue: Map<K, V> = new Map();
|
private readonly keyToValue: Map<K, V> = new Map();
|
||||||
private readonly valueToKey: Map<V, K> = new Map();
|
private readonly valueToKey: Map<V, K> = new Map();
|
||||||
@@ -76,19 +78,65 @@ export class LimitedHashTable<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MessageUniqueWrapper {
|
class MessageUniqueWrapper {
|
||||||
constructor() {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOutputData(peer: Peer, msg_id: string, seq: string): string {
|
getRecentMsgIds(Peer: Peer, size: number): string[] {
|
||||||
return `${peer.chatType}|${msg_id}|${peer.peerUid}|${seq}`;
|
const heads = this.msgIdMap.getHeads(size);
|
||||||
}
|
if (!heads) {
|
||||||
|
return [];
|
||||||
getInnerData(shortId: string): { MsgId: string; Peer: Peer, seq: string } | undefined {
|
|
||||||
const [chatType, msgId, peerUid, seq] = shortId.split('|');
|
|
||||||
if (!chatType || !msgId || !peerUid || !seq) {
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
return { MsgId: msgId, Peer: { chatType: parseInt(chatType), peerUid, guildId: '' }, seq: seq };
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,11 +13,15 @@ export class NapCatPathWrapper {
|
|||||||
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
||||||
this.binaryPath = mainPath;
|
this.binaryPath = mainPath;
|
||||||
let writePath: string;
|
let writePath: string;
|
||||||
if (os.platform() === 'darwin') {
|
|
||||||
|
if (process.env['NAPCAT_WORKDIR']) {
|
||||||
|
writePath = process.env['NAPCAT_WORKDIR'];
|
||||||
|
} else if (os.platform() === 'darwin') {
|
||||||
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
||||||
} else {
|
} else {
|
||||||
writePath = this.binaryPath;
|
writePath = this.binaryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logsPath = path.join(writePath, 'logs');
|
this.logsPath = path.join(writePath, 'logs');
|
||||||
this.configPath = path.join(writePath, 'config');
|
this.configPath = path.join(writePath, 'config');
|
||||||
this.cachePath = path.join(writePath, 'cache');
|
this.cachePath = path.join(writePath, 'cache');
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '4.7.63';
|
export const napCatVersion = '4.7.75';
|
||||||
|
@@ -9,7 +9,7 @@ export async function runTask<T, R>(workerScript: string, taskData: T): Promise<
|
|||||||
console.error('Worker Log--->:', (result as { log: string }).log);
|
console.error('Worker Log--->:', (result as { log: string }).log);
|
||||||
}
|
}
|
||||||
if ((result as any)?.error) {
|
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);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
@@ -45,7 +45,7 @@ export class NTQQFileApi {
|
|||||||
'https://secret-service.bietiaop.com/rkeys',
|
'https://secret-service.bietiaop.com/rkeys',
|
||||||
'http://ss.xingzhige.com/music_card/rkey',
|
'http://ss.xingzhige.com/music_card/rkey',
|
||||||
],
|
],
|
||||||
this.context.logger
|
this.context.logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,18 +379,18 @@ export class NTQQFileApi {
|
|||||||
element.elementType === ElementType.FILE
|
element.elementType === ElementType.FILE
|
||||||
) {
|
) {
|
||||||
switch (element.elementType) {
|
switch (element.elementType) {
|
||||||
case ElementType.PIC:
|
case ElementType.PIC:
|
||||||
element.picElement!.sourcePath = elementResults?.[elementIndex] ?? '';
|
element.picElement!.sourcePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.VIDEO:
|
case ElementType.VIDEO:
|
||||||
element.videoElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.videoElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.PTT:
|
case ElementType.PTT:
|
||||||
element.pttElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.pttElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.FILE:
|
case ElementType.FILE:
|
||||||
element.fileElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.fileElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elementIndex++;
|
elementIndex++;
|
||||||
}
|
}
|
||||||
|
@@ -110,7 +110,7 @@ export class NTQQFriendApi {
|
|||||||
time: item.reqTime, // 信息字段
|
time: item.reqTime, // 信息字段
|
||||||
type: 'doubt' //保留字段
|
type: 'doubt' //保留字段
|
||||||
};
|
};
|
||||||
}));
|
}))
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,14 @@ import {
|
|||||||
GroupNotify,
|
GroupNotify,
|
||||||
GroupInfoSource,
|
GroupInfoSource,
|
||||||
ShutUpGroupMember,
|
ShutUpGroupMember,
|
||||||
|
Peer,
|
||||||
|
ChatType,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { isNumeric, solveAsyncProblem } from '@/common/helper';
|
import { isNumeric, solveAsyncProblem } from '@/common/helper';
|
||||||
import { LimitedHashTable } from '@/common/message-unique';
|
import { LimitedHashTable } from '@/common/message-unique';
|
||||||
import { NTEventWrapper } from '@/common/event';
|
import { NTEventWrapper } from '@/common/event';
|
||||||
import { CancelableTask, TaskExecutor } from '@/common/cancel-task';
|
import { CancelableTask, TaskExecutor } from '@/common/cancel-task';
|
||||||
|
import { createGroupDetailInfoV2Param, createGroupExtFilter, createGroupExtInfo } from '../data';
|
||||||
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -47,6 +50,22 @@ export class NTQQGroupApi {
|
|||||||
this.initCache().then().catch(e => this.context.logger.logError(e));
|
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() {
|
async initCache() {
|
||||||
for (const group of await this.getGroups(true)) {
|
for (const group of await this.getGroups(true)) {
|
||||||
this.refreshGroupMemberCache(group.groupCode, false).then().catch(e => this.context.logger.logError(e));
|
this.refreshGroupMemberCache(group.groupCode, false).then().catch(e => this.context.logger.logError(e));
|
||||||
@@ -95,6 +114,58 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getGroupService().setHeader(groupCode, filePath);
|
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) {
|
async getGroups(forced: boolean = false) {
|
||||||
const [, , groupList] = await this.core.eventWrapper.callNormalEventV2(
|
const [, , groupList] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelGroupService/getGroupList',
|
'NodeIKernelGroupService/getGroupList',
|
||||||
|
245
src/core/data/group.ts
Normal file
245
src/core/data/group.ts
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
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
src/core/data/index.ts
Normal file
1
src/core/data/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./group";
|
12
src/core/external/appid.json
vendored
12
src/core/external/appid.json
vendored
@@ -294,5 +294,17 @@
|
|||||||
"9.9.19-35184": {
|
"9.9.19-35184": {
|
||||||
"appid": 537291048,
|
"appid": 537291048,
|
||||||
"qua": "V1_WIN_NQ_9.9.19_35184_GW_B"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
16
src/core/external/offset.json
vendored
16
src/core/external/offset.json
vendored
@@ -378,5 +378,21 @@
|
|||||||
"9.9.19-35184-x64": {
|
"9.9.19-35184-x64": {
|
||||||
"send": "3BE5A10",
|
"send": "3BE5A10",
|
||||||
"recv": "3BEA210"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -30,13 +30,8 @@ export class PacketOperationContext {
|
|||||||
return await this.context.client.sendOidbPacket(pkt, rsp);
|
return await this.context.client.sendOidbPacket(pkt, rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
async GroupPoke(groupUin: number, uin: number) {
|
async SendPoke(is_group: boolean, peer: number, target?: number) {
|
||||||
const req = trans.SendPoke.build(uin, groupUin);
|
const req = trans.SendPoke.build(is_group, peer, target ?? peer);
|
||||||
await this.context.client.sendOidbPacket(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
async FriendPoke(uin: number) {
|
|
||||||
const req = trans.SendPoke.build(uin);
|
|
||||||
await this.context.client.sendOidbPacket(req);
|
await this.context.client.sendOidbPacket(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,9 +180,9 @@ export class PacketOperationContext {
|
|||||||
const ps = msg.map((m) => {
|
const ps = msg.map((m) => {
|
||||||
return m.msg.map(async (e) => {
|
return m.msg.map(async (e) => {
|
||||||
if (e instanceof PacketMsgReplyElement && !e.targetElems) {
|
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) {
|
if (!e.targetPeer?.peerUid) {
|
||||||
this.context.logger.error('targetPeer is undefined!');
|
this.context.logger.error(`targetPeer is undefined!`);
|
||||||
}
|
}
|
||||||
let targetMsg: NapProtoEncodeStructType<typeof PushMsgBody>[] | undefined;
|
let targetMsg: NapProtoEncodeStructType<typeof PushMsgBody>[] | undefined;
|
||||||
if (e.isGroupReply) {
|
if (e.isGroupReply) {
|
||||||
@@ -200,7 +195,7 @@ export class PacketOperationContext {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).flat();
|
}).flat();
|
||||||
await Promise.all(ps);
|
await Promise.all(ps)
|
||||||
await this.UploadResources(msg, groupUin);
|
await this.UploadResources(msg, groupUin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +203,14 @@ export class PacketOperationContext {
|
|||||||
const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq);
|
const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq);
|
||||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
const res = trans.FetchGroupMessage.parse(resp);
|
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>[]> {
|
async FetchC2CMessage(targetUid: string, startSeq: number, endSeq: number): Promise<NapProtoDecodeStructType<typeof PushMsgBody>[]> {
|
||||||
const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq);
|
const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq);
|
||||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
const res = trans.FetchC2CMessage.parse(resp);
|
const res = trans.FetchC2CMessage.parse(resp);
|
||||||
return res.messages;
|
return res.messages
|
||||||
}
|
}
|
||||||
|
|
||||||
async UploadForwardMsg(msg: PacketMsg[], groupUin: number = 0) {
|
async UploadForwardMsg(msg: PacketMsg[], groupUin: number = 0) {
|
||||||
|
@@ -8,13 +8,13 @@ class SendPoke extends PacketTransformer<typeof proto.OidbSvcTrpcTcpBase> {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
build(peer: number, group?: number): OidbPacket {
|
build(is_group: boolean, peer: number, target: number): OidbPacket {
|
||||||
const data = new NapProtoMsg(proto.OidbSvcTrpcTcp0XED3_1).encode({
|
const payload = {
|
||||||
uin: peer,
|
uin: target,
|
||||||
groupUin: group,
|
ext: 0,
|
||||||
friendUin: group ?? peer,
|
...(is_group ? { groupUin: peer } : { friendUin: peer })
|
||||||
ext: 0
|
};
|
||||||
});
|
const data = new NapProtoMsg(proto.OidbSvcTrpcTcp0XED3_1).encode(payload);
|
||||||
return OidbBase.build(0xED3, 1, data);
|
return OidbBase.build(0xED3, 1, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ class OidbBase extends PacketTransformer<typeof proto.OidbSvcTrpcTcpBase> {
|
|||||||
super();
|
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({
|
const data = new NapProtoMsg(proto.OidbSvcTrpcTcpBase).encode({
|
||||||
command: cmd,
|
command: cmd,
|
||||||
subCommand: subCmd,
|
subCommand: subCmd,
|
||||||
|
@@ -8,10 +8,22 @@ import {
|
|||||||
GroupNotifyMsgType,
|
GroupNotifyMsgType,
|
||||||
NTGroupRequestOperateTypes,
|
NTGroupRequestOperateTypes,
|
||||||
KickMemberV2Req,
|
KickMemberV2Req,
|
||||||
|
GroupDetailInfoV2Param,
|
||||||
|
GroupExtInfo,
|
||||||
|
GroupExtFilter,
|
||||||
} from '@/core/types';
|
} from '@/core/types';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
export interface NodeIKernelGroupService {
|
export interface NodeIKernelGroupService {
|
||||||
|
|
||||||
|
modifyGroupExtInfoV2(groupExtInfo: GroupExtInfo, groupExtFilter: GroupExtFilter): Promise<GeneralCallResult &
|
||||||
|
{
|
||||||
|
result: {
|
||||||
|
groupCode: string,
|
||||||
|
result: number
|
||||||
|
}
|
||||||
|
}>;
|
||||||
|
|
||||||
// --->
|
// --->
|
||||||
// 待启用 For Next Version 3.2.0
|
// 待启用 For Next Version 3.2.0
|
||||||
// isTroopMember ? 0 : 111
|
// isTroopMember ? 0 : 111
|
||||||
@@ -169,6 +181,9 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
modifyGroupDetailInfo(groupCode: string, arg: unknown): void;
|
modifyGroupDetailInfo(groupCode: string, arg: unknown): void;
|
||||||
|
|
||||||
|
// 第二个参数在大多数情况为0 设置群成员权限 例如上传群文件权限和群成员付费/加入邀请加入时为8
|
||||||
|
modifyGroupDetailInfoV2(param: GroupDetailInfoV2Param, arg: number): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
setGroupMsgMask(groupCode: string, arg: unknown): void;
|
setGroupMsgMask(groupCode: string, arg: unknown): void;
|
||||||
|
|
||||||
changeGroupShieldSettingTemp(groupCode: string, arg: unknown): void;
|
changeGroupShieldSettingTemp(groupCode: string, arg: unknown): void;
|
||||||
|
@@ -1,4 +1,97 @@
|
|||||||
import { QQLevel, NTSex } from './user';
|
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 {
|
export interface KickMemberInfo {
|
||||||
optFlag: number;
|
optFlag: number;
|
||||||
@@ -7,6 +100,185 @@ export interface KickMemberInfo {
|
|||||||
optBytesMsg: string;
|
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 {
|
export enum GroupInfoSource {
|
||||||
KUNSPECIFIED,
|
KUNSPECIFIED,
|
||||||
|
@@ -477,7 +477,7 @@ export enum SendStatusType {
|
|||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
parentMsgPeer: Peer; // 父消息的Peer
|
parentMsgPeer: Peer; // 父消息的Peer
|
||||||
parentMsgIdList: string[];// 父消息 ID 列表
|
parentMsgIdList: string[];// 父消息 ID 列表
|
||||||
id?: string;// 扩展字段,与 Ob11 msg ID 有关
|
id?: number;// 扩展字段,与 Ob11 msg ID 有关
|
||||||
guildId: string;// 频道ID
|
guildId: string;// 频道ID
|
||||||
msgRandom: string;// 消息ID相关
|
msgRandom: string;// 消息ID相关
|
||||||
msgId: string;// 雪花ID
|
msgId: string;// 雪花ID
|
||||||
|
@@ -48,6 +48,12 @@ 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 selfInfo = await new Promise<SelfInfo>((resolveSelfInfo) => {
|
||||||
const loginListener = new NodeIKernelLoginListener();
|
const loginListener = new NodeIKernelLoginListener();
|
||||||
loginListener.onQRCodeLoginSucceed = async (loginResult) => {
|
loginListener.onQRCodeLoginSucceed = async (loginResult) => {
|
||||||
|
26
src/framework/nativeLoader.cjs
Normal file
26
src/framework/nativeLoader.cjs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
bot_appid: Type.String(),
|
bot_appid: Type.String(),
|
||||||
button_id: Type.String({ default: '' }),
|
button_id: Type.String({ default: '' }),
|
||||||
callback_data: Type.String({ default: '' }),
|
callback_data: Type.String({ default: '' }),
|
||||||
@@ -25,6 +25,6 @@ export class ClickInlineKeyboardButton extends OneBotAction<Payload, unknown> {
|
|||||||
callback_data: payload.callback_data,
|
callback_data: payload.callback_data,
|
||||||
dmFlag: 0,
|
dmFlag: 0,
|
||||||
chatType: 2
|
chatType: 2
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
count: Type.Number({ default: 48 }),
|
count: Type.Union([Type.Number(), Type.String()], { default: 48 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -5,7 +5,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { type NTQQMsgApi } from '@/core/apis';
|
import { type NTQQMsgApi } from '@/core/apis';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
emojiId: Type.Union([Type.Number(), Type.String()]),
|
emojiId: Type.Union([Type.Number(), Type.String()]),
|
||||||
emojiType: Type.Union([Type.Number(), Type.String()]),
|
emojiType: Type.Union([Type.Number(), Type.String()]),
|
||||||
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
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;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msgIdPeer = MessageUnique.getInnerData(payload.message_id);
|
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msgIdPeer) throw new Error('消息不存在');
|
if (!msgIdPeer) throw new Error('消息不存在');
|
||||||
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
||||||
if (!msg) throw new Error('消息不存在');
|
if (!msg) throw new Error('消息不存在');
|
||||||
|
@@ -4,7 +4,7 @@ import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
|
|||||||
import { Type, Static } from '@sinclair/typebox';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
chat_type: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
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';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
category: Type.Number({ default: 0 }),
|
category: Type.Union([Type.Number(), Type.String()]),
|
||||||
count: Type.Number({ default: 1 }),
|
count: Type.Union([Type.Union([Type.Number(), Type.String()])], { default: 1 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { Type, Static } from '@sinclair/typebox';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Type, Static } from '@sinclair/typebox';
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.Optional(Type.String()),
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
start: Type.String({ default: '0' }),
|
start: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
count: Type.String({ default: '10' })
|
count: Type.Union([Type.Number(), Type.String()], { default: 10 })
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -36,7 +36,7 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
|||||||
uint64_uin: self_id,
|
uint64_uin: self_id,
|
||||||
uint64_top: 0,
|
uint64_top: 0,
|
||||||
uint32_req_num: 99,
|
uint32_req_num: 99,
|
||||||
bytes_cookies: ''
|
bytes_cookies: ""
|
||||||
};
|
};
|
||||||
const packed_data = await this.pack_data(JSON.stringify(req_json));
|
const packed_data = await this.pack_data(JSON.stringify(req_json));
|
||||||
const data = Buffer.from(packed_data).toString('hex');
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_id: Type.String(),
|
file_id: Type.String(),
|
||||||
current_parent_directory: Type.String(),
|
current_parent_directory: Type.String(),
|
||||||
target_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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_id: Type.String(),
|
file_id: Type.String(),
|
||||||
current_parent_directory: Type.String(),
|
current_parent_directory: Type.String(),
|
||||||
new_name: Type.String(),
|
new_name: Type.String(),
|
||||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
face_id: Type.String(),// 参考 face_config.json 的 QSid
|
face_id: Type.Union([Type.Number(), Type.String()]),// 参考 face_config.json 的 QSid
|
||||||
face_type: Type.String({ default: '1' }),
|
face_type: Type.Union([Type.Number(), Type.String()], { default: '1' }),
|
||||||
wording: Type.String({ default: ' ' }),
|
wording: Type.String({ default: ' ' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -16,9 +16,9 @@ export class SetDiyOnlineStatus extends OneBotAction<Payload, string> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const ret = await this.core.apis.UserApi.setDiySelfOnlineStatus(
|
const ret = await this.core.apis.UserApi.setDiySelfOnlineStatus(
|
||||||
payload.face_id,
|
payload.face_id.toString(),
|
||||||
payload.wording,
|
payload.wording,
|
||||||
payload.face_type,
|
payload.face_type.toString(),
|
||||||
);
|
);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('设置在线状态失败');
|
throw new Error('设置在线状态失败');
|
||||||
|
28
src/onebot/action/extends/SetGroupAddOption.ts
Normal file
28
src/onebot/action/extends/SetGroupAddOption.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
23
src/onebot/action/extends/SetGroupKickMembers.ts
Normal file
23
src/onebot/action/extends/SetGroupKickMembers.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
27
src/onebot/action/extends/SetGroupRobotAddOption.ts
Normal file
27
src/onebot/action/extends/SetGroupRobotAddOption.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
26
src/onebot/action/extends/SetGroupSearch.ts
Normal file
26
src/onebot/action/extends/SetGroupSearch.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -4,7 +4,7 @@ import { ChatType } from '@/core';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
event_type: Type.Number(),
|
event_type: Type.Number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
status: Type.Number(),
|
status: Type.Union([Type.Number(), Type.String()]),
|
||||||
ext_status: Type.Number(),
|
ext_status: Type.Union([Type.Number(), Type.String()]),
|
||||||
battery_status: Type.Number(),
|
battery_status: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -16,9 +16,9 @@ export class SetOnlineStatus extends OneBotAction<Payload, null> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
||||||
payload.status,
|
+payload.status,
|
||||||
payload.ext_status,
|
+payload.ext_status,
|
||||||
payload.battery_status,
|
+payload.battery_status,
|
||||||
);
|
);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('设置在线状态失败');
|
throw new Error('设置在线状态失败');
|
||||||
|
@@ -3,8 +3,8 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
special_title: Type.String({ default: '' }),
|
special_title: Type.String({ default: '' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.Optional(Type.String()),
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
group_id: Type.Optional(Type.String()),
|
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
phoneNumber: Type.String({ default: '' }),
|
phoneNumber: Type.String({ default: '' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export class SharePeer extends OneBotAction<Payload, GeneralCallResult & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SchemaDataGroupEx = Type.Object({
|
const SchemaDataGroupEx = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type PayloadGroupEx = Static<typeof SchemaDataGroupEx>;
|
type PayloadGroupEx = Static<typeof SchemaDataGroupEx>;
|
||||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_id: Type.String(),
|
file_id: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_id: Type.String(),
|
file_id: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
folder_name: Type.String(),
|
folder_name: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
import { NTQQGroupApi } from '@/core/apis';
|
import { NTQQGroupApi } from '@/core/apis';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_id: Type.String(),
|
file_id: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
import { NTQQGroupApi } from '@/core/apis';
|
import { NTQQGroupApi } from '@/core/apis';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
folder_id: Type.Optional(Type.String()),
|
folder_id: Type.Optional(Type.String()),
|
||||||
folder: Type.Optional(Type.String()),
|
folder: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
@@ -117,7 +117,8 @@ export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, {
|
|||||||
}
|
}
|
||||||
throw new Error('ResId无效: 找不到相关的聊天记录');
|
throw new Error('ResId无效: 找不到相关的聊天记录');
|
||||||
}
|
}
|
||||||
const rootMsg = MessageUnique.getInnerData(msgId);
|
const rootMsgId = MessageUnique.getShortIdByMsgId(msgId.toString());
|
||||||
|
const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId ?? +msgId);
|
||||||
|
|
||||||
if (rootMsg) {
|
if (rootMsg) {
|
||||||
// 5. 获取消息内容
|
// 5. 获取消息内容
|
||||||
|
@@ -12,7 +12,7 @@ interface Response {
|
|||||||
}
|
}
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.String(),
|
user_id: Type.String(),
|
||||||
message_id: Type.Optional(Type.String()),
|
message_seq: Type.Optional(Type.String()),
|
||||||
count: Type.Number({ default: 20 }),
|
count: Type.Number({ default: 20 }),
|
||||||
reverseOrder: Type.Boolean({ default: false })
|
reverseOrder: Type.Boolean({ default: false })
|
||||||
});
|
});
|
||||||
@@ -24,24 +24,24 @@ export default class GetFriendMsgHistory extends OneBotAction<Payload, Response>
|
|||||||
override actionName = ActionName.GetFriendMsgHistory;
|
override actionName = ActionName.GetFriendMsgHistory;
|
||||||
override payloadSchema = SchemaData;
|
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());
|
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
if (!uid) throw new Error(`记录${payload.user_id}不存在`);
|
if (!uid) throw new Error(`记录${payload.user_id}不存在`);
|
||||||
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
||||||
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||||
const hasMessageId = !payload.message_id ? !!payload.message_id : !(payload.message_id?.toString() === '' || payload.message_id?.toString() === '0');
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
const startMsgId = hasMessageId ? (MessageUnique.getInnerData(payload.message_id!)?.MsgId ?? payload.message_id!.toString()) : '0';
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
const msgList = hasMessageId ?
|
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;
|
(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_id}不存在`);
|
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||||
//转换序号
|
//转换序号
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = MessageUnique.getOutputData({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId, msg.msgSeq);
|
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||||
}));
|
}));
|
||||||
//烘焙消息
|
//烘焙消息
|
||||||
const ob11MsgList = (await Promise.all(
|
const ob11MsgList = (await Promise.all(
|
||||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat)))
|
||||||
).filter(msg => msg !== undefined);
|
).filter(msg => msg !== undefined);
|
||||||
return { 'messages': ob11MsgList };
|
return { 'messages': ob11MsgList };
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String()
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String()
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -5,7 +5,7 @@ import { OB11Construct } from '@/onebot/helper/data';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
folder_id: Type.Optional(Type.String()),
|
folder_id: Type.Optional(Type.String()),
|
||||||
folder: Type.Optional(Type.String()),
|
folder: Type.Optional(Type.String()),
|
||||||
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
type: Type.Optional(Type.Enum(WebHonorType))
|
type: Type.Optional(Type.Enum(WebHonorType))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -4,13 +4,15 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { ChatType, Peer } from '@/core/types';
|
import { ChatType, Peer } from '@/core/types';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.String(),
|
||||||
message_id: Type.Optional(Type.String()),
|
message_seq: Type.Optional(Type.String()),
|
||||||
count: Type.Number({ default: 20 }),
|
count: Type.Number({ default: 20 }),
|
||||||
reverseOrder: Type.Boolean({ default: false })
|
reverseOrder: Type.Boolean({ default: false })
|
||||||
});
|
});
|
||||||
@@ -23,21 +25,21 @@ export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Re
|
|||||||
override actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
override actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload, _adapter: string): Promise<Response> {
|
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig): Promise<Response> {
|
||||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
const hasMessageSeq = !payload.message_id ? !!payload.message_id : !(payload.message_id?.toString() === '' || payload.message_id?.toString() === '0');
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
//拉取消息
|
//拉取消息
|
||||||
const startMsgId = hasMessageSeq ? (MessageUnique.getInnerData(payload.message_id!)?.MsgId ?? payload.message_id!.toString()) : '0';
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
const msgList = hasMessageSeq ?
|
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;
|
(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_id}不存在`);
|
if (msgList.length === 0) throw new Error(`消息${payload.message_seq}不存在`);
|
||||||
//转换序号
|
//转换序号
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = MessageUnique.getOutputData({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId, msg.msgSeq);
|
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||||
}));
|
}));
|
||||||
//烘焙消息
|
//烘焙消息
|
||||||
const ob11MsgList = (await Promise.all(
|
const ob11MsgList = (await Promise.all(
|
||||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat)))
|
||||||
).filter(msg => msg !== undefined);
|
).filter(msg => msg !== undefined);
|
||||||
return { 'messages': ob11MsgList };
|
return { 'messages': ob11MsgList };
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ import { OB11Construct } from '@/onebot/helper/data';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file_count: Type.Union([Type.Number(), Type.String()], { default: 50 }),
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
no_cache: Type.Union([Type.Boolean(), Type.String()], { default: false }),
|
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.baseInfo,
|
||||||
...extendData.detail.simpleInfo.relationFlags ?? {},
|
...extendData.detail.simpleInfo.relationFlags ?? {},
|
||||||
...extendData.detail.simpleInfo.status ?? {},
|
...extendData.detail.simpleInfo.status ?? {},
|
||||||
user_id: extendData.detail.uin ?? 0,
|
user_id: parseInt(extendData.detail.uin) ?? 0,
|
||||||
uid: info.uid ?? uid,
|
uid: info.uid ?? uid,
|
||||||
nickname: extendData.detail.simpleInfo.coreInfo.nick ?? '',
|
nickname: extendData.detail.simpleInfo.coreInfo.nick ?? '',
|
||||||
age: extendData.detail.simpleInfo.baseInfo.age ?? info.age,
|
age: extendData.detail.simpleInfo.baseInfo.age ?? info.age,
|
||||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
friend_id: Type.Optional(Type.String()),
|
friend_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
user_id: Type.Optional(Type.String()),
|
user_id: Type.Optional(Type.Union([Type.String(), Type.Number()])),
|
||||||
temp_block: Type.Optional(Type.Boolean()),
|
temp_block: Type.Optional(Type.Boolean()),
|
||||||
temp_both_del: Type.Optional(Type.Boolean()),
|
temp_both_del: Type.Optional(Type.Boolean()),
|
||||||
});
|
});
|
||||||
|
19
src/onebot/action/go-cqhttp/QuickAction.ts
Normal file
19
src/onebot/action/go-cqhttp/QuickAction.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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 { normalize, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
import { ContextMode, normalize, ReturnDataType, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||||
import { OB11PostSendMsg } from '@/onebot/types';
|
import { OB11PostSendMsg } from '@/onebot/types';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
|
||||||
@@ -19,8 +19,14 @@ export class GoCQHTTPSendForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
|||||||
}
|
}
|
||||||
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||||
override actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
override actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
||||||
|
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||||
|
return this.base_handle(payload, ContextMode.Private);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||||
override actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
|
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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
content: Type.String(),
|
content: Type.String(),
|
||||||
image: Type.Optional(Type.String()),
|
image: Type.Optional(Type.String()),
|
||||||
pinned: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
pinned: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
|
@@ -6,7 +6,7 @@ import fs from 'node:fs/promises';
|
|||||||
import { GeneralCallResult } from '@/core';
|
import { GeneralCallResult } from '@/core';
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
file: Type.String(),
|
file: Type.String(),
|
||||||
group_id: Type.String()
|
group_id: Type.Union([Type.Number(), Type.String()])
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -7,7 +7,7 @@ import { SendMessageContext } from '@/onebot/api';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file: Type.String(),
|
file: Type.String(),
|
||||||
name: Type.String(),
|
name: Type.String(),
|
||||||
folder: Type.Optional(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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
file: Type.String(),
|
file: Type.String(),
|
||||||
name: Type.String(),
|
name: Type.String(),
|
||||||
});
|
});
|
||||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -13,7 +13,7 @@ export default class DelEssenceMsg extends OneBotAction<Payload, unknown> {
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<unknown> {
|
async _handle(payload: Payload): Promise<unknown> {
|
||||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
const data = this.core.apis.GroupApi.essenceLRU.getValue(+payload.message_id);
|
const data = this.core.apis.GroupApi.essenceLRU.getValue(+payload.message_id);
|
||||||
if(!data) throw new Error('消息不存在');
|
if(!data) throw new Error('消息不存在');
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
notice_id: Type.String()
|
notice_id: Type.String()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
character: Type.String(),
|
character: Type.String(),
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
text: Type.String(),
|
text: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -4,8 +4,10 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -20,12 +22,12 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: MessageUnique.getOutputData(peer, replyMsgList.msgId, replyMsgList.msgSeq),
|
id: MessageUnique.createUniqueMsgId(peer, replyMsgList.msgId),
|
||||||
msg: replyMsgList
|
msg: replyMsgList
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: Payload, _adapter: string) {
|
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||||
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
|
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
|
||||||
if (!msglist) {
|
if (!msglist) {
|
||||||
throw new Error('获取失败');
|
throw new Error('获取失败');
|
||||||
@@ -46,7 +48,7 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
|
|||||||
operator_nick: msg.add_digest_nick,
|
operator_nick: msg.add_digest_nick,
|
||||||
message_id: message_id,
|
message_id: message_id,
|
||||||
operator_time: msg.add_digest_time,
|
operator_time: msg.add_digest_time,
|
||||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage))?.message
|
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage, config.messagePostFormat))?.message
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const msgTempData = JSON.stringify({
|
const msgTempData = JSON.stringify({
|
||||||
|
@@ -5,7 +5,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -5,8 +5,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
no_cache: Type.Optional(Type.Union([Type.Boolean(), 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';
|
import { GroupMember } from '@/core';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()]))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ interface GroupNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
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({
|
const SchemaData = Type.Object({
|
||||||
character: Type.String(),
|
character: Type.String(),
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
text: Type.String(),
|
text: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,17 +1,19 @@
|
|||||||
import { ContextMode, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
import { ContextMode, ReturnDataType, SendMsgBase } from '@/onebot/action/msg/SendMsg';
|
||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||||
import { OB11PostSendMsg } from '@/onebot/types';
|
import { OB11PostSendMsg } from '@/onebot/types';
|
||||||
|
|
||||||
// 未检测参数
|
// 未检测参数
|
||||||
class SendGroupMsg extends SendMsgBase {
|
class SendGroupMsg extends SendMsgBase {
|
||||||
override actionName = ActionName.SendGroupMsg;
|
override actionName = ActionName.SendGroupMsg;
|
||||||
override contextMode: ContextMode = ContextMode.Group;
|
|
||||||
|
|
||||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
delete payload.user_id;
|
delete payload.user_id;
|
||||||
payload.message_type = 'group';
|
payload.message_type = 'group';
|
||||||
return super.check(payload);
|
return super.check(payload);
|
||||||
}
|
}
|
||||||
|
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||||
|
return this.base_handle(payload, ContextMode.Group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SendGroupMsg;
|
export default SendGroupMsg;
|
||||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -14,7 +14,7 @@ export default class SetEssenceMsg extends OneBotAction<Payload, unknown> {
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw new Error('msg not found');
|
throw new Error('msg not found');
|
||||||
}
|
}
|
||||||
|
@@ -4,8 +4,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
enable: Type.Optional(Type.Union([Type.Boolean(), 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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
duration: Type.String({ default: '0' }),
|
duration: Type.Union([Type.Number(), Type.String()], { default: 0 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
card: Type.Optional(Type.String())
|
card: Type.Optional(Type.String())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
user_id: Type.String(),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
reject_add_request: Type.Optional(Type.Union([Type.Boolean(), 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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
is_dismiss: Type.Optional(Type.Union([Type.Boolean(), 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';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_name: Type.String(),
|
group_name: Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
enable: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@ import SetGroupAdmin from './group/SetGroupAdmin';
|
|||||||
import SetGroupCard from './group/SetGroupCard';
|
import SetGroupCard from './group/SetGroupCard';
|
||||||
import GetImage from './file/GetImage';
|
import GetImage from './file/GetImage';
|
||||||
import GetRecord from './file/GetRecord';
|
import GetRecord from './file/GetRecord';
|
||||||
|
import { GoCQHTTPMarkMsgAsRead, MarkAllMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
|
||||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||||
import SetQQAvatar from '@/onebot/action/extends/SetQQAvatar';
|
import SetQQAvatar from '@/onebot/action/extends/SetQQAvatar';
|
||||||
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
||||||
@@ -47,6 +48,7 @@ import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from '@/onebot/action/m
|
|||||||
import { GetFriendWithCategory } from './extends/GetFriendWithCategory';
|
import { GetFriendWithCategory } from './extends/GetFriendWithCategory';
|
||||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice';
|
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice';
|
||||||
import { GetGroupHonorInfo } from './go-cqhttp/GetGroupHonorInfo';
|
import { GetGroupHonorInfo } from './go-cqhttp/GetGroupHonorInfo';
|
||||||
|
import { GoCQHTTPHandleQuickAction } from './go-cqhttp/QuickAction';
|
||||||
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
||||||
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
||||||
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
||||||
@@ -76,7 +78,6 @@ import { GetGroupFileSystemInfo } from '@/onebot/action/go-cqhttp/GetGroupFileSy
|
|||||||
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
||||||
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
||||||
import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
||||||
import { GroupPoke } from './group/GroupPoke';
|
|
||||||
import { GetUserStatus } from './extends/GetUserStatus';
|
import { GetUserStatus } from './extends/GetUserStatus';
|
||||||
import { GetRkey } from './extends/GetRkey';
|
import { GetRkey } from './extends/GetRkey';
|
||||||
import { SetSpecialTitle } from './extends/SetSpecialTitle';
|
import { SetSpecialTitle } from './extends/SetSpecialTitle';
|
||||||
@@ -84,7 +85,6 @@ import { GetGroupShutList } from './group/GetGroupShutList';
|
|||||||
import { GetGroupMemberList } from './group/GetGroupMemberList';
|
import { GetGroupMemberList } from './group/GetGroupMemberList';
|
||||||
import { GetGroupFileUrl } from '@/onebot/action/file/GetGroupFileUrl';
|
import { GetGroupFileUrl } from '@/onebot/action/file/GetGroupFileUrl';
|
||||||
import { GetPacketStatus } from '@/onebot/action/packet/GetPacketStatus';
|
import { GetPacketStatus } from '@/onebot/action/packet/GetPacketStatus';
|
||||||
import { FriendPoke } from '@/onebot/action/user/FriendPoke';
|
|
||||||
import { GetCredentials } from './system/GetCredentials';
|
import { GetCredentials } from './system/GetCredentials';
|
||||||
import { SendGroupSign, SetGroupSign } from './extends/SetGroupSign';
|
import { SendGroupSign, SetGroupSign } from './extends/SetGroupSign';
|
||||||
import { GoCQHTTPGetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain';
|
import { GoCQHTTPGetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain';
|
||||||
@@ -100,7 +100,7 @@ import { GetGuildList } from './guild/GetGuildList';
|
|||||||
import { GetGuildProfile } from './guild/GetGuildProfile';
|
import { GetGuildProfile } from './guild/GetGuildProfile';
|
||||||
import { GetClientkey } from './extends/GetClientkey';
|
import { GetClientkey } from './extends/GetClientkey';
|
||||||
import { SendPacket } from './extends/SendPacket';
|
import { SendPacket } from './extends/SendPacket';
|
||||||
import { SendPoke } from '@/onebot/action/packet/SendPoke';
|
import { FriendPoke, GroupPoke, SendPoke } from '@/onebot/action/packet/SendPoke';
|
||||||
import { SetDiyOnlineStatus } from './extends/SetDiyOnlineStatus';
|
import { SetDiyOnlineStatus } from './extends/SetDiyOnlineStatus';
|
||||||
import { BotExit } from './extends/BotExit';
|
import { BotExit } from './extends/BotExit';
|
||||||
import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
||||||
@@ -116,10 +116,18 @@ import { CleanCache } from './system/CleanCache';
|
|||||||
import SetFriendRemark from './user/SetFriendRemark';
|
import SetFriendRemark from './user/SetFriendRemark';
|
||||||
import { SetDoubtFriendsAddRequest } from './new/SetDoubtFriendsAddRequest';
|
import { SetDoubtFriendsAddRequest } from './new/SetDoubtFriendsAddRequest';
|
||||||
import { GetDoubtFriendsAddRequest } from './new/GetDoubtFriendsAddRequest';
|
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';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
|
new SetGroupKickMembers(obContext, core),
|
||||||
|
new SetGroupAddOption(obContext, core),
|
||||||
|
new SetGroupRobotAddOption(obContext, core),
|
||||||
|
new SetGroupSearch(obContext, core),
|
||||||
new SetDoubtFriendsAddRequest(obContext, core),
|
new SetDoubtFriendsAddRequest(obContext, core),
|
||||||
new GetDoubtFriendsAddRequest(obContext, core),
|
new GetDoubtFriendsAddRequest(obContext, core),
|
||||||
new SetFriendRemark(obContext, core),
|
new SetFriendRemark(obContext, core),
|
||||||
@@ -136,6 +144,8 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new SetLongNick(obContext, core),
|
new SetLongNick(obContext, core),
|
||||||
new ForwardFriendSingleMsg(obContext, core),
|
new ForwardFriendSingleMsg(obContext, core),
|
||||||
new ForwardGroupSingleMsg(obContext, core),
|
new ForwardGroupSingleMsg(obContext, core),
|
||||||
|
new MarkGroupMsgAsRead(obContext, core),
|
||||||
|
new MarkPrivateMsgAsRead(obContext, core),
|
||||||
new SetQQAvatar(obContext, core),
|
new SetQQAvatar(obContext, core),
|
||||||
new TranslateEnWordToZn(obContext, core),
|
new TranslateEnWordToZn(obContext, core),
|
||||||
new GetGroupRootFiles(obContext, core),
|
new GetGroupRootFiles(obContext, core),
|
||||||
@@ -195,14 +205,17 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new GoCQHTTPGetStrangerInfo(obContext, core),
|
new GoCQHTTPGetStrangerInfo(obContext, core),
|
||||||
new GoCQHTTPDownloadFile(obContext, core),
|
new GoCQHTTPDownloadFile(obContext, core),
|
||||||
new GetGuildList(obContext, core),
|
new GetGuildList(obContext, core),
|
||||||
|
new GoCQHTTPMarkMsgAsRead(obContext, core),
|
||||||
new GoCQHTTPUploadGroupFile(obContext, core),
|
new GoCQHTTPUploadGroupFile(obContext, core),
|
||||||
new GoCQHTTPGetGroupMsgHistory(obContext, core),
|
new GoCQHTTPGetGroupMsgHistory(obContext, core),
|
||||||
new GoCQHTTPGetForwardMsgAction(obContext, core),
|
new GoCQHTTPGetForwardMsgAction(obContext, core),
|
||||||
new GetFriendMsgHistory(obContext, core),
|
new GetFriendMsgHistory(obContext, core),
|
||||||
|
new GoCQHTTPHandleQuickAction(obContext, core),
|
||||||
new GetGroupIgnoredNotifies(obContext, core),
|
new GetGroupIgnoredNotifies(obContext, core),
|
||||||
new DelEssenceMsg(obContext, core),
|
new DelEssenceMsg(obContext, core),
|
||||||
new SetEssenceMsg(obContext, core),
|
new SetEssenceMsg(obContext, core),
|
||||||
new GetRecentContact(obContext, core),
|
new GetRecentContact(obContext, core),
|
||||||
|
new MarkAllMsgAsRead(obContext, core),
|
||||||
new GetProfileLike(obContext, core),
|
new GetProfileLike(obContext, core),
|
||||||
new SetGroupPortrait(obContext, core),
|
new SetGroupPortrait(obContext, core),
|
||||||
new FetchCustomFace(obContext, core),
|
new FetchCustomFace(obContext, core),
|
||||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -14,7 +14,7 @@ class DeleteMsg extends OneBotAction<Payload, void> {
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
||||||
if (msg) {
|
if (msg) {
|
||||||
await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId);
|
await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -5,9 +5,9 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
group_id: Type.Optional(Type.String()),
|
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
user_id: Type.Optional(Type.String()),
|
user_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -25,7 +25,7 @@ class ForwardSingleMsg extends OneBotAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw new Error(`无法找到消息${payload.message_id}`);
|
throw new Error(`无法找到消息${payload.message_id}`);
|
||||||
}
|
}
|
||||||
|
@@ -4,10 +4,12 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { RawMessage } from '@/core';
|
import { RawMessage } from '@/core';
|
||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||||
|
|
||||||
export type ReturnDataType = OB11Message
|
export type ReturnDataType = OB11Message
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -16,27 +18,30 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
|
|||||||
override actionName = ActionName.GetMsg;
|
override actionName = ActionName.GetMsg;
|
||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload, _adapter: string) {
|
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||||
if (!payload.message_id) {
|
if (!payload.message_id) {
|
||||||
throw Error('参数message_id不能为空');
|
throw Error('参数message_id不能为空');
|
||||||
}
|
}
|
||||||
const msgIdWithPeer = MessageUnique.getInnerData(payload.message_id);
|
const MsgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString());
|
||||||
|
const msgIdWithPeer = MessageUnique.getMsgIdAndPeerByShortId(MsgShortId ?? +payload.message_id);
|
||||||
if (!msgIdWithPeer) {
|
if (!msgIdWithPeer) {
|
||||||
throw new Error('消息不存在');
|
throw new Error('消息不存在');
|
||||||
}
|
}
|
||||||
const peer = { guildId: '', peerUid: msgIdWithPeer?.Peer.peerUid, chatType: msgIdWithPeer.Peer.chatType };
|
const peer = { guildId: '', peerUid: msgIdWithPeer?.Peer.peerUid, chatType: msgIdWithPeer.Peer.chatType };
|
||||||
const orimsg = this.obContext.recallMsgCache.get(msgIdWithPeer.MsgId);
|
const orimsg = this.obContext.recallMsgCache.get(msgIdWithPeer.MsgId);
|
||||||
let msg: RawMessage | undefined;
|
let msg: RawMessage|undefined;
|
||||||
if (orimsg) {
|
if (orimsg) {
|
||||||
msg = orimsg;
|
msg = orimsg;
|
||||||
} else {
|
} else {
|
||||||
msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0];
|
msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0];
|
||||||
}
|
}
|
||||||
if (!msg) throw Error('消息不存在');
|
if (!msg) throw Error('消息不存在');
|
||||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg);
|
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
||||||
if (!retMsg) throw Error('消息为空');
|
if (!retMsg) throw Error('消息为空');
|
||||||
try {
|
try {
|
||||||
retMsg.message_id = MessageUnique.getOutputData(peer, msg.msgId, msg.msgSeq)!;
|
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!;
|
||||||
|
retMsg.message_seq = retMsg.message_id;
|
||||||
|
retMsg.real_id = retMsg.message_id;
|
||||||
} catch {
|
} catch {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
72
src/onebot/action/msg/MarkMsgAsRead.ts
Normal file
72
src/onebot/action/msg/MarkMsgAsRead.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
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,6 +7,7 @@ import {
|
|||||||
OB11PostSendMsg,
|
OB11PostSendMsg,
|
||||||
} from '@/onebot/types';
|
} from '@/onebot/types';
|
||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||||
|
import { decodeCQCode } from '@/onebot/helper/cqcode';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
@@ -16,7 +17,7 @@ import { PacketMsg } from '@/core/packet/message/message';
|
|||||||
import { rawMsgWithSendMsg } from '@/core/packet/message/converter';
|
import { rawMsgWithSendMsg } from '@/core/packet/message/converter';
|
||||||
|
|
||||||
export interface ReturnDataType {
|
export interface ReturnDataType {
|
||||||
message_id: string;
|
message_id: number;
|
||||||
res_id?: string;
|
res_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,9 +28,11 @@ export enum ContextMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalizes a mixed type (CQCode/a single segment/segment array) into a segment array.
|
// Normalizes a mixed type (CQCode/a single segment/segment array) into a segment array.
|
||||||
export function normalize(message: OB11MessageMixType): OB11MessageData[] {
|
export function normalize(message: OB11MessageMixType, autoEscape = false): OB11MessageData[] {
|
||||||
return typeof message === 'string' ? (
|
return typeof message === 'string' ? (
|
||||||
[{ type: OB11MessageDataType.text, data: { text: message } }]
|
autoEscape ?
|
||||||
|
[{ type: OB11MessageDataType.text, data: { text: message } }] :
|
||||||
|
decodeCQCode(message)
|
||||||
) : Array.isArray(message) ? message : [message];
|
) : Array.isArray(message) ? message : [message];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ export async function createContext(core: NapCatCore, payload: OB11PostContext |
|
|||||||
chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: payload.group_id.toString(),
|
peerUid: payload.group_id.toString(),
|
||||||
guildId: ''
|
guildId: ''
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
throw new Error('无法获取用户信息');
|
throw new Error('无法获取用户信息');
|
||||||
}
|
}
|
||||||
@@ -101,8 +104,6 @@ function getSpecialMsgNum(payload: OB11PostSendMsg, msgType: OB11MessageDataType
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||||
contextMode = ContextMode.Normal;
|
|
||||||
|
|
||||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
const messages = normalize(payload.message);
|
const messages = normalize(payload.message);
|
||||||
const nodeElementLength = getSpecialMsgNum(payload, OB11MessageDataType.node);
|
const nodeElementLength = getSpecialMsgNum(payload, OB11MessageDataType.node);
|
||||||
@@ -114,14 +115,18 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
return { valid: true };
|
return { valid: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||||
this.contextMode = ContextMode.Normal;
|
return this.base_handle(payload);
|
||||||
if (payload.message_type === 'group') this.contextMode = ContextMode.Group;
|
}
|
||||||
if (payload.message_type === 'private') this.contextMode = ContextMode.Private;
|
async base_handle(payload: OB11PostSendMsg, contextMode: ContextMode = ContextMode.Normal): Promise<ReturnDataType> {
|
||||||
const peer = await createContext(this.core, payload, this.contextMode);
|
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);
|
const messages = normalize(
|
||||||
|
payload.message,
|
||||||
|
typeof payload.auto_escape === 'string' ? payload.auto_escape === 'true' : !!payload.auto_escape,
|
||||||
|
);
|
||||||
|
|
||||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||||
const packetMode = this.core.apis.PacketApi.available;
|
const packetMode = this.core.apis.PacketApi.available;
|
||||||
@@ -137,14 +142,11 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
throw Error('发送合并转发消息失败:returnMsgAndResId 为空!');
|
throw Error('发送合并转发消息失败:returnMsgAndResId 为空!');
|
||||||
}
|
}
|
||||||
if (returnMsgAndResId.message) {
|
if (returnMsgAndResId.message) {
|
||||||
const msgShortId = MessageUnique.getOutputData({
|
const msgShortId = MessageUnique.createUniqueMsgId({
|
||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: peer.peerUid,
|
peerUid: peer.peerUid,
|
||||||
chatType: peer.chatType,
|
chatType: peer.chatType,
|
||||||
},
|
}, (returnMsgAndResId.message).msgId);
|
||||||
(returnMsgAndResId.message).msgId,
|
|
||||||
(returnMsgAndResId.message).msgSeq
|
|
||||||
);
|
|
||||||
return { message_id: msgShortId!, res_id: returnMsgAndResId.res_id! };
|
return { message_id: msgShortId!, res_id: returnMsgAndResId.res_id! };
|
||||||
} else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) {
|
} else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) {
|
||||||
throw Error(`发送转发消息(res_id:${returnMsgAndResId.res_id} 失败`);
|
throw Error(`发送转发消息(res_id:${returnMsgAndResId.res_id} 失败`);
|
||||||
@@ -211,7 +213,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
packetMsg.push(transformedMsg);
|
packetMsg.push(transformedMsg);
|
||||||
} else if (node.data.id) {
|
} else if (node.data.id) {
|
||||||
const id = node.data.id;
|
const id = node.data.id;
|
||||||
const nodeMsg = MessageUnique.getInnerData(id);
|
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(+id) || MessageUnique.getPeerByMsgId(id);
|
||||||
if (!nodeMsg) {
|
if (!nodeMsg) {
|
||||||
this.core.context.logger.logError('转发消息失败,未找到消息', id);
|
this.core.context.logger.logError('转发消息失败,未找到消息', id);
|
||||||
continue;
|
continue;
|
||||||
@@ -270,17 +272,17 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
chatType: ChatType.KCHATTYPEC2C,
|
chatType: ChatType.KCHATTYPEC2C,
|
||||||
peerUid: this.core.selfInfo.uid,
|
peerUid: this.core.selfInfo.uid,
|
||||||
};
|
};
|
||||||
let nodeMsgIds: { MsgId: string, Peer: Peer }[] = [];
|
let nodeMsgIds: string[] = [];
|
||||||
for (const messageNode of messageNodes) {
|
for (const messageNode of messageNodes) {
|
||||||
const nodeId = messageNode.data.id;
|
const nodeId = messageNode.data.id;
|
||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
// 对Msgid和OB11ID混用情况兜底
|
// 对Msgid和OB11ID混用情况兜底
|
||||||
const nodeMsg = MessageUnique.getInnerData(nodeId);
|
const nodeMsg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(nodeId)) || MessageUnique.getPeerByMsgId(nodeId);
|
||||||
if (!nodeMsg) {
|
if (!nodeMsg) {
|
||||||
this.core.context.logger.logError('转发消息失败,未找到消息', nodeId);
|
this.core.context.logger.logError('转发消息失败,未找到消息', nodeId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nodeMsgIds.push({ MsgId: nodeMsg.MsgId, Peer: nodeMsg.Peer });
|
nodeMsgIds.push(nodeMsg.MsgId);
|
||||||
} else {
|
} else {
|
||||||
// 自定义的消息
|
// 自定义的消息
|
||||||
try {
|
try {
|
||||||
@@ -294,7 +296,8 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
const nodeMsg = await this.handleForwardedNodes(selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node));
|
const nodeMsg = await this.handleForwardedNodes(selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node));
|
||||||
if (nodeMsg) {
|
if (nodeMsg) {
|
||||||
nodeMsgIds.push({ MsgId: nodeMsg.message!.msgId, Peer: selfPeer });
|
nodeMsgIds.push(nodeMsg.message!.msgId);
|
||||||
|
MessageUnique.createUniqueMsgId(selfPeer, nodeMsg.message!.msgId);
|
||||||
}
|
}
|
||||||
//完成子卡片生成跳过后续
|
//完成子卡片生成跳过后续
|
||||||
continue;
|
continue;
|
||||||
@@ -320,8 +323,8 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
(await Promise.allSettled(MsgNodeList)).map((result) => {
|
(await Promise.allSettled(MsgNodeList)).map((result) => {
|
||||||
if (result.status === 'fulfilled' && result.value) {
|
if (result.status === 'fulfilled' && result.value) {
|
||||||
nodeMsgIds.push({ MsgId: result.value.msgId, Peer: selfPeer });
|
nodeMsgIds.push(result.value.msgId);
|
||||||
MessageUnique.getOutputData(selfPeer, result.value.msgId, result.value.msgSeq);
|
MessageUnique.createUniqueMsgId(selfPeer, result.value.msgId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
@@ -333,18 +336,22 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
let srcPeer: Peer | undefined = undefined;
|
let srcPeer: Peer | undefined = undefined;
|
||||||
let needSendSelf = false;
|
let needSendSelf = false;
|
||||||
//检测是否处于同一个Peer 不在同一个peer则全部消息由自身发送
|
//检测是否处于同一个Peer 不在同一个peer则全部消息由自身发送
|
||||||
let new_nodeMsgIds: { MsgId: string, Peer: Peer }[] = [];
|
for (const msgId of nodeMsgIds) {
|
||||||
for (const data of nodeMsgIds) {
|
const nodeMsgPeer = MessageUnique.getPeerByMsgId(msgId);
|
||||||
const nodeMsg = (await this.core.apis.MsgApi.getMsgsByMsgId(data.Peer, [data.MsgId])).msgList[0];
|
if (!nodeMsgPeer) {
|
||||||
|
this.core.context.logger.logError('转发消息失败,未找到消息', msgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const nodeMsg = (await this.core.apis.MsgApi.getMsgsByMsgId(nodeMsgPeer.Peer, [msgId])).msgList[0];
|
||||||
if (nodeMsg) {
|
if (nodeMsg) {
|
||||||
srcPeer = srcPeer ?? { chatType: nodeMsg.chatType, peerUid: nodeMsg.peerUid };
|
srcPeer = srcPeer ?? { chatType: nodeMsg.chatType, peerUid: nodeMsg.peerUid };
|
||||||
if (srcPeer.peerUid !== nodeMsg.peerUid) {
|
if (srcPeer.peerUid !== nodeMsg.peerUid) {
|
||||||
needSendSelf = true;
|
needSendSelf = true;
|
||||||
}
|
}
|
||||||
new_nodeMsgIds.push({ MsgId: nodeMsg.msgId, Peer: data.Peer });
|
nodeMsgArray.push(nodeMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeMsgIds = new_nodeMsgIds;
|
nodeMsgIds = nodeMsgArray.map(msg => msg.msgId);
|
||||||
let retMsgIds: string[] = [];
|
let retMsgIds: string[] = [];
|
||||||
if (needSendSelf) {
|
if (needSendSelf) {
|
||||||
for (const [, msg] of nodeMsgArray.entries()) {
|
for (const [, msg] of nodeMsgArray.entries()) {
|
||||||
@@ -356,7 +363,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
if (ClonedMsg) retMsgIds.push(ClonedMsg.msgId);
|
if (ClonedMsg) retMsgIds.push(ClonedMsg.msgId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retMsgIds = nodeMsgIds.map((msg) => msg.MsgId);
|
retMsgIds = nodeMsgIds;
|
||||||
}
|
}
|
||||||
if (retMsgIds.length === 0) throw Error('转发消息失败,生成节点为空');
|
if (retMsgIds.length === 0) throw Error('转发消息失败,生成节点为空');
|
||||||
try {
|
try {
|
||||||
|
@@ -1,16 +1,18 @@
|
|||||||
import { ContextMode, SendMsgBase } from './SendMsg';
|
import { ContextMode, ReturnDataType, SendMsgBase } from './SendMsg';
|
||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||||
import { OB11PostSendMsg } from '@/onebot/types';
|
import { OB11PostSendMsg } from '@/onebot/types';
|
||||||
|
|
||||||
// 未检测参数
|
// 未检测参数
|
||||||
class SendPrivateMsg extends SendMsgBase {
|
class SendPrivateMsg extends SendMsgBase {
|
||||||
override actionName = ActionName.SendPrivateMsg;
|
override actionName = ActionName.SendPrivateMsg;
|
||||||
override contextMode: ContextMode = ContextMode.Private;
|
|
||||||
|
|
||||||
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected override async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
payload.message_type = 'private';
|
payload.message_type = 'private';
|
||||||
return super.check(payload);
|
return super.check(payload);
|
||||||
}
|
}
|
||||||
|
override async _handle(payload: OB11PostSendMsg): Promise<ReturnDataType> {
|
||||||
|
return this.base_handle(payload, ContextMode.Private);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SendPrivateMsg;
|
export default SendPrivateMsg;
|
||||||
|
@@ -4,7 +4,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.String(),
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
emoji_id: Type.Union([Type.Number(), Type.String()]),
|
emoji_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
set: Type.Optional(Type.Union([Type.Boolean(), 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;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msg = MessageUnique.getInnerData(payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw new Error('msg not found');
|
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();
|
let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey();
|
||||||
return rkeys.map(rkey => {
|
return rkeys.map(rkey => {
|
||||||
return {
|
return {
|
||||||
type: rkey.type === 10 ? 'private' : 'group',
|
type: rkey.type === 10 ? "private" : "group",
|
||||||
rkey: rkey.rkey,
|
rkey: rkey.rkey,
|
||||||
created_at: rkey.time,
|
created_at: rkey.time,
|
||||||
ttl: rkey.ttl,
|
ttl: rkey.ttl,
|
||||||
|
@@ -30,7 +30,7 @@ export class GetRkeyServer extends GetPacketStatusDepends<void, { private_rkey?:
|
|||||||
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
|
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
|
||||||
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
|
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
|
||||||
expired_time: this.expiryTime,
|
expired_time: this.expiryTime,
|
||||||
name: 'NapCat 4'
|
name: "NapCat 4"
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.rkeyCache;
|
return this.rkeyCache;
|
||||||
|
@@ -4,20 +4,35 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.Optional(Type.String()),
|
group_id: Type.Optional(Type.String()),
|
||||||
user_id: Type.String(),
|
user_id: Type.Optional(Type.String()),
|
||||||
|
target_id: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
export class SendPokeBase extends GetPacketStatusDepends<Payload, void> {
|
||||||
export class SendPoke extends GetPacketStatusDepends<Payload, void> {
|
|
||||||
override actionName = ActionName.SendPoke;
|
|
||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
if (payload.group_id) {
|
// 这里的 !! 可以传入空字符串 忽略这些数据有利用接口统一接口
|
||||||
await this.core.apis.PacketApi.pkt.operation.GroupPoke(+payload.group_id, +payload.user_id);
|
const target_id = !!payload.target_id ? payload.target_id : payload.user_id;
|
||||||
} else {
|
const peer_id = !!payload.group_id ? payload.group_id : payload.user_id;
|
||||||
await this.core.apis.PacketApi.pkt.operation.FriendPoke(+payload.user_id);
|
|
||||||
|
const is_group = !!payload.group_id;
|
||||||
|
if (!target_id || !peer_id) {
|
||||||
|
throw new Error('请检查参数,缺少 user_id 或 group_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.core.apis.PacketApi.pkt.operation.SendPoke(is_group, +peer_id, +target_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class SendPoke extends SendPokeBase {
|
||||||
|
override actionName = ActionName.SendPoke;
|
||||||
|
}
|
||||||
|
export class GroupPoke extends SendPokeBase {
|
||||||
|
override actionName = ActionName.GroupPoke;
|
||||||
|
}
|
||||||
|
export class FriendPoke extends SendPokeBase {
|
||||||
|
override actionName = ActionName.FriendPoke;
|
||||||
|
}
|
||||||
|
@@ -10,6 +10,10 @@ export interface InvalidCheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ActionName = {
|
export const ActionName = {
|
||||||
|
SetGroupKickMembers: 'set_group_kick_members',
|
||||||
|
SetGroupRobotAddOption: 'set_group_robot_add_option',
|
||||||
|
SetGroupAddOption: 'set_group_add_option',
|
||||||
|
SetGroupSearch: 'set_group_search',
|
||||||
// new extends 完全差异OneBot类别
|
// new extends 完全差异OneBot类别
|
||||||
GetDoubtFriendsAddRequest: 'get_doubt_friends_add_request',
|
GetDoubtFriendsAddRequest: 'get_doubt_friends_add_request',
|
||||||
SetDoubtFriendsAddRequest: 'set_doubt_friends_add_request',
|
SetDoubtFriendsAddRequest: 'set_doubt_friends_add_request',
|
||||||
@@ -59,7 +63,7 @@ export const ActionName = {
|
|||||||
GetStatus: 'get_status',
|
GetStatus: 'get_status',
|
||||||
GetVersionInfo: 'get_version_info',
|
GetVersionInfo: 'get_version_info',
|
||||||
// Reboot : 'set_restart',
|
// Reboot : 'set_restart',
|
||||||
CleanCache : 'clean_cache',
|
CleanCache: 'clean_cache',
|
||||||
Exit: 'bot_exit',
|
Exit: 'bot_exit',
|
||||||
// go-cqhttp
|
// go-cqhttp
|
||||||
SetQQProfile: 'set_qq_profile',
|
SetQQProfile: 'set_qq_profile',
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user