Compare commits

..

7 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
17 changed files with 291 additions and 102 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "4.4.1", "version": "4.4.2",
"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",

View File

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

View File

@@ -2406,6 +2406,193 @@
"AQLid": "211", "AQLid": "211",
"QHide": "1", "QHide": "1",
"EMCode": "309" "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": [ "emoji": [

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
import { OB11EmitEventContent } from './index'; import { OB11EmitEventContent } from './index';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { OB11Response } from '@/onebot/action/OneBotAction'; 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[] = []; private sseClients: Response[] = [];
async handleRequest(req: Request, res: Response): Promise<any> { 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 { NapCatOneBot11Adapter } from "@/onebot";
import { IOB11NetworkAdapter } from "@/onebot/network/adapter"; import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11PassiveHttpAdapter extends IOB11NetworkAdapter<HttpServerConfig> { export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig> {
private app: Express | undefined; private app: Express | undefined;
private server: http.Server | undefined; private server: http.Server | undefined;
@@ -98,7 +98,7 @@ export class OB11PassiveHttpAdapter extends IOB11NetworkAdapter<HttpServerConfig
const action = this.actions.get(actionName as any); const action = this.actions.get(actionName as any);
if (action) { if (action) {
try { try {
const result = await action.handle(payload, this.name); const result = await action.handle(payload, this.name, this.config);
return res.json(result); return res.json(result);
} catch (error: any) { } catch (error: any) {
return res.json(OB11Response.error(error?.stack?.toString() || error?.message || 'Error Handle', 200)); 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 './http-client';
export * from './active-websocket'; export * from './websocket-client';
export * from './passive-http'; export * from './http-server';
export * from './passive-websocket'; export * from './websocket-server';

View File

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

View File

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