mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
50ec49d9a2 | ||
![]() |
dc3a089070 | ||
![]() |
530e380178 | ||
![]() |
10e4387add | ||
![]() |
e925bc3aa8 | ||
![]() |
427b3a7560 | ||
![]() |
c8da950725 | ||
![]() |
743c5b8196 | ||
![]() |
5e62abea57 | ||
![]() |
6bfc545582 | ||
![]() |
411108a2d2 | ||
![]() |
308a6fa9e4 | ||
![]() |
2dc7b785d0 | ||
![]() |
0e69e9e839 | ||
![]() |
b83229b5da | ||
![]() |
6f053f5f7d | ||
![]() |
c3dc53eaaf | ||
![]() |
ffdc34cfe2 | ||
![]() |
4825a0e341 | ||
![]() |
95a00d7f35 | ||
![]() |
d885bab426 | ||
![]() |
e2a6a0bc02 | ||
![]() |
ff7d8609ce | ||
![]() |
7507b90e03 | ||
![]() |
2b226a4b27 | ||
![]() |
8b0232c4fe | ||
![]() |
0728ee9ad6 | ||
![]() |
8c6f04d0bc | ||
![]() |
c67fad789e |
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -127,6 +127,10 @@ jobs:
|
||||
zip -q -r NapCat.Framework.Windows.Once.zip *
|
||||
cd ..
|
||||
mv ./NapCat.Framework.Windows.Once/NapCat.Framework.Windows.Once.zip ./
|
||||
mv ./external/packet/napcat.packet.arm64 ./
|
||||
mv ./external/packet/napcat.packet.exe ./
|
||||
mv ./external/packet/napcat.packet.linux ./
|
||||
mv ./external/packet/napcat.packet.production.py ./
|
||||
- name: Extract version from tag
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||
|
||||
@@ -143,4 +147,8 @@ jobs:
|
||||
NapCat.Framework.zip
|
||||
NapCat.Shell.zip
|
||||
NapCat.Framework.Windows.Once.zip
|
||||
napcat.packet.arm64
|
||||
napcat.packet.exe
|
||||
napcat.packet.linux
|
||||
napcat.packet.production.py
|
||||
draft: true
|
||||
|
BIN
external/packet/napcat.packet.arm64
vendored
Normal file
BIN
external/packet/napcat.packet.arm64
vendored
Normal file
Binary file not shown.
BIN
external/packet/napcat.packet.exe
vendored
Normal file
BIN
external/packet/napcat.packet.exe
vendored
Normal file
Binary file not shown.
BIN
external/packet/napcat.packet.linux
vendored
Normal file
BIN
external/packet/napcat.packet.linux
vendored
Normal file
Binary file not shown.
102
external/packet/napcat.packet.production.py
vendored
Normal file
102
external/packet/napcat.packet.production.py
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
|
||||
"name": "NapCatQQ",
|
||||
"slug": "NapCat.Framework",
|
||||
"description": "高性能的 OneBot 11 协议实现",
|
||||
"version": "3.1.10",
|
||||
"version": "3.3.20",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "3.1.10",
|
||||
"version": "3.3.20",
|
||||
"scripts": {
|
||||
"build:framework": "vite build --mode framework",
|
||||
"build:shell": "vite build --mode shell",
|
||||
|
@@ -4,16 +4,27 @@ const process = require("process");
|
||||
console.log("[NapCat] [CheckVersion] 开始检测当前仓库版本...");
|
||||
try {
|
||||
const packageJson = require("../package.json");
|
||||
const manifsetJson = require("../manifest.json");
|
||||
|
||||
const currentVersion = packageJson.version;
|
||||
const targetVersion = process.env.VERSION;
|
||||
|
||||
const manifestCurrentVersion = manifsetJson.version;
|
||||
const manifestTargetVersion = process.env.VERSION;
|
||||
|
||||
console.log("[NapCat] [CheckVersion] currentVersion:", currentVersion, "targetVersion:", targetVersion);
|
||||
console.log("[NapCat] [CheckVersion] manifestCurrentVersion:", manifestCurrentVersion, "manifestTargetVersion:", manifestTargetVersion);
|
||||
|
||||
// 验证 targetVersion 格式
|
||||
if (!targetVersion || typeof targetVersion !== 'string') {
|
||||
console.log("[NapCat] [CheckVersion] 目标版本格式不正确或未设置!");
|
||||
return;
|
||||
}
|
||||
// 验证 manifestTargetVersion 格式
|
||||
if (!manifestTargetVersion || typeof manifestTargetVersion !== 'string') {
|
||||
console.log("[NapCat] [CheckVersion] manifest目标版本格式不正确或未设置!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 写入脚本文件的统一函数
|
||||
const writeScriptToFile = (content) => {
|
||||
@@ -21,7 +32,7 @@ try {
|
||||
console.log("[NapCat] [CheckVersion] checkVersion.sh 文件已更新。");
|
||||
};
|
||||
|
||||
if (currentVersion === targetVersion) {
|
||||
if (currentVersion === targetVersion && manifestCurrentVersion === manifestTargetVersion) {
|
||||
// 不需要更新版本,写入一个简单的脚本
|
||||
const simpleScript = "#!/bin/bash\necho \"CheckVersion Is Done\"";
|
||||
writeScriptToFile(simpleScript);
|
||||
@@ -29,11 +40,14 @@ try {
|
||||
// 更新版本,构建安全的sed命令
|
||||
const safeScriptContent = `
|
||||
#!/bin/bash
|
||||
git config --global user.email "bot@test.wumiao.wang"
|
||||
git config --global user.name "Version"
|
||||
sed -i "s/\\\"version\\\": \\\"${currentVersion}\\\"/\\\"version\\\": \\\"${targetVersion}\\\"/g" package.json
|
||||
git config --global user.email "nanaeonn@outlook.com"
|
||||
git config --global user.name "Mlikiowa"
|
||||
sed -i "s/\\"version\\": \\"${currentVersion}\\"/\\"version\\": \\"${targetVersion}\\"/g" package.json
|
||||
sed -i "s/\\"version\\": \\"${manifestCurrentVersion}\\"/\\"version\\": \\"${targetVersion}\\"/g" manifest.json
|
||||
sed -i "s/napCatVersion = '.*'/napCatVersion = '${targetVersion}'/g" ./src/common/version.ts
|
||||
sed -i "s/SettingButton(\\"V.*\\", \\"napcat-update-button\\", \\"secondary\\")/SettingButton(\\"V${targetVersion}\\", \\"napcat-update-button\\", \\"secondary\\")/g" ./static/assets/renderer.js
|
||||
git add .
|
||||
git commit -m "chore:version change"
|
||||
git commit -m "release: v${targetVersion}"
|
||||
git push -u origin main`;
|
||||
writeScriptToFile(safeScriptContent);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { PacketMsg } from "@/core/packet/msg/message";
|
||||
import { PacketMsg } from "@/core/packet/message/message";
|
||||
import * as crypto from "node:crypto";
|
||||
|
||||
interface ForwardMsgJson {
|
||||
|
@@ -239,3 +239,9 @@ export function calcQQLevel(level?: QQLevel) {
|
||||
const { crownNum, sunNum, moonNum, starNum } = level;
|
||||
return crownNum * 64 + sunNum * 16 + moonNum * 4 + starNum;
|
||||
}
|
||||
|
||||
export function stringifyWithBigInt(obj: any) {
|
||||
return JSON.stringify(obj, (key, value) =>
|
||||
typeof value === 'bigint' ? value.toString() : value
|
||||
);
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
export const napCatVersion = '3.1.10';
|
||||
export const napCatVersion = '3.3.20';
|
||||
|
@@ -82,6 +82,18 @@ export class NTQQMsgApi {
|
||||
pageLimit: 1,
|
||||
});
|
||||
}
|
||||
async queryMsgsWithFilterExWithSeqV3(peer: Peer, msgSeq: string, SendersUid: string[]) {
|
||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||
chatInfo: peer,
|
||||
filterMsgType: [],
|
||||
filterSendersUid: SendersUid,
|
||||
filterMsgToTime: '0',
|
||||
filterMsgFromTime: '0',
|
||||
isReverseOrder: false,
|
||||
isIncludeCurrent: true,
|
||||
pageLimit: 1,
|
||||
});
|
||||
}
|
||||
async queryFirstMsgBySeq(peer: Peer, msgSeq: string) {
|
||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||
chatInfo: peer,
|
||||
|
@@ -10,14 +10,16 @@ import { OidbSvcTrpcTcpBase, OidbSvcTrpcTcpBaseRsp } from '@/core/packet/proto/o
|
||||
import { OidbSvcTrpcTcp0XFE1_2RSP } from '@/core/packet/proto/oidb/Oidb.0XFE1_2';
|
||||
import { LogWrapper } from "@/common/log";
|
||||
import { SendLongMsgResp } from "@/core/packet/proto/message/action";
|
||||
import { PacketMsg } from "@/core/packet/msg/message";
|
||||
import { PacketMsg } from "@/core/packet/message/message";
|
||||
import { OidbSvcTrpcTcp0x6D6Response } from "@/core/packet/proto/oidb/Oidb.0x6D6";
|
||||
import {
|
||||
PacketMsgFileElement,
|
||||
PacketMsgPicElement,
|
||||
PacketMsgPttElement,
|
||||
PacketMsgVideoElement
|
||||
} from "@/core/packet/msg/element";
|
||||
} from "@/core/packet/message/element";
|
||||
import { MiniAppReqParams, MiniAppRawData } from "@/core/packet/entities/miniApp";
|
||||
import { MiniAppAdaptShareInfoResp } from "@/core/packet/proto/action/miniAppAdaptShareInfo";
|
||||
|
||||
|
||||
interface OffsetType {
|
||||
@@ -185,4 +187,11 @@ export class NTQQPacketApi {
|
||||
}
|
||||
return `https://${resp.download.downloadDns}/ftn_handler/${Buffer.from(resp.download.downloadUrl).toString('hex')}/?fname=`;
|
||||
}
|
||||
|
||||
async sendMiniAppShareInfoReq(param: MiniAppReqParams) {
|
||||
const data = this.packetSession?.packer.packMiniAppAdaptShareInfo(param);
|
||||
const ret = await this.sendPacket("LightAppSvc.mini_app_share.AdaptShareInfo", data!, true);
|
||||
const body = new NapProtoMsg(MiniAppAdaptShareInfoResp).decode(Buffer.from(ret.hex_data, 'hex'))
|
||||
return JSON.parse(body.content.jsonContent) as MiniAppRawData;
|
||||
}
|
||||
}
|
||||
|
79
src/core/packet/entities/miniApp.ts
Normal file
79
src/core/packet/entities/miniApp.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
export interface MiniAppReqCustomParams {
|
||||
title: string;
|
||||
desc: string;
|
||||
picUrl: string;
|
||||
jumpUrl: string;
|
||||
}
|
||||
|
||||
export interface MiniAppReqTemplateParams {
|
||||
sdkId: string;
|
||||
appId: string;
|
||||
scene: number;
|
||||
iconUrl: string;
|
||||
templateType: number;
|
||||
businessType: number;
|
||||
verType: number;
|
||||
shareType: number;
|
||||
versionId: string;
|
||||
withShareTicket: number;
|
||||
}
|
||||
|
||||
export interface MiniAppReqParams extends MiniAppReqCustomParams, MiniAppReqTemplateParams {}
|
||||
|
||||
export interface MiniAppData {
|
||||
ver: string;
|
||||
prompt: string;
|
||||
config: Config;
|
||||
app: string;
|
||||
view: string;
|
||||
meta: MetaData;
|
||||
miniappShareOrigin: number;
|
||||
miniappOpenRefer: string;
|
||||
}
|
||||
|
||||
export interface MiniAppRawData {
|
||||
appName: string;
|
||||
appView: string;
|
||||
ver: string;
|
||||
desc: string;
|
||||
prompt: string;
|
||||
metaData: MetaData;
|
||||
config: Config;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
forward: number;
|
||||
autoSize: number;
|
||||
ctime: number;
|
||||
token: string;
|
||||
}
|
||||
|
||||
interface Host {
|
||||
uin: number;
|
||||
nick: string;
|
||||
}
|
||||
|
||||
interface Detail {
|
||||
appid: string;
|
||||
appType: number;
|
||||
title: string;
|
||||
desc: string;
|
||||
icon: string;
|
||||
preview: string;
|
||||
url: string;
|
||||
scene: number;
|
||||
host: Host;
|
||||
shareTemplateId: string;
|
||||
shareTemplateData: Record<string, unknown>;
|
||||
showLittleTail: string;
|
||||
gamePoints: string;
|
||||
gamePointsUrl: string;
|
||||
shareOrigin: number;
|
||||
}
|
||||
|
||||
interface MetaData {
|
||||
detail_1: Detail;
|
||||
}
|
94
src/core/packet/helper/miniAppHelper.ts
Normal file
94
src/core/packet/helper/miniAppHelper.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import {
|
||||
MiniAppData,
|
||||
MiniAppReqParams,
|
||||
MiniAppRawData,
|
||||
MiniAppReqCustomParams,
|
||||
MiniAppReqTemplateParams
|
||||
} from "@/core/packet/entities/miniApp";
|
||||
|
||||
type MiniAppTemplateNameList = "bili" | "weibo";
|
||||
|
||||
export abstract class MiniAppInfo {
|
||||
static sdkId: string = "V1_PC_MINISDK_99.99.99_1_APP_A";
|
||||
template: MiniAppReqTemplateParams;
|
||||
|
||||
private static appMap = new Map<MiniAppTemplateNameList, MiniAppInfo>();
|
||||
|
||||
protected constructor(template: MiniAppReqTemplateParams) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
static get(name: MiniAppTemplateNameList): MiniAppInfo | undefined {
|
||||
return this.appMap.get(name);
|
||||
}
|
||||
|
||||
static Bili = new class extends MiniAppInfo {
|
||||
constructor() {
|
||||
super({
|
||||
sdkId: MiniAppInfo.sdkId,
|
||||
appId: "1109937557",
|
||||
scene: 1,
|
||||
templateType: 1,
|
||||
businessType: 0,
|
||||
verType: 3,
|
||||
shareType: 0,
|
||||
versionId: "cfc5f7b05b44b5956502edaecf9d2240",
|
||||
withShareTicket: 0,
|
||||
iconUrl: "https://miniapp.gtimg.cn/public/appicon/51f90239b78a2e4994c11215f4c4ba15_200.jpg"
|
||||
});
|
||||
MiniAppInfo.appMap.set("bili", this);
|
||||
}
|
||||
}
|
||||
|
||||
static WeiBo = new class extends MiniAppInfo {
|
||||
constructor() {
|
||||
super({
|
||||
sdkId: MiniAppInfo.sdkId,
|
||||
appId: "1109224783",
|
||||
scene: 1,
|
||||
templateType: 1,
|
||||
businessType: 0,
|
||||
verType: 3,
|
||||
shareType: 0,
|
||||
versionId: "e482a3cc4e574d9b772e96ba6eec9ba2",
|
||||
withShareTicket: 0,
|
||||
iconUrl: "https://miniapp.gtimg.cn/public/appicon/35bbb44dc68e65194cfacfb206b8f1f7_200.jpg"
|
||||
});
|
||||
MiniAppInfo.appMap.set("weibo", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class MiniAppInfoHelper {
|
||||
static generateReq(custom: MiniAppReqCustomParams, template: MiniAppReqTemplateParams): MiniAppReqParams {
|
||||
return {
|
||||
...custom,
|
||||
...template
|
||||
};
|
||||
}
|
||||
|
||||
static RawToSend(rawData: MiniAppRawData): MiniAppData {
|
||||
return {
|
||||
ver: rawData.ver,
|
||||
prompt: rawData.prompt,
|
||||
config: rawData.config,
|
||||
app: rawData.appName,
|
||||
view: rawData.appView,
|
||||
meta: rawData.metaData,
|
||||
miniappShareOrigin: 3,
|
||||
miniappOpenRefer: "10002",
|
||||
};
|
||||
}
|
||||
|
||||
static SendToRaw(data: MiniAppData): MiniAppRawData {
|
||||
return {
|
||||
appName: data.app,
|
||||
appView: data.view,
|
||||
ver: data.ver,
|
||||
desc: data.meta.detail_1.desc,
|
||||
prompt: data.prompt,
|
||||
metaData: data.meta,
|
||||
config: data.config,
|
||||
};
|
||||
}
|
||||
}
|
@@ -13,7 +13,7 @@ import {
|
||||
PacketMsgPicElement,
|
||||
PacketMsgPttElement,
|
||||
PacketMsgVideoElement
|
||||
} from "@/core/packet/msg/element";
|
||||
} from "@/core/packet/message/element";
|
||||
import { FileUploadExt, NTV2RichMediaHighwayExt } from "@/core/packet/proto/highway/highway";
|
||||
import { int32ip2str, oidbIpv4s2HighwayIpv4s } from "@/core/packet/highway/utils";
|
||||
import { calculateSha1, calculateSha1StreamBytes, computeMd5AndLengthWithLimit } from "@/core/packet/utils/crypto/hash";
|
||||
|
@@ -2,8 +2,8 @@ import * as crypto from "crypto";
|
||||
import { PushMsgBody } from "@/core/packet/proto/message/message";
|
||||
import { NapProtoEncodeStructType } from "@/core/packet/proto/NapProto";
|
||||
import { LogWrapper } from "@/common/log";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/msg/message";
|
||||
import { IPacketMsgElement, PacketMsgTextElement } from "@/core/packet/msg/element";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/message/message";
|
||||
import { IPacketMsgElement, PacketMsgTextElement } from "@/core/packet/message/element";
|
||||
import { SendTextElement } from "@/core";
|
||||
|
||||
export class PacketMsgBuilder {
|
@@ -30,8 +30,8 @@ import {
|
||||
PacketMsgTextElement,
|
||||
PacketMsgVideoElement,
|
||||
PacketMultiMsgElement
|
||||
} from "@/core/packet/msg/element";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/msg/message";
|
||||
} from "@/core/packet/message/element";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/message/message";
|
||||
import { LogWrapper } from "@/common/log";
|
||||
|
||||
const SupportedElementTypes = [
|
@@ -25,7 +25,7 @@ import {
|
||||
SendVideoElement
|
||||
} from "@/core";
|
||||
import { MsgInfo } from "@/core/packet/proto/oidb/common/Ntv2.RichMediaReq";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/msg/message";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/message/message";
|
||||
import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
|
||||
import { FileExtra, GroupFileExtra } from "@/core/packet/proto/message/component";
|
||||
import { OidbSvcTrpcTcp0XE37_800Response } from "@/core/packet/proto/oidb/Oidb.0XE37_800";
|
@@ -1,4 +1,4 @@
|
||||
import { IPacketMsgElement } from "@/core/packet/msg/element";
|
||||
import { IPacketMsgElement } from "@/core/packet/message/element";
|
||||
import { SendMessageElement, SendStructLongMsgElement } from "@/core";
|
||||
|
||||
export type PacketSendMsgElement = SendMessageElement | SendStructLongMsgElement
|
@@ -10,22 +10,24 @@ import { OidbSvcTrpcTcp0XED3_1 } from "@/core/packet/proto/oidb/Oidb.0xED3_1";
|
||||
import { NTV2RichMediaReq } from "@/core/packet/proto/oidb/common/Ntv2.RichMediaReq";
|
||||
import { HttpConn0x6ff_501 } from "@/core/packet/proto/action/action";
|
||||
import { LongMsgResult, SendLongMsgReq } from "@/core/packet/proto/message/action";
|
||||
import { PacketMsgBuilder } from "@/core/packet/msg/builder";
|
||||
import { PacketMsgBuilder } from "@/core/packet/message/builder";
|
||||
import {
|
||||
PacketMsgFileElement,
|
||||
PacketMsgPicElement,
|
||||
PacketMsgPttElement,
|
||||
PacketMsgVideoElement
|
||||
} from "@/core/packet/msg/element";
|
||||
} from "@/core/packet/message/element";
|
||||
import { LogWrapper } from "@/common/log";
|
||||
import { PacketMsg } from "@/core/packet/msg/message";
|
||||
import { PacketMsg } from "@/core/packet/message/message";
|
||||
import { OidbSvcTrpcTcp0x6D6 } from "@/core/packet/proto/oidb/Oidb.0x6D6";
|
||||
import { OidbSvcTrpcTcp0XE37_1200 } from "@/core/packet/proto/oidb/Oidb.0xE37_1200";
|
||||
import { PacketMsgConverter } from "@/core/packet/msg/converter";
|
||||
import { PacketMsgConverter } from "@/core/packet/message/converter";
|
||||
import { PacketClient } from "@/core/packet/client";
|
||||
import { OidbSvcTrpcTcp0XE37_1700 } from "@/core/packet/proto/oidb/Oidb.0xE37_1700";
|
||||
import { OidbSvcTrpcTcp0XE37_800 } from "@/core/packet/proto/oidb/Oidb.0XE37_800";
|
||||
import { OidbSvcTrpcTcp0XEB7 } from "./proto/oidb/Oidb.0xEB7";
|
||||
import { MiniAppReqParams } from "@/core/packet/entities/miniApp";
|
||||
import { MiniAppAdaptShareInfoReq } from "@/core/packet/proto/action/miniAppAdaptShareInfo";
|
||||
|
||||
export type PacketHexStr = string & { readonly hexNya: unique symbol };
|
||||
|
||||
@@ -705,4 +707,41 @@ export class PacketPacker {
|
||||
}
|
||||
), false, false);
|
||||
}
|
||||
|
||||
packMiniAppAdaptShareInfo(req: MiniAppReqParams): PacketHexStr {
|
||||
return this.packetPacket(
|
||||
new NapProtoMsg(MiniAppAdaptShareInfoReq).encode(
|
||||
{
|
||||
appId: req.sdkId,
|
||||
body: {
|
||||
extInfo: {
|
||||
field2: Buffer.alloc(0)
|
||||
},
|
||||
appid: req.appId,
|
||||
title: req.title,
|
||||
desc: req.desc,
|
||||
time: BigInt(Date.now()),
|
||||
scene: req.scene,
|
||||
templateType: req.templateType,
|
||||
businessType: req.businessType,
|
||||
picUrl: req.picUrl,
|
||||
vidUrl: "",
|
||||
jumpUrl: req.jumpUrl,
|
||||
iconUrl: req.iconUrl,
|
||||
verType: req.verType,
|
||||
shareType: req.shareType,
|
||||
versionId: req.versionId,
|
||||
withShareTicket: req.withShareTicket,
|
||||
webURL: "",
|
||||
appidRich: Buffer.alloc(0),
|
||||
template: {
|
||||
templateId: "",
|
||||
templateData: ""
|
||||
},
|
||||
field20: ""
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
49
src/core/packet/proto/action/miniAppAdaptShareInfo.ts
Normal file
49
src/core/packet/proto/action/miniAppAdaptShareInfo.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { ScalarType } from "@protobuf-ts/runtime";
|
||||
import { ProtoField } from "../NapProto";
|
||||
|
||||
export const MiniAppAdaptShareInfoReq = {
|
||||
appId: ProtoField(2, ScalarType.STRING),
|
||||
body: ProtoField(4, () => MiniAppAdaptShareInfoReqBody),
|
||||
};
|
||||
|
||||
export const MiniAppAdaptShareInfoReqBody = {
|
||||
extInfo: ProtoField(1, () => ExtInfo),
|
||||
appid: ProtoField(2, ScalarType.STRING),
|
||||
title: ProtoField(3, ScalarType.STRING),
|
||||
desc: ProtoField(4, ScalarType.STRING),
|
||||
time: ProtoField(5, ScalarType.UINT64),
|
||||
scene: ProtoField(6, ScalarType.UINT32),
|
||||
templateType: ProtoField(7, ScalarType.UINT32),
|
||||
businessType: ProtoField(8, ScalarType.UINT32),
|
||||
picUrl: ProtoField(9, ScalarType.STRING),
|
||||
vidUrl: ProtoField(10, ScalarType.STRING),
|
||||
jumpUrl: ProtoField(11, ScalarType.STRING),
|
||||
iconUrl: ProtoField(12, ScalarType.STRING),
|
||||
verType: ProtoField(13, ScalarType.UINT32),
|
||||
shareType: ProtoField(14, ScalarType.UINT32),
|
||||
versionId: ProtoField(15, ScalarType.STRING),
|
||||
withShareTicket: ProtoField(16, ScalarType.UINT32),
|
||||
webURL: ProtoField(17, ScalarType.STRING),
|
||||
appidRich: ProtoField(18, ScalarType.BYTES),
|
||||
template: ProtoField(19, () => Template),
|
||||
field20: ProtoField(20, ScalarType.STRING),
|
||||
};
|
||||
|
||||
export const ExtInfo = {
|
||||
field2: ProtoField(2, ScalarType.BYTES),
|
||||
};
|
||||
|
||||
export const Template = {
|
||||
templateId: ProtoField(1, ScalarType.STRING),
|
||||
templateData: ProtoField(2, ScalarType.STRING),
|
||||
};
|
||||
|
||||
export const MiniAppAdaptShareInfoResp = {
|
||||
field2: ProtoField(2, ScalarType.UINT32),
|
||||
field3: ProtoField(3, ScalarType.STRING),
|
||||
content: ProtoField(4, () => MiniAppAdaptShareInfoRespContent),
|
||||
};
|
||||
|
||||
export const MiniAppAdaptShareInfoRespContent = {
|
||||
jsonContent: ProtoField(2, ScalarType.STRING),
|
||||
};
|
@@ -232,7 +232,8 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
getGroupStatisticInfo(groupCode: string): unknown;
|
||||
|
||||
getGroupRemainAtTimes(groupCode: string): Promise<GeneralCallResult & {
|
||||
getGroupRemainAtTimes(groupCode: string): Promise<Omit<GeneralCallResult, 'result'> & {
|
||||
errCode: number,
|
||||
atInfo: {
|
||||
canAtAll: boolean
|
||||
RemainAtAllCountForUin: number
|
||||
|
85
src/onebot/action/extends/GetMiniAppArk.ts
Normal file
85
src/onebot/action/extends/GetMiniAppArk.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import {ActionName} from '../types';
|
||||
import {FromSchema, JSONSchema} from 'json-schema-to-ts';
|
||||
import {GetPacketStatusDepends} from "@/onebot/action/packet/GetPacketStatus";
|
||||
import {MiniAppData, MiniAppRawData, MiniAppReqCustomParams, MiniAppReqParams} from "@/core/packet/entities/miniApp";
|
||||
import {MiniAppInfo, MiniAppInfoHelper} from "@/core/packet/helper/miniAppHelper";
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: ['bili', 'weibo']
|
||||
},
|
||||
title: {type: 'string'},
|
||||
desc: {type: 'string'},
|
||||
picUrl: {type: 'string'},
|
||||
jumpUrl: {type: 'string'},
|
||||
iconUrl: {type: 'string'},
|
||||
sdkId: {type: 'string'},
|
||||
appId: {type: 'string'},
|
||||
scene: {type: ['number', 'string']},
|
||||
templateType: {type: ['number', 'string']},
|
||||
businessType: {type: ['number', 'string']},
|
||||
verType: {type: ['number', 'string']},
|
||||
shareType: {type: ['number', 'string']},
|
||||
versionId: {type: 'string'},
|
||||
withShareTicket: {type: ['number', 'string']},
|
||||
rawArkData: {type: ['boolean', 'string']}
|
||||
},
|
||||
oneOf: [
|
||||
{
|
||||
required: ['type', 'title', 'desc', 'picUrl', 'jumpUrl']
|
||||
},
|
||||
{
|
||||
required: [
|
||||
'title', 'desc', 'picUrl', 'jumpUrl',
|
||||
'iconUrl', 'appId', 'scene', 'templateType', 'businessType',
|
||||
'verType', 'shareType', 'versionId', 'withShareTicket'
|
||||
]
|
||||
}
|
||||
]
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetMiniAppArk extends GetPacketStatusDepends<Payload, {
|
||||
data: MiniAppData | MiniAppRawData
|
||||
}> {
|
||||
actionName = ActionName.GetMiniAppArk;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
let reqParam: MiniAppReqParams;
|
||||
const customParams = {
|
||||
title: payload.title,
|
||||
desc: payload.desc,
|
||||
picUrl: payload.picUrl,
|
||||
jumpUrl: payload.jumpUrl
|
||||
} as MiniAppReqCustomParams;
|
||||
if (payload.type) {
|
||||
reqParam = MiniAppInfoHelper.generateReq(customParams, MiniAppInfo.get(payload.type)!.template);
|
||||
} else {
|
||||
const { appId, scene, iconUrl, templateType, businessType, verType, shareType, versionId, withShareTicket } = payload as Required<Payload>;
|
||||
reqParam = MiniAppInfoHelper.generateReq(
|
||||
customParams,
|
||||
{
|
||||
sdkId: payload.sdkId ?? MiniAppInfo.sdkId,
|
||||
appId: appId,
|
||||
scene: +scene,
|
||||
iconUrl: iconUrl,
|
||||
templateType: +templateType,
|
||||
businessType: +businessType,
|
||||
verType: +verType,
|
||||
shareType: +shareType,
|
||||
versionId: versionId,
|
||||
withShareTicket: +withShareTicket
|
||||
}
|
||||
)
|
||||
}
|
||||
const arkData = await this.core.apis.PacketApi.sendMiniAppShareInfoReq(reqParam);
|
||||
return {
|
||||
data: Boolean(payload.rawArkData) ? arkData : MiniAppInfoHelper.RawToSend(arkData)
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,9 +17,6 @@ export class GoCQHTTPGetGroupAtAllRemain extends BaseAction<Payload, any> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const ret = await this.core.apis.GroupApi.getGroupRemainAtTimes(payload.group_id.toString());
|
||||
if (!ret.atInfo || ret.result !== 0) {
|
||||
throw new Error('atInfo not found');
|
||||
}
|
||||
const data = {
|
||||
can_at_all: ret.atInfo.canAtAll,
|
||||
remain_at_all_count_for_group: ret.atInfo.RemainAtAllCountForGroup,
|
||||
|
@@ -98,6 +98,7 @@ import { GoCQHTTPCheckUrlSafely } from './go-cqhttp/GoCQHTTPCheckUrlSafely';
|
||||
import { GoCQHTTPGetModelShow } from './go-cqhttp/GoCQHTTPGetModelShow';
|
||||
import { GoCQHTTPSetModelShow } from './go-cqhttp/GoCQHTTPSetModelShow';
|
||||
import { GoCQHTTPDeleteFriend } from './go-cqhttp/GoCQHTTPDeleteFriend';
|
||||
import { GetMiniAppArk } from "@/onebot/action/extends/GetMiniAppArk";
|
||||
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
@@ -210,6 +211,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
// new UploadForwardMsg(obContext, core),
|
||||
new GetGroupShutList(obContext, core),
|
||||
new GetGroupFileUrl(obContext, core),
|
||||
new GetMiniAppArk(obContext, core),
|
||||
];
|
||||
const actionMap = new Map();
|
||||
for (const action of actionHandlers) {
|
||||
|
@@ -11,9 +11,10 @@ import { decodeCQCode } from '@/onebot/cqcode';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { rawMsgWithSendMsg } from "@/core/packet/msg/converter";
|
||||
import { PacketMsg } from "@/core/packet/msg/message";
|
||||
import { rawMsgWithSendMsg } from "@/core/packet/message/converter";
|
||||
import { PacketMsg } from "@/core/packet/message/message";
|
||||
import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
|
||||
import { stringifyWithBigInt } from "@/common/helper";
|
||||
|
||||
export interface ReturnDataType {
|
||||
message_id: number;
|
||||
@@ -190,9 +191,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
time: Number(node.data.time) || Date.now(),
|
||||
msg: sendElements,
|
||||
};
|
||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 开始转换 ${JSON.stringify(packetMsgElements)}`);
|
||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 开始转换 ${stringifyWithBigInt(packetMsgElements)}`);
|
||||
const transformedMsg = this.core.apis.PacketApi.packetSession?.packer.packetConverter.rawMsgWithSendMsgToPacketMsg(packetMsgElements);
|
||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 转换为 ${JSON.stringify(transformedMsg)}`);
|
||||
logger.logDebug(`handleForwardedNodesPacket[SendRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
||||
packetMsg.push(transformedMsg!);
|
||||
} else if (node.data.id) {
|
||||
const id = node.data.id;
|
||||
@@ -202,13 +203,13 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
continue;
|
||||
}
|
||||
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(nodeMsg.Peer, [nodeMsg.MsgId])).msgList[0];
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 开始转换 ${JSON.stringify(msg)}`);
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 开始转换 ${stringifyWithBigInt(msg)}`);
|
||||
await this.core.apis.FileApi.downloadRawMsgMedia([msg]);
|
||||
const transformedMsg = this.core.apis.PacketApi.packetSession?.packer.packetConverter.rawMsgToPacketMsg(msg, msgPeer);
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${JSON.stringify(transformedMsg)}`);
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${stringifyWithBigInt(transformedMsg)}`);
|
||||
packetMsg.push(transformedMsg!);
|
||||
} else {
|
||||
logger.logDebug(`handleForwardedNodesPacket 跳过元素 ${JSON.stringify(node)}`);
|
||||
logger.logDebug(`handleForwardedNodesPacket 跳过元素 ${stringifyWithBigInt(node)}`);
|
||||
}
|
||||
}
|
||||
if (packetMsg.length === 0) {
|
||||
|
@@ -134,7 +134,8 @@ export enum ActionName {
|
||||
GetGuildProfile = 'get_guild_service_profile',
|
||||
|
||||
GetGroupIgnoredNotifies = 'get_group_ignored_notifies',
|
||||
|
||||
|
||||
SetGroupSign = "set_group_sign",
|
||||
GetMiniAppArk = "get_mini_app_ark",
|
||||
// UploadForwardMsg = "upload_forward_msg",
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ export class OneBotMsgApi {
|
||||
url: await this.core.apis.FileApi.getImageUrl(element),
|
||||
path: element.filePath,
|
||||
file_size: element.fileSize,
|
||||
file_unique: element.fileName
|
||||
file_unique: element.md5HexStr ?? element.fileName,
|
||||
},
|
||||
};
|
||||
} catch (e: any) {
|
||||
@@ -141,9 +141,9 @@ export class OneBotMsgApi {
|
||||
file: element.fileName,
|
||||
path: element.filePath,
|
||||
url: pathToFileURL(element.filePath).href,
|
||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileUuid,"." + element.fileName),
|
||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileUuid, "." + element.fileName),
|
||||
file_size: element.fileSize,
|
||||
file_unique: element.fileName,
|
||||
file_unique: element.fileMd5 ?? element.fileSha ?? element.fileName,
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -204,7 +204,7 @@ export class OneBotMsgApi {
|
||||
guildId: '',
|
||||
};
|
||||
if (!records || !element.replyMsgTime || !element.senderUidStr) {
|
||||
this.core.context.logger.logError.bind(this.core.context.logger)('获取不到引用的消息', element.replayMsgSeq);
|
||||
this.core.context.logger.logError.bind(this.core.context.logger)('似乎是旧版客户端,获取不到引用的消息', element.replayMsgSeq);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -218,11 +218,27 @@ export class OneBotMsgApi {
|
||||
if (records.peerUin === '284840486' || records.peerUin === '1094950020') {
|
||||
return createReplyData(records.msgId);
|
||||
}
|
||||
const replyMsg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeqV2(peer, element.replayMsgSeq, element.replyMsgTime, [element.senderUidStr]))
|
||||
.msgList.find(msg => msg.msgRandom === records.msgRandom);
|
||||
|
||||
let replyMsgList = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeqV2(peer, element.replayMsgSeq, element.replyMsgTime, [element.senderUidStr])).msgList;
|
||||
let replyMsg = replyMsgList.find(msg => msg.msgRandom === records.msgRandom);
|
||||
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
||||
this.core.context.logger.logError.bind(this.core.context.logger)('获取不到引用的消息', element.replayMsgSeq);
|
||||
// 我猜测可能是时间参数未对上 导致找不到引用消息 或者msgList 存在问题
|
||||
this.core.context.logger.logWarn.bind(this.core.context.logger)(
|
||||
'初次筛选消息失败,获取不到引用的消息 Seq:',
|
||||
element.replayMsgSeq,
|
||||
',消息长度:',
|
||||
replyMsgList.length
|
||||
);
|
||||
// 再次筛选
|
||||
replyMsgList = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeqV3(peer, element.replayMsgSeq, [element.senderUidStr])).msgList;
|
||||
replyMsg = replyMsgList.find(msg => msg.msgRandom === records.msgRandom);
|
||||
}
|
||||
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
||||
this.core.context.logger.logError.bind(this.core.context.logger)(
|
||||
'最终筛选结果,筛选消息失败,获取不到引用的消息 Seq: ',
|
||||
element.replayMsgSeq,
|
||||
',消息长度:',
|
||||
replyMsgList.length
|
||||
);
|
||||
return null;
|
||||
}
|
||||
return createReplyData(replyMsg.msgId);
|
||||
@@ -285,7 +301,7 @@ export class OneBotMsgApi {
|
||||
url: videoDownUrl ?? pathToFileURL(element.filePath).href,
|
||||
file_id: fileCode,
|
||||
file_size: element.fileSize,
|
||||
file_unique: element.fileName,
|
||||
file_unique: element.videoMd5 ?? element.thumbMd5 ?? element.fileName,
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -305,7 +321,7 @@ export class OneBotMsgApi {
|
||||
url: pathToFileURL(element.filePath).href,
|
||||
file_id: fileCode,
|
||||
file_size: element.fileSize,
|
||||
file_unique: element.fileName
|
||||
file_unique: element.fileUuid
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -626,13 +642,13 @@ export class OneBotMsgApi {
|
||||
[OB11MessageDataType.miniapp]: async () => undefined,
|
||||
|
||||
[OB11MessageDataType.contact]: async ({ data: { type = "qq", id } }, context) => {
|
||||
if(type === "qq"){
|
||||
if (type === "qq") {
|
||||
const arkJson = await this.core.apis.UserApi.getBuddyRecommendContactArkJson(id.toString(), '');
|
||||
return this.ob11ToRawConverters.json({
|
||||
data: { data: arkJson.arkMsg },
|
||||
type: OB11MessageDataType.json
|
||||
}, context);
|
||||
}else if(type === "group"){
|
||||
} else if (type === "group") {
|
||||
const arkJson = await this.core.apis.GroupApi.getGroupRecommendContactArkJson(id.toString());
|
||||
return this.ob11ToRawConverters.json({
|
||||
data: { data: arkJson.arkJson },
|
||||
|
@@ -119,11 +119,25 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
|
||||
async close() {
|
||||
this.isOpen = false;
|
||||
this.wsServer.close();
|
||||
this.wsServer.close((err) => {
|
||||
if (err) {
|
||||
this.logger.logError.bind(this.logger)('[OneBot] [WebSocket Server] Error closing server:', err.message);
|
||||
} else {
|
||||
this.logger.log.bind(this.logger)('[OneBot] [WebSocket Server] Server Closed');
|
||||
}
|
||||
|
||||
});
|
||||
if (this.heartbeatIntervalId) {
|
||||
clearInterval(this.heartbeatIntervalId);
|
||||
this.heartbeatIntervalId = null;
|
||||
}
|
||||
await this.wsClientsMutex.runExclusive(async () => {
|
||||
this.wsClients.forEach((wsClient) => {
|
||||
wsClient.close();
|
||||
});
|
||||
this.wsClients = [];
|
||||
this.wsClientWithEvent = [];
|
||||
});
|
||||
}
|
||||
|
||||
private registerHeartBeat() {
|
||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
undefined,
|
||||
SettingButton('V3.1.10', 'napcat-update-button', 'secondary'),
|
||||
SettingButton('V3.3.12', 'napcat-update-button', 'secondary'),
|
||||
),
|
||||
]),
|
||||
SettingList([
|
||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
void 0,
|
||||
SettingButton("V3.1.10", "napcat-update-button", "secondary")
|
||||
SettingButton("V3.3.20", "napcat-update-button", "secondary")
|
||||
)
|
||||
]),
|
||||
SettingList([
|
||||
|
Reference in New Issue
Block a user