From 57ab9c611aff10f9b56d286df93536f7e390b859 Mon Sep 17 00:00:00 2001 From: Jerryplusy Date: Mon, 29 Sep 2025 16:39:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config/configControl.js | 2 +- lib/core/meme.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/core/meme.js diff --git a/lib/config/configControl.js b/lib/config/configControl.js index 8027112..a7b8788 100644 --- a/lib/config/configControl.js +++ b/lib/config/configControl.js @@ -70,7 +70,7 @@ async function init() { } } if (!Array.isArray(configCache)) { - configCache = fc.mergeConfig(configCache, defaultConfig); + configCache = fc.mergeConfig(configCache, configCache.config || {}); } if (configCache.debug) { logger.info('[crystelf-plugin] 配置模块初始化成功..'); diff --git a/lib/core/meme.js b/lib/core/meme.js new file mode 100644 index 0000000..375c27c --- /dev/null +++ b/lib/core/meme.js @@ -0,0 +1,14 @@ +import ConfigControl from '../config/configControl.js'; +import axios from 'axios'; + +const Meme = { + async getMeme(character, status) { + const coreConfig = await ConfigControl.get()?.coreConfig; + const coreUrl = coreConfig?.coreUrl; + const token = coreConfig?.token; + //logger.info(`${coreUrl}/api/meme`); + return `${coreUrl}/api/meme?token=${token}?character=${character}&status=${status}`; + }, +}; + +export default Meme; From 9c496f4e06d7ad51e8a41426ccaa17143943d19f Mon Sep 17 00:00:00 2001 From: Jerryplusy Date: Mon, 29 Sep 2025 18:31:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.json | 3 ++- config/feeds.json | 8 +------- lib/yunzai/group.js | 16 ++++++++++++++++ lib/yunzai/message.js | 16 ++++++++++++++++ lib/yunzai/self.js | 16 ++++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 lib/yunzai/group.js create mode 100644 lib/yunzai/message.js create mode 100644 lib/yunzai/self.js diff --git a/config/config.json b/config/config.json index 6a44b89..ec6a13e 100644 --- a/config/config.json +++ b/config/config.json @@ -1,5 +1,6 @@ { "debug": true, "core": true, - "maxFeed": 10 + "maxFeed": 10, + "adapter": "lgr" } diff --git a/config/feeds.json b/config/feeds.json index 3eb5adb..fe51488 100644 --- a/config/feeds.json +++ b/config/feeds.json @@ -1,7 +1 @@ -[ - { - "url": "", - "targetGroups": [114,154], - "screenshot": true - } -] +[] diff --git a/lib/yunzai/group.js b/lib/yunzai/group.js new file mode 100644 index 0000000..5a96950 --- /dev/null +++ b/lib/yunzai/group.js @@ -0,0 +1,16 @@ +import ConfigControl from '../config/configControl.js'; + +class NapcatGroup {} +class LgrGroup {} + +async function getGroupAdapter() { + const adapter = (await ConfigControl.get('config'))?.adapter; + if (!adapter || adapter === 'nc' || adapter === 'napcat') { + return new NapcatGroup(); + } else if (adapter === 'lgr' || adapter === 'lagrange') { + return new LgrGroup(); + } + return new NapcatGroup(); +} + +export default await getGroupAdapter(); diff --git a/lib/yunzai/message.js b/lib/yunzai/message.js new file mode 100644 index 0000000..798e1dd --- /dev/null +++ b/lib/yunzai/message.js @@ -0,0 +1,16 @@ +import ConfigControl from '../config/configControl.js'; + +class NapcatMessage {} +class LgrMessage {} + +async function getMessageAdapter() { + const adapter = (await ConfigControl.get('config'))?.adapter; + if (!adapter || adapter === 'nc' || adapter === 'napcat') { + return new NapcatMessage(); + } else if (adapter === 'lgr' || adapter === 'lagrange') { + return new LgrMessage(); + } + return new NapcatMessage(); +} + +export default await getMessageAdapter(); diff --git a/lib/yunzai/self.js b/lib/yunzai/self.js new file mode 100644 index 0000000..8cca86a --- /dev/null +++ b/lib/yunzai/self.js @@ -0,0 +1,16 @@ +import ConfigControl from '../config/configControl.js'; + +class NapcatSelf {} +class LgrSelf {} + +async function getSelfAdapter() { + const adapter = (await ConfigControl.get('config'))?.adapter; + if (!adapter || adapter === 'nc' || adapter === 'napcat') { + return new NapcatSelf(); + } else if (adapter === 'lgr' || adapter === 'lagrange') { + return new LgrSelf(); + } + return new NapcatSelf(); +} + +export default await getSelfAdapter();