koishi-plugin-chatluna-character 0.0.39 → 0.0.41
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/plugins/filter.js
CHANGED
|
@@ -31,16 +31,15 @@ async function apply(ctx, config) {
|
|
|
31
31
|
let { messageCount, messageSendProbability } = info;
|
|
32
32
|
logger.debug(`messageCount: ${messageCount}, messageSendProbability: ${messageSendProbability}. content: ${JSON.stringify(message)}`);
|
|
33
33
|
// 检查是否在名单里面
|
|
34
|
-
if (
|
|
35
|
-
copyOfConfig.whiteListDisableChatLuna.includes(guildId))
|
|
36
|
-
!copyOfConfig.disableChatLuna) {
|
|
34
|
+
if (copyOfConfig.disableChatLuna &&
|
|
35
|
+
copyOfConfig.whiteListDisableChatLuna.includes(guildId)) {
|
|
37
36
|
// check to last five message is send for bot
|
|
38
37
|
const selfId = session.bot.userId ?? session.bot.selfId ?? '0';
|
|
39
38
|
const guildMessages = ctx.chatluna_character.getMessages(guildId);
|
|
39
|
+
let maxRecentMessage = 0;
|
|
40
40
|
if (guildMessages == null || guildMessages.length === 0) {
|
|
41
|
-
|
|
41
|
+
maxRecentMessage = 6;
|
|
42
42
|
}
|
|
43
|
-
let maxRecentMessage = 0;
|
|
44
43
|
while (maxRecentMessage < 5) {
|
|
45
44
|
const currentMessage = guildMessages[guildMessages?.length - 1 - maxRecentMessage];
|
|
46
45
|
if (currentMessage == null) {
|
|
@@ -60,25 +59,23 @@ async function apply(ctx, config) {
|
|
|
60
59
|
if (needMute) {
|
|
61
60
|
logger.debug(`mute content: ${message.content}`);
|
|
62
61
|
service.mute(session, config.muteTime);
|
|
63
|
-
return;
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
64
|
+
const isMute = service.isMute(session);
|
|
69
65
|
// 保底必出
|
|
70
|
-
if (messageCount > maxMessages ||
|
|
66
|
+
if ((messageCount > maxMessages ||
|
|
71
67
|
messageSendProbability > 1 ||
|
|
72
68
|
session.stripped.appel ||
|
|
73
69
|
(config.isNickname &&
|
|
74
|
-
currentPreset.nick_name.some((value) => message.content.startsWith(value))))
|
|
70
|
+
currentPreset.nick_name.some((value) => message.content.startsWith(value)))) &&
|
|
71
|
+
!isMute) {
|
|
75
72
|
info.messageCount = 0;
|
|
76
73
|
info.messageSendProbability = 1;
|
|
77
74
|
exports.groupInfos[session.guildId] = info;
|
|
78
75
|
return true;
|
|
79
76
|
}
|
|
80
77
|
// 按照概率出
|
|
81
|
-
if (Math.random() > messageSendProbability) {
|
|
78
|
+
if (Math.random() > messageSendProbability && !isMute) {
|
|
82
79
|
info.messageCount = 0;
|
|
83
80
|
info.messageSendProbability = 1;
|
|
84
81
|
exports.groupInfos[session.guildId] = info;
|
|
@@ -10,17 +10,16 @@ function apply(ctx, config) {
|
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
// 检查是否在名单里面
|
|
13
|
-
if (
|
|
14
|
-
config.whiteListDisableChatLuna
|
|
15
|
-
!config.disableChatLuna) {
|
|
13
|
+
if (config.disableChatLuna &&
|
|
14
|
+
config.whiteListDisableChatLuna?.includes(guildId)) {
|
|
16
15
|
// check to last five message is send for bot
|
|
17
16
|
const selfId = session.bot.userId ?? session.bot.selfId ?? '0';
|
|
18
17
|
const guildMessages = ctx.chatluna_character.getMessages(guildId);
|
|
19
18
|
if (guildMessages == null || guildMessages.length === 0) {
|
|
20
|
-
return
|
|
19
|
+
return true;
|
|
21
20
|
}
|
|
22
21
|
let maxRecentMessage = 0;
|
|
23
|
-
while (maxRecentMessage <
|
|
22
|
+
while (maxRecentMessage < 3) {
|
|
24
23
|
const currentMessage = guildMessages[guildMessages?.length - 1 - maxRecentMessage];
|
|
25
24
|
if (currentMessage == null) {
|
|
26
25
|
return false;
|
|
@@ -31,7 +30,7 @@ function apply(ctx, config) {
|
|
|
31
30
|
maxRecentMessage++;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
return
|
|
33
|
+
return config.disableChatLuna;
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
exports.apply = apply;
|
package/lib/service/message.js
CHANGED
|
@@ -197,10 +197,7 @@ function mapElementToString(session, content, elements) {
|
|
|
197
197
|
for (const element of elements) {
|
|
198
198
|
if (element.type === 'text') {
|
|
199
199
|
const content = element.attrs.content;
|
|
200
|
-
if (content.trimEnd().length
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
200
|
+
if (content.trimEnd().length > 0) {
|
|
204
201
|
filteredBuffer.push(content);
|
|
205
202
|
}
|
|
206
203
|
}
|
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.41",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"koishi": "^4.16.7",
|
|
54
|
-
"koishi-plugin-chatluna": "^1.0.0-beta.
|
|
54
|
+
"koishi-plugin-chatluna": "^1.0.0-beta.42"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0.0"
|