Compare commits

..

13 Commits

Author SHA1 Message Date
手瓜一十雪
cd315b0e71 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2025-01-22 09:33:23 +08:00
手瓜一十雪
4d4d79e66f fix #727 2025-01-22 09:33:19 +08:00
手瓜一十雪
395ce97a78 Merge pull request #726 from Caulic/main
fix: 无法修改网络配置表单值
2025-01-22 09:16:53 +08:00
Caulic
e44e8423d0 fix: 无法修改网络配置表单值 2025-01-22 01:16:35 +08:00
手瓜一十雪
fa13a56697 Merge pull request #725 from clansty/feat/face_resultId
update face list
2025-01-21 22:45:25 +08:00
Clansty
6383164aec update face list 2025-01-21 22:42:37 +08:00
Mlikiowa
d9adfad1c0 release: v4.4.2 2025-01-21 14:15:28 +00:00
手瓜一十雪
901828f5a6 Merge pull request #724 from clansty/feat/face_resultId
为新的接龙表情提供 resultId 和 chainCount 返回
2025-01-21 22:14:18 +08:00
Clansty
2a4b0cbc09 force resultId to string 2025-01-21 22:10:52 +08:00
Clansty
c5434efd56 为新的接龙表情提供 resultId 和 chainCount 返回 2025-01-21 22:02:35 +08:00
手瓜一十雪
b73f283095 Merge pull request #717 from NapNeko/dependabot/npm_and_yarn/file-type-20.0.0
chore(deps-dev): bump file-type from 19.6.0 to 20.0.0
2025-01-21 21:55:45 +08:00
Mlikiowa
24ef54f01c release: v4.4.1 2025-01-21 13:46:31 +00:00
dependabot[bot]
9c4751794f chore(deps-dev): bump file-type from 19.6.0 to 20.0.0
Bumps [file-type](https://github.com/sindresorhus/file-type) from 19.6.0 to 20.0.0.
- [Release notes](https://github.com/sindresorhus/file-type/releases)
- [Commits](https://github.com/sindresorhus/file-type/compare/v19.6.0...v20.0.0)

---
updated-dependencies:
- dependency-name: file-type
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-20 08:59:49 +00:00
22 changed files with 312 additions and 113 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.4.0",
"version": "4.4.2",
"icon": "./logo.png",
"authors": [
{

View File

@@ -149,8 +149,10 @@
</t-select>
</t-form-item>
<div>
<component :is="resolveDynamicComponent(getComponent(newTab.type as ComponentKey))"
:config="newTab.data" />
<component
:is="resolveDynamicComponent(getComponent(newTab.type as ComponentKey))"
:config="newTab"
/>
</div>
</t-form>
</div>

View File

@@ -2,22 +2,22 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="URL">
<t-input v-model="config.url" />
<t-input v-model="props.config.data.url" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="报告自身消息">
<t-switch v-model="config.reportSelfMessage" />
<t-switch v-model="props.config.data.reportSelfMessage" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" />
<t-input v-model="props.config.data.token" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
</t-form>
</div>
@@ -34,14 +34,14 @@ const defaultConfig: HttpClientConfig = {
messagePostFormat: 'array',
reportSelfMessage: false,
token: '',
debug: false
debug: false,
};
const props = defineProps<{
config: HttpClientConfig;
config: { data: HttpClientConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -49,13 +49,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -2,28 +2,28 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="端口">
<t-input v-model.number="config.port" type="number" />
<t-input v-model.number="props.config.data.port" type="number" />
</t-form-item>
<t-form-item label="主机">
<t-input v-model="config.host" type="text" />
<t-input v-model="props.config.data.host" type="text" />
</t-form-item>
<t-form-item label="启用 CORS">
<t-switch v-model="config.enableCors" />
<t-switch v-model="props.config.data.enableCors" />
</t-form-item>
<t-form-item label="启用 WS">
<t-switch v-model="config.enableWebsocket" />
<t-switch v-model="props.config.data.enableWebsocket" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" type="text" />
<t-input v-model="props.config.data.token" type="text" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
</t-form>
</div>
@@ -42,14 +42,14 @@ const defaultConfig: HttpServerConfig = {
enableWebsocket: true,
messagePostFormat: 'array',
token: '',
debug: false
debug: false,
};
const props = defineProps<{
config: HttpServerConfig;
config: { data: HttpServerConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -57,13 +57,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -2,31 +2,31 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="端口">
<t-input v-model.number="config.port" type="number" />
<t-input v-model.number="props.config.data.port" type="number" />
</t-form-item>
<t-form-item label="主机">
<t-input v-model="config.host" type="text" />
<t-input v-model="props.config.data.host" type="text" />
</t-form-item>
<t-form-item label="报告自身消息">
<t-switch v-model="config.reportSelfMessage" />
<t-switch v-model="props.config.data.reportSelfMessage" />
</t-form-item>
<t-form-item label="启用 CORS">
<t-switch v-model="config.enableCors" />
<t-switch v-model="props.config.data.enableCors" />
</t-form-item>
<t-form-item label="启用 WS">
<t-switch v-model="config.enableWebsocket" />
<t-switch v-model="props.config.data.enableWebsocket" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" type="text" />
<t-input v-model="props.config.data.token" type="text" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
</t-form>
</div>
@@ -46,14 +46,14 @@ const defaultConfig: HttpSseServerConfig = {
messagePostFormat: 'array',
token: '',
debug: false,
reportSelfMessage: false
reportSelfMessage: false,
};
const props = defineProps<{
config: HttpSseServerConfig;
config: { data: HttpSseServerConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -61,13 +61,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -2,25 +2,25 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="URL">
<t-input v-model="config.url" />
<t-input v-model="props.config.data.url" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="报告自身消息">
<t-switch v-model="config.reportSelfMessage" />
<t-switch v-model="props.config.data.reportSelfMessage" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" />
<t-input v-model="props.config.data.token" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
<t-form-item label="心跳间隔">
<t-input v-model.number="config.heartInterval" type="number" />
<t-input v-model.number="props.config.data.heartInterval" type="number" />
</t-form-item>
</t-form>
</div>
@@ -39,14 +39,14 @@ const defaultConfig: WebsocketClientConfig = {
reconnectInterval: 5000,
token: '',
debug: false,
heartInterval: 30000
heartInterval: 30000,
};
const props = defineProps<{
config: WebsocketClientConfig;
config: { data: WebsocketClientConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -54,13 +54,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -2,31 +2,31 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="主机">
<t-input v-model="config.host" />
<t-input v-model="props.config.data.host" />
</t-form-item>
<t-form-item label="端口">
<t-input v-model.number="config.port" type="number" />
<t-input v-model.number="props.config.data.port" type="number" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="上报自身消息">
<t-switch v-model="config.reportSelfMessage" />
<t-switch v-model="props.config.data.reportSelfMessage" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" />
<t-input v-model="props.config.data.token" />
</t-form-item>
<t-form-item label="强制推送事件">
<t-switch v-model="config.enableForcePushEvent" />
<t-switch v-model="props.config.data.enableForcePushEvent" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
<t-form-item label="心跳间隔">
<t-input v-model.number="config.heartInterval" type="number" />
<t-input v-model.number="props.config.data.heartInterval" type="number" />
</t-form-item>
</t-form>
</div>
@@ -46,14 +46,14 @@ const defaultConfig: WebsocketServerConfig = {
token: '',
enableForcePushEvent: true,
debug: false,
heartInterval: 30000
heartInterval: 30000,
};
const props = defineProps<{
config: WebsocketServerConfig;
config: { data: WebsocketServerConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -61,13 +61,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.4.0",
"version": "4.4.2",
"scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
@@ -43,7 +43,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"fast-xml-parser": "^4.3.6",
"file-type": "^19.0.0",
"file-type": "^20.0.0",
"globals": "^15.12.0",
"image-size": "^1.1.1",
"typescript": "^5.3.3",

View File

@@ -1 +1 @@
export const napCatVersion = '4.4.0';
export const napCatVersion = '4.4.2';

View File

@@ -2406,6 +2406,193 @@
"AQLid": "211",
"QHide": "1",
"EMCode": "309"
},
{
"QSid": "424",
"QDes": "/续标识",
"IQLid": "424",
"AQLid": "424",
"EMCode": "10424",
"QHide": "0",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "52"
},
{
"QSid": "415",
"QDes": "/划龙舟",
"IQLid": "415",
"AQLid": "415",
"EMCode": "10415",
"QHide": "0",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "43"
},
{
"QSid": "416",
"QDes": "/中龙舟",
"IQLid": "416",
"AQLid": "416",
"EMCode": "10416",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "44"
},
{
"QSid": "417",
"QDes": "/大龙舟",
"IQLid": "417",
"AQLid": "417",
"EMCode": "10417",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "45"
},
{
"QSid": "425",
"QDes": "/求放过",
"IQLid": "425",
"AQLid": "425",
"EMCode": "10425",
"QHide": "0",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "53"
},
{
"QSid": "427",
"QDes": "/偷感",
"IQLid": "427",
"AQLid": "427",
"EMCode": "10427",
"QHide": "0",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "55"
},
{
"QSid": "426",
"QDes": "/玩火",
"IQLid": "426",
"AQLid": "426",
"EMCode": "10426",
"QHide": "0",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "54"
},
{
"QSid": "419",
"QDes": "/火车",
"IQLid": "419",
"AQLid": "419",
"EMCode": "10419",
"QHide": "0",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "47"
},
{
"QSid": "420",
"QDes": "/中火车",
"IQLid": "420",
"AQLid": "420",
"EMCode": "10420",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "48"
},
{
"QSid": "421",
"QDes": "/大火车",
"IQLid": "421",
"AQLid": "421",
"EMCode": "10421",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "49"
},
{
"QSid": "429",
"QDes": "/蛇年快乐",
"IQLid": "429",
"AQLid": "429",
"EMCode": "10429",
"QHide": "0",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "56"
},
{
"QSid": "430",
"QDes": "/蛇身",
"IQLid": "430",
"AQLid": "430",
"EMCode": "10430",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "57"
},
{
"QSid": "431",
"QDes": "/蛇尾",
"IQLid": "431",
"AQLid": "431",
"EMCode": "10431",
"QHide": "1",
"AniStickerType": 3,
"AniStickerPackId": "1",
"AniStickerId": "56"
},
{
"QSid": "428",
"QDes": "/收到",
"IQLid": "428",
"AQLid": "428",
"EMCode": "10428",
"QHide": "0",
"AniStickerType": 0,
"AniStickerPackId": "0",
"AniStickerId": "0"
},
{
"QSid": "422",
"QDes": "/粽于等到你",
"IQLid": "422",
"AQLid": "422",
"EMCode": "10422",
"QHide": "1",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "50"
},
{
"QSid": "423",
"QDes": "/复兴号",
"IQLid": "423",
"AQLid": "423",
"EMCode": "10423",
"QHide": "1",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "51"
},
{
"QSid": "432",
"QDes": "/灵蛇献瑞",
"IQLid": "432",
"AQLid": "432",
"EMCode": "10432",
"QHide": "1",
"AniStickerType": 1,
"AniStickerPackId": "1",
"AniStickerId": "59"
}
],
"emoji": [

View File

@@ -160,10 +160,12 @@ export class PacketMsgReplyElement extends IPacketMsgElement<SendReplyElement> {
export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
faceId: number;
isLargeFace: boolean;
resultId?: string;
constructor(element: SendFaceElement) {
super(element);
this.faceId = element.faceElement.faceIndex;
this.resultId = element.faceElement.resultId;
this.isLargeFace = element.faceElement.faceType === FaceType.AniSticke;
}
@@ -176,10 +178,10 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
aniStickerPackId: "1",
aniStickerId: "8",
faceId: this.faceId,
field4: 1,
field6: "",
sourceType: 1,
resultId: this.resultId,
preview: "",
field9: 1
randomType: 1
}),
businessType: 1
}

View File

@@ -342,11 +342,11 @@ export const QBigFaceExtra = {
AniStickerPackId: ProtoField(1, ScalarType.STRING, true),
AniStickerId: ProtoField(2, ScalarType.STRING, true),
faceId: ProtoField(3, ScalarType.INT32, true),
Field4: ProtoField(4, ScalarType.INT32, true),
sourceType: ProtoField(4, ScalarType.INT32, true),
AniStickerType: ProtoField(5, ScalarType.INT32, true),
field6: ProtoField(6, ScalarType.STRING, true),
resultId: ProtoField(6, ScalarType.STRING, true),
preview: ProtoField(7, ScalarType.STRING, true),
field9: ProtoField(9, ScalarType.INT32, true),
randomType: ProtoField(9, ScalarType.INT32, true),
};
export const QSmallFaceExtra = {

View File

@@ -40,6 +40,7 @@ export interface FaceElement {
resultId?: string;
surpriseId?: string;
randomType?: number;
chainCount?: number;
}
export interface GrayTipRovokeElement {
operatorRole: string;
@@ -348,4 +349,4 @@ export type SendShareLocationElement = SendElementBase<ElementType.SHARELOCATION
export type SendMessageElement = SendTextElement | SendPttElement |
SendPicElement | SendReplyElement | SendFaceElement | SendMarketFaceElement | SendFileElement |
SendVideoElement | SendArkElement | SendMarkdownElement | SendShareLocationElement;
SendVideoElement | SendArkElement | SendMarkdownElement | SendShareLocationElement;

View File

@@ -190,7 +190,10 @@ export class OneBotMsgApi {
return {
type: OB11MessageDataType.face,
data: {
id: element.faceIndex.toString()
id: element.faceIndex.toString(),
raw: element,
resultId: element.resultId,
chainCount: element.chainCount,
},
};
}
@@ -464,7 +467,7 @@ export class OneBotMsgApi {
undefined;
},
[OB11MessageDataType.face]: async ({ data: { id } }) => {
[OB11MessageDataType.face]: async ({ data: { id, resultId, chainCount } }) => {
const parsedFaceId = +id;
// 从face_config.json中获取表情名称
const sysFaces = faceConfig.sysface;
@@ -491,6 +494,8 @@ export class OneBotMsgApi {
stickerType: face.AniStickerType,
packId: face.AniStickerPackId,
sourceType: 1,
resultId: resultId?.toString(),
chainCount,
},
};
},

View File

@@ -16,12 +16,12 @@ import {
} from '@/core';
import { OB11ConfigLoader } from '@/onebot/config';
import {
OB11ActiveHttpAdapter,
OB11ActiveWebSocketAdapter,
OB11HttpClientAdapter,
OB11WebSocketClientAdapter,
OB11NetworkManager,
OB11NetworkReloadType,
OB11PassiveHttpAdapter,
OB11PassiveWebSocketAdapter,
OB11HttpServerAdapter,
OB11WebSocketServerAdapter,
} from '@/onebot/network';
import { NapCatPathWrapper } from '@/common/path';
import {
@@ -51,7 +51,7 @@ import {
import { OB11Message } from './types';
import { OB11PluginAdapter } from './network/plugin';
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
import { OB11ActiveHttpSSEAdapter } from './network/active-http-sse';
import { OB11HttpSSEServerAdapter } from './network/http-server-sse';
//OneBot实现类
export class NapCatOneBot11Adapter {
@@ -123,28 +123,28 @@ export class NapCatOneBot11Adapter {
for (const key of ob11Config.network.httpServers) {
if (key.enable) {
this.networkManager.registerAdapter(
new OB11PassiveHttpAdapter(key.name, key, this.core, this, this.actions)
new OB11HttpServerAdapter(key.name, key, this.core, this, this.actions)
);
}
}
for (const key of ob11Config.network.httpSseServers) {
if (key.enable) {
this.networkManager.registerAdapter(
new OB11ActiveHttpSSEAdapter(key.name, key, this.core, this, this.actions)
new OB11HttpSSEServerAdapter(key.name, key, this.core, this, this.actions)
);
}
}
for (const key of ob11Config.network.httpClients) {
if (key.enable) {
this.networkManager.registerAdapter(
new OB11ActiveHttpAdapter(key.name, key, this.core, this, this.actions)
new OB11HttpClientAdapter(key.name, key, this.core, this, this.actions)
);
}
}
for (const key of ob11Config.network.websocketServers) {
if (key.enable) {
this.networkManager.registerAdapter(
new OB11PassiveWebSocketAdapter(
new OB11WebSocketServerAdapter(
key.name,
key,
this.core,
@@ -157,7 +157,7 @@ export class NapCatOneBot11Adapter {
for (const key of ob11Config.network.websocketClients) {
if (key.enable) {
this.networkManager.registerAdapter(
new OB11ActiveWebSocketAdapter(
new OB11WebSocketClientAdapter(
key.name,
key,
this.core,
@@ -206,11 +206,11 @@ export class NapCatOneBot11Adapter {
this.context.logger.log(`[Notice] [OneBot11] 配置变更前:\n${prevLog}`);
this.context.logger.log(`[Notice] [OneBot11] 配置变更后:\n${newLog}`);
await this.handleConfigChange(prev.network.httpServers, now.network.httpServers, OB11PassiveHttpAdapter);
await this.handleConfigChange(prev.network.httpClients, now.network.httpClients, OB11ActiveHttpAdapter);
await this.handleConfigChange(prev.network.httpSseServers, now.network.httpSseServers, OB11ActiveHttpSSEAdapter);
await this.handleConfigChange(prev.network.websocketServers, now.network.websocketServers, OB11PassiveWebSocketAdapter);
await this.handleConfigChange(prev.network.websocketClients, now.network.websocketClients, OB11ActiveWebSocketAdapter);
await this.handleConfigChange(prev.network.httpServers, now.network.httpServers, OB11HttpServerAdapter);
await this.handleConfigChange(prev.network.httpClients, now.network.httpClients, OB11HttpClientAdapter);
await this.handleConfigChange(prev.network.httpSseServers, now.network.httpSseServers, OB11HttpSSEServerAdapter);
await this.handleConfigChange(prev.network.websocketServers, now.network.websocketServers, OB11WebSocketServerAdapter);
await this.handleConfigChange(prev.network.websocketClients, now.network.websocketClients, OB11WebSocketClientAdapter);
}
private async handleConfigChange<CT extends NetworkAdapterConfig>(

View File

@@ -8,7 +8,7 @@ import { HttpClientConfig } from '@/onebot/config/config';
import { ActionMap } from '@/onebot/action';
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11ActiveHttpAdapter extends IOB11NetworkAdapter<HttpClientConfig> {
export class OB11HttpClientAdapter extends IOB11NetworkAdapter<HttpClientConfig> {
constructor(
name: string, config: HttpClientConfig, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap
) {

View File

@@ -1,9 +1,9 @@
import { OB11EmitEventContent } from './index';
import { Request, Response } from 'express';
import { OB11Response } from '@/onebot/action/OneBotAction';
import { OB11PassiveHttpAdapter } from './passive-http';
import { OB11HttpServerAdapter } from './http-server';
export class OB11ActiveHttpSSEAdapter extends OB11PassiveHttpAdapter {
export class OB11HttpSSEServerAdapter extends OB11HttpServerAdapter {
private sseClients: Response[] = [];
async handleRequest(req: Request, res: Response): Promise<any> {

View File

@@ -9,7 +9,7 @@ import { HttpServerConfig } from '@/onebot/config/config';
import { NapCatOneBot11Adapter } from "@/onebot";
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11PassiveHttpAdapter extends IOB11NetworkAdapter<HttpServerConfig> {
export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig> {
private app: Express | undefined;
private server: http.Server | undefined;
@@ -98,7 +98,7 @@ export class OB11PassiveHttpAdapter extends IOB11NetworkAdapter<HttpServerConfig
const action = this.actions.get(actionName as any);
if (action) {
try {
const result = await action.handle(payload, this.name);
const result = await action.handle(payload, this.name, this.config);
return res.json(result);
} catch (error: any) {
return res.json(OB11Response.error(error?.stack?.toString() || error?.message || 'Error Handle', 200));

View File

@@ -101,7 +101,7 @@ export class OB11NetworkManager {
}
}
export * from './active-http';
export * from './active-websocket';
export * from './passive-http';
export * from './passive-websocket';
export * from './http-client';
export * from './websocket-client';
export * from './http-server';
export * from './websocket-server';

View File

@@ -10,7 +10,7 @@ import { WebsocketClientConfig } from '@/onebot/config/config';
import { NapCatOneBot11Adapter } from "@/onebot";
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11ActiveWebSocketAdapter extends IOB11NetworkAdapter<WebsocketClientConfig> {
export class OB11WebSocketClientAdapter extends IOB11NetworkAdapter<WebsocketClientConfig> {
private connection: WebSocket | null = null;
private heartbeatRef: NodeJS.Timeout | null = null;
@@ -143,7 +143,7 @@ export class OB11ActiveWebSocketAdapter extends IOB11NetworkAdapter<WebsocketCli
this.checkStateAndReply<any>(OB11Response.error('不支持的Api ' + receiveData.action, 1404, echo));
return;
}
const retdata = await action.websocketHandle(receiveData.params, echo ?? '', this.name);
const retdata = await action.websocketHandle(receiveData.params, echo ?? '', this.name, this.config);
this.checkStateAndReply<any>({ ...retdata });
}
async reload(newConfig: WebsocketClientConfig) {

View File

@@ -13,7 +13,7 @@ import { WebsocketServerConfig } from '@/onebot/config/config';
import { NapCatOneBot11Adapter } from "@/onebot";
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11PassiveWebSocketAdapter extends IOB11NetworkAdapter<WebsocketServerConfig> {
export class OB11WebSocketServerAdapter extends IOB11NetworkAdapter<WebsocketServerConfig> {
wsServer: WebSocketServer;
wsClients: WebSocket[] = [];
wsClientsMutex = new Mutex();
@@ -176,7 +176,7 @@ export class OB11PassiveWebSocketAdapter extends IOB11NetworkAdapter<WebsocketSe
this.checkStateAndReply<any>(OB11Response.error('不支持的API ' + receiveData.action, 1404, echo), wsClient);
return;
}
const retdata = await action.websocketHandle(receiveData.params, echo ?? '', this.name);
const retdata = await action.websocketHandle(receiveData.params, echo ?? '', this.name, this.config);
this.checkStateAndReply<any>({ ...retdata }, wsClient);
}

View File

@@ -164,6 +164,8 @@ export interface OB11MessageFace {
type: OB11MessageDataType.face;
data: {
id: string;
resultId?: string;
chainCount?: number;
};
}
@@ -276,4 +278,4 @@ export interface OB11PostContext {
message_type?: 'private' | 'group';
user_id?: string;
group_id?: string;
}
}