koishi-plugin-chatluna-character 0.0.43 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +2 -2
- package/lib/plugins/chat.js +6 -4
- package/lib/plugins/commands.js +2 -1
- package/lib/plugins/config.js +2 -1
- package/lib/plugins/filter.js +2 -2
- package/lib/plugins/interception.js +2 -1
- package/lib/preset.js +2 -2
- package/package.json +4 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.name = exports.Config = exports.inject = void 0;
|
|
4
|
-
exports.apply = apply;
|
|
3
|
+
exports.name = exports.Config = exports.inject = exports.apply = void 0;
|
|
5
4
|
/* eslint-disable max-len */
|
|
6
5
|
const koishi_1 = require("koishi");
|
|
7
6
|
const plugin_1 = require("./plugin");
|
|
@@ -43,6 +42,7 @@ function apply(ctx, config) {
|
|
|
43
42
|
disposables.forEach((disposable) => disposable());
|
|
44
43
|
});
|
|
45
44
|
}
|
|
45
|
+
exports.apply = apply;
|
|
46
46
|
exports.inject = {
|
|
47
47
|
required: ['chatluna', 'cache'],
|
|
48
48
|
optional: ['chatluna_character', 'vits']
|
package/lib/plugins/chat.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apply =
|
|
3
|
+
exports.apply = apply;
|
|
4
4
|
const messages_1 = require("@langchain/core/messages");
|
|
5
5
|
const koishi_1 = require("koishi");
|
|
6
6
|
const count_tokens_1 = require("koishi-plugin-chatluna/lib/llm-core/utils/count_tokens");
|
|
@@ -101,7 +101,8 @@ async function apply(ctx, config) {
|
|
|
101
101
|
isEmoticonStatement(text)) {
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
|
-
if (config.splitVoice !== true
|
|
104
|
+
if (config.splitVoice !== true &&
|
|
105
|
+
parsedResponse.messageType === 'voice') {
|
|
105
106
|
maxTime =
|
|
106
107
|
parsedResponse.rawMessage.length * copyOfConfig.typingTime +
|
|
107
108
|
100;
|
|
@@ -116,11 +117,13 @@ async function apply(ctx, config) {
|
|
|
116
117
|
await session.send(elements);
|
|
117
118
|
break;
|
|
118
119
|
case 'voice':
|
|
119
|
-
await (0, koishi_1.sleep)(random.int(maxTime / 4, maxTime / 2));
|
|
120
120
|
await session.send(await ctx.vits.say({
|
|
121
121
|
input: text
|
|
122
122
|
}));
|
|
123
123
|
break;
|
|
124
|
+
default:
|
|
125
|
+
await session.send(elements);
|
|
126
|
+
break;
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
catch (e) {
|
|
@@ -138,7 +141,6 @@ async function apply(ctx, config) {
|
|
|
138
141
|
await service.broadcastOnBot(session, parsedResponse.elements.flat());
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
|
-
exports.apply = apply;
|
|
142
144
|
function isEmoticonStatement(text) {
|
|
143
145
|
const regex = /^[\p{P}\p{S}\p{Z}\p{M}\p{N}\p{L}\s]*\p{So}[\p{P}\p{S}\p{Z}\p{M}\p{N}\p{L}\s]*$/u;
|
|
144
146
|
return regex.test(text);
|
package/lib/plugins/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apply =
|
|
3
|
+
exports.apply = void 0;
|
|
4
4
|
const filter_1 = require("./filter");
|
|
5
5
|
function apply(ctx, config) {
|
|
6
6
|
ctx.command('chatluna.character', '角色扮演相关命令');
|
|
@@ -22,3 +22,4 @@ function apply(ctx, config) {
|
|
|
22
22
|
return `已清除群组 ${groupId} 的聊天记录`;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
exports.apply = apply;
|
package/lib/plugins/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apply =
|
|
3
|
+
exports.apply = void 0;
|
|
4
4
|
const koishi_1 = require("koishi");
|
|
5
5
|
const types_1 = require("koishi-plugin-chatluna/lib/llm-core/platform/types");
|
|
6
6
|
async function apply(ctx, config) {
|
|
@@ -12,6 +12,7 @@ async function apply(ctx, config) {
|
|
|
12
12
|
});
|
|
13
13
|
ctx.schema.set('model', koishi_1.Schema.union(await getModelNames(ctx.chatluna.platform)));
|
|
14
14
|
}
|
|
15
|
+
exports.apply = apply;
|
|
15
16
|
async function getModelNames(service) {
|
|
16
17
|
return service.getAllModels(types_1.ModelType.llm).map((m) => koishi_1.Schema.const(m));
|
|
17
18
|
}
|
package/lib/plugins/filter.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupInfos = void 0;
|
|
4
|
-
exports.apply = apply;
|
|
3
|
+
exports.apply = exports.groupInfos = void 0;
|
|
5
4
|
exports.groupInfos = {};
|
|
6
5
|
async function apply(ctx, config) {
|
|
7
6
|
const maxMessages = config.messageInterval;
|
|
@@ -91,3 +90,4 @@ async function apply(ctx, config) {
|
|
|
91
90
|
return false;
|
|
92
91
|
});
|
|
93
92
|
}
|
|
93
|
+
exports.apply = apply;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apply =
|
|
3
|
+
exports.apply = void 0;
|
|
4
4
|
function apply(ctx, config) {
|
|
5
5
|
ctx.on('chatluna/before-check-sender', async (session) => {
|
|
6
6
|
const guildId = session.guildId;
|
|
@@ -33,3 +33,4 @@ function apply(ctx, config) {
|
|
|
33
33
|
return config.disableChatLuna;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
exports.apply = apply;
|
package/lib/preset.js
CHANGED
|
@@ -3,8 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Preset = void 0;
|
|
7
|
-
exports.loadPreset = loadPreset;
|
|
6
|
+
exports.loadPreset = exports.Preset = void 0;
|
|
8
7
|
const prompts_1 = require("@langchain/core/prompts");
|
|
9
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
9
|
const js_yaml_1 = require("js-yaml");
|
|
@@ -122,3 +121,4 @@ function loadPreset(text) {
|
|
|
122
121
|
mute_keyword: rawPreset.mute_keyword ?? []
|
|
123
122
|
};
|
|
124
123
|
}
|
|
124
|
+
exports.loadPreset = loadPreset;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-character",
|
|
3
3
|
"description": "Let the large language model play a role, disguise as a group friend",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.44",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
"service": {
|
|
72
72
|
"required": [
|
|
73
73
|
"chatluna"
|
|
74
|
+
],
|
|
75
|
+
"optional": [
|
|
76
|
+
"vits"
|
|
74
77
|
]
|
|
75
78
|
}
|
|
76
79
|
}
|