koishi-plugin-chatluna-toolbox 0.0.6 → 0.0.8
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 +500 -134
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
BasicSettingsSchema: () => BasicSettingsSchema,
|
|
23
24
|
Config: () => ConfigSchema,
|
|
24
25
|
ConfigSchema: () => ConfigSchema,
|
|
25
26
|
DEFAULT_GROUP_INFO_ITEMS: () => DEFAULT_GROUP_INFO_ITEMS,
|
|
@@ -34,9 +35,11 @@ __export(index_exports, {
|
|
|
34
35
|
createCharacterTempXmlRuntime: () => createCharacterTempXmlRuntime,
|
|
35
36
|
createDeleteMessageTool: () => createDeleteMessageTool,
|
|
36
37
|
createGroupInfoProvider: () => createGroupInfoProvider,
|
|
38
|
+
createGroupShutListProvider: () => createGroupShutListProvider,
|
|
37
39
|
createLogger: () => createLogger,
|
|
38
40
|
createPokeTool: () => createPokeTool,
|
|
39
41
|
createRandomProvider: () => createRandomProvider,
|
|
42
|
+
createSetGroupBanTool: () => createSetGroupBanTool,
|
|
40
43
|
createSetGroupCardTool: () => createSetGroupCardTool,
|
|
41
44
|
createSetMsgEmojiTool: () => createSetMsgEmojiTool,
|
|
42
45
|
createSetProfileTool: () => createSetProfileTool,
|
|
@@ -52,33 +55,106 @@ __export(index_exports, {
|
|
|
52
55
|
registerXmlTools: () => registerXmlTools,
|
|
53
56
|
resolveOneBotProtocol: () => resolveOneBotProtocol,
|
|
54
57
|
sendDeleteMessage: () => sendDeleteMessage,
|
|
58
|
+
sendGroupBan: () => sendGroupBan,
|
|
55
59
|
sendMsgEmoji: () => sendMsgEmoji,
|
|
56
60
|
sendPoke: () => sendPoke
|
|
57
61
|
});
|
|
58
62
|
module.exports = __toCommonJS(index_exports);
|
|
59
63
|
|
|
60
64
|
// src/schema/index.ts
|
|
61
|
-
var
|
|
65
|
+
var import_koishi5 = require("koishi");
|
|
62
66
|
|
|
63
|
-
// src/schema/
|
|
67
|
+
// src/schema/basic-settings.ts
|
|
64
68
|
var import_koishi = require("koishi");
|
|
65
|
-
var
|
|
69
|
+
var BasicSettingsSchema = import_koishi.Schema.object({
|
|
66
70
|
enableNapCatProtocol: import_koishi.Schema.boolean().default(true).description("\u542F\u7528 NapCat OneBot \u534F\u8BAE\uFF08\u4E0E LLBot \u4E8C\u9009\u4E00\uFF09"),
|
|
67
|
-
enableLlbotProtocol: import_koishi.Schema.boolean().default(false).description("\u542F\u7528 LLBot OneBot \u534F\u8BAE\uFF08\u4E0E NapCat \u4E8C\u9009\u4E00\uFF09")
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
enableLlbotProtocol: import_koishi.Schema.boolean().default(false).description("\u542F\u7528 LLBot OneBot \u534F\u8BAE\uFF08\u4E0E NapCat \u4E8C\u9009\u4E00\uFF09")
|
|
72
|
+
}).description("\u57FA\u7840\u8BBE\u7F6E");
|
|
73
|
+
|
|
74
|
+
// src/schema/native-tools.ts
|
|
75
|
+
var import_koishi2 = require("koishi");
|
|
76
|
+
|
|
77
|
+
// src/features/native-tools/defaults.ts
|
|
78
|
+
var DEFAULT_POKE_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u7528\u6237\u6267\u884C\u6233\u4E00\u6233\u3002";
|
|
79
|
+
var DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION = "\u4FEE\u6539\u81EA\u5DF1\u7684 QQ \u8D44\u6599\uFF0C\u53EF\u8BBE\u7F6E\u6635\u79F0\u3001\u7B7E\u540D\u548C\u6027\u522B\u3002";
|
|
80
|
+
var DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION = "\u4FEE\u6539\u7FA4\u6210\u5458\u7684\u7FA4\u6635\u79F0\u3002";
|
|
81
|
+
var DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION = "\u7981\u8A00\u6307\u5B9A\u7FA4\u6210\u5458\uFF0Cduration=0 \u8868\u793A\u89E3\u9664\u7981\u8A00\u3002";
|
|
82
|
+
var DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\u56DE\u5E94\u3002";
|
|
83
|
+
var DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION = "\u6839\u636E\u6D88\u606F ID \u64A4\u56DE\u6307\u5B9A\u6D88\u606F\u3002";
|
|
84
|
+
|
|
85
|
+
// src/schema/native-tools.ts
|
|
86
|
+
var NativeToolsSchema = import_koishi2.Schema.object({
|
|
87
|
+
poke: import_koishi2.Schema.object({
|
|
88
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u6233\u4E00\u6233\uFF08\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"),
|
|
89
|
+
toolName: import_koishi2.Schema.string().default("poke_user").description("\u5DE5\u5177\u540D\u79F0"),
|
|
90
|
+
description: import_koishi2.Schema.string().default(DEFAULT_POKE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
91
|
+
}).description("\u6233\u4E00\u6233\u5DE5\u5177").collapse(),
|
|
92
|
+
setSelfProfile: import_koishi2.Schema.object({
|
|
93
|
+
enabled: import_koishi2.Schema.boolean().default(false).description(
|
|
94
|
+
"\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F\uFF08\u652F\u6301\u6635\u79F0/\u7B7E\u540D/\u6027\u522B\uFF09"
|
|
95
|
+
),
|
|
96
|
+
toolName: import_koishi2.Schema.string().default("set_self_profile").description("\u5DE5\u5177\u540D\u79F0"),
|
|
97
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
98
|
+
}).description("\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F\u5DE5\u5177").collapse(),
|
|
99
|
+
setGroupCard: import_koishi2.Schema.object({
|
|
100
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0"),
|
|
101
|
+
toolName: import_koishi2.Schema.string().default("set_group_card").description("\u5DE5\u5177\u540D\u79F0"),
|
|
102
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
103
|
+
}).description("\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0\u5DE5\u5177").collapse(),
|
|
104
|
+
setGroupBan: import_koishi2.Schema.object({
|
|
105
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u7981\u8A00\u7FA4\u6210\u5458"),
|
|
106
|
+
toolName: import_koishi2.Schema.string().default("set_group_ban").description("\u5DE5\u5177\u540D\u79F0"),
|
|
107
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
108
|
+
}).description("\u7981\u8A00\u5DE5\u5177").collapse(),
|
|
109
|
+
setMsgEmoji: import_koishi2.Schema.object({
|
|
110
|
+
enabled: import_koishi2.Schema.boolean().default(false).description(
|
|
111
|
+
"\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u7ED9\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF0C\u8868\u60C5\u5BF9\u7167\u8868\uFF1Ahttps://bot.q.qq.com/wiki/develop/pythonsdk/model/emoji.html \uFF09"
|
|
112
|
+
),
|
|
113
|
+
toolName: import_koishi2.Schema.string().default("set_msg_emoji").description("\u5DE5\u5177\u540D\u79F0"),
|
|
114
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
115
|
+
}).description("\u6D88\u606F\u8868\u60C5\u5DE5\u5177").collapse(),
|
|
116
|
+
deleteMessage: import_koishi2.Schema.object({
|
|
117
|
+
enabled: import_koishi2.Schema.boolean().default(false).description(
|
|
118
|
+
"\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u64A4\u56DE\u6D88\u606F\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"
|
|
119
|
+
),
|
|
120
|
+
toolName: import_koishi2.Schema.string().default("delete_msg").description("\u5DE5\u5177\u540D\u79F0"),
|
|
121
|
+
description: import_koishi2.Schema.string().default(DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
122
|
+
}).description("\u64A4\u56DE\u6D88\u606F\u5DE5\u5177").collapse()
|
|
123
|
+
}).default({
|
|
124
|
+
poke: {
|
|
125
|
+
enabled: false,
|
|
126
|
+
toolName: "poke_user",
|
|
127
|
+
description: DEFAULT_POKE_TOOL_DESCRIPTION
|
|
128
|
+
},
|
|
129
|
+
setSelfProfile: {
|
|
130
|
+
enabled: false,
|
|
131
|
+
toolName: "set_self_profile",
|
|
132
|
+
description: DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION
|
|
133
|
+
},
|
|
134
|
+
setGroupCard: {
|
|
135
|
+
enabled: false,
|
|
136
|
+
toolName: "set_group_card",
|
|
137
|
+
description: DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION
|
|
138
|
+
},
|
|
139
|
+
setGroupBan: {
|
|
140
|
+
enabled: false,
|
|
141
|
+
toolName: "set_group_ban",
|
|
142
|
+
description: DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION
|
|
143
|
+
},
|
|
144
|
+
setMsgEmoji: {
|
|
145
|
+
enabled: false,
|
|
146
|
+
toolName: "set_msg_emoji",
|
|
147
|
+
description: DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION
|
|
148
|
+
},
|
|
149
|
+
deleteMessage: {
|
|
150
|
+
enabled: false,
|
|
151
|
+
toolName: "delete_msg",
|
|
152
|
+
description: DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION
|
|
153
|
+
}
|
|
78
154
|
}).description("\u539F\u751F\u5DE5\u5177");
|
|
79
155
|
|
|
80
156
|
// src/schema/xml-tools.ts
|
|
81
|
-
var
|
|
157
|
+
var import_koishi3 = require("koishi");
|
|
82
158
|
var DEFAULT_XML_REFERENCE_PROMPT = `## \u52A8\u4F5C\u6307\u4EE4
|
|
83
159
|
\u4F60\u53EF\u4EE5\u6839\u636E\u9700\u8981\u5728\u6A21\u578B\u56DE\u590D\u4E2D\u8F93\u51FA\u4E00\u4E2A\u72EC\u7ACB\u7684 <actions> \u5143\u7D20\u3002\u5B83\u7528\u4E8E\u6267\u884C\u975E\u8BED\u8A00\u7684\u7CFB\u7EDF\u6307\u4EE4\u3002\u5982\u679C\u4E0D\u9700\u8981\u6267\u884C\u4EFB\u4F55\u52A8\u4F5C\uFF0C\u8BF7\u7701\u7565\u6B64\u5143\u7D20\u3002
|
|
84
160
|
1. \u6233\u4E00\u6233: <poke id=""/>
|
|
@@ -97,7 +173,13 @@ var DEFAULT_XML_REFERENCE_PROMPT = `## \u52A8\u4F5C\u6307\u4EE4
|
|
|
97
173
|
- 66: \u7231\u5FC3
|
|
98
174
|
- \u9002\u7528\u573A\u666F:
|
|
99
175
|
- \u7528\u4E8E\u5BF9\u4E0A\u4E0B\u6587\u4E2D\u7684\u7279\u5B9A\u6D88\u606F\u8FDB\u884C\u8868\u60C5\u56DE\u5E94\u3002
|
|
100
|
-
3. \
|
|
176
|
+
3. \u7981\u8A00\u7FA4\u6210\u5458: <ban id="" duration=""/>
|
|
177
|
+
- id: user_id
|
|
178
|
+
- duration: \u7981\u8A00\u65F6\u957F\uFF0C\u5355\u4F4D\u79D2\uFF0C\u4F20 0 \u8868\u793A\u89E3\u9664\u7981\u8A00
|
|
179
|
+
- \u9002\u7528\u573A\u666F:
|
|
180
|
+
- \u4F60\u5728\u672C\u7FA4\u4E3A\u7BA1\u7406\u5458
|
|
181
|
+
- \u7528\u4E8E\u7981\u8A00\u6216\u89E3\u9664\u7981\u8A00\u6307\u5B9A\u7FA4\u6210\u5458
|
|
182
|
+
4. \u64A4\u56DE\u6D88\u606F: <delete message_id=""/>
|
|
101
183
|
- message_id: \u6D88\u606F ID
|
|
102
184
|
- \u9002\u7528\u573A\u666F:
|
|
103
185
|
- \u4F60\u5728\u672C\u7FA4\u4E3A\u7BA1\u7406\u5458
|
|
@@ -108,20 +190,26 @@ var DEFAULT_XML_REFERENCE_PROMPT = `## \u52A8\u4F5C\u6307\u4EE4
|
|
|
108
190
|
<actions>
|
|
109
191
|
<poke id="123456"/>
|
|
110
192
|
<emoji message_id="346234" emoji_id="66"/>
|
|
193
|
+
<ban id="123456" duration="600"/>
|
|
111
194
|
<delete message_id="435663"/>
|
|
112
195
|
</actions>
|
|
113
196
|
\`\`\``;
|
|
114
|
-
var XmlToolsSchema =
|
|
115
|
-
enablePokeXmlTool:
|
|
116
|
-
enableEmojiXmlTool:
|
|
197
|
+
var XmlToolsSchema = import_koishi3.Schema.object({
|
|
198
|
+
enablePokeXmlTool: import_koishi3.Schema.boolean().default(false).description("\u542F\u7528 XML \u5F62\u5F0F\u7684\u6233\u4E00\u6233\u8C03\u7528\uFF08\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"),
|
|
199
|
+
enableEmojiXmlTool: import_koishi3.Schema.boolean().default(false).description(
|
|
117
200
|
"\u542F\u7528 XML \u5F62\u5F0F\u7684\u6D88\u606F\u8868\u60C5\u8C03\u7528\uFF0C\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF0Cemoji_id \u5BF9\u7167\u8868\uFF1Ahttps://bot.q.qq.com/wiki/develop/pythonsdk/model/emoji.html \uFF09"
|
|
118
201
|
),
|
|
119
|
-
enableDeleteXmlTool:
|
|
120
|
-
|
|
202
|
+
enableDeleteXmlTool: import_koishi3.Schema.boolean().default(false).description(
|
|
203
|
+
"\u542F\u7528 XML \u5F62\u5F0F\u7684\u6D88\u606F\u64A4\u56DE\u8C03\u7528\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"
|
|
204
|
+
),
|
|
205
|
+
enableBanXmlTool: import_koishi3.Schema.boolean().default(false).description(
|
|
206
|
+
"\u542F\u7528 XML \u5F62\u5F0F\u7684\u7FA4\u6210\u5458\u7981\u8A00\u8C03\u7528\uFF08\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"
|
|
207
|
+
),
|
|
208
|
+
referencePrompt: import_koishi3.Schema.string().role("textarea").default(DEFAULT_XML_REFERENCE_PROMPT).description("\u6A21\u578B\u56DE\u590D XML \u53C2\u8003\u63D0\u793A\u8BCD\uFF0C\u81EA\u884C\u5199\u5165\u63D0\u793A\u8BCD\u4E2D\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165")
|
|
121
209
|
}).description("XML \u5DE5\u5177");
|
|
122
210
|
|
|
123
211
|
// src/schema/variables.ts
|
|
124
|
-
var
|
|
212
|
+
var import_koishi4 = require("koishi");
|
|
125
213
|
|
|
126
214
|
// src/constants/defaults.ts
|
|
127
215
|
var DEFAULT_MEMBER_INFO_ITEMS = [
|
|
@@ -146,58 +234,61 @@ var DEFAULT_GROUP_INFO_ITEMS = [
|
|
|
146
234
|
var RAW_INTERCEPTOR_TAG = "__chatlunaToolboxRawInterceptor";
|
|
147
235
|
|
|
148
236
|
// src/schema/variables.ts
|
|
149
|
-
var VariablesSchema =
|
|
150
|
-
userInfo:
|
|
151
|
-
variableName:
|
|
152
|
-
items:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
237
|
+
var VariablesSchema = import_koishi4.Schema.object({
|
|
238
|
+
userInfo: import_koishi4.Schema.object({
|
|
239
|
+
variableName: import_koishi4.Schema.string().default("userInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
240
|
+
items: import_koishi4.Schema.array(
|
|
241
|
+
import_koishi4.Schema.union([
|
|
242
|
+
import_koishi4.Schema.const("userId").description("\u7528\u6237 ID"),
|
|
243
|
+
import_koishi4.Schema.const("nickname").description("\u7FA4\u6635\u79F0"),
|
|
244
|
+
import_koishi4.Schema.const("role").description("\u7FA4\u5185\u8EAB\u4EFD"),
|
|
245
|
+
import_koishi4.Schema.const("level").description("\u7FA4\u7B49\u7EA7"),
|
|
246
|
+
import_koishi4.Schema.const("title").description("\u7FA4\u5934\u8854"),
|
|
247
|
+
import_koishi4.Schema.const("gender").description("\u6027\u522B"),
|
|
248
|
+
import_koishi4.Schema.const("age").description("\u5E74\u9F84"),
|
|
249
|
+
import_koishi4.Schema.const("area").description("\u5730\u533A"),
|
|
250
|
+
import_koishi4.Schema.const("joinTime").description("\u5165\u7FA4\u65F6\u95F4"),
|
|
251
|
+
import_koishi4.Schema.const("lastSentTime").description("\u6700\u540E\u53D1\u8A00\u65F6\u95F4")
|
|
164
252
|
])
|
|
165
253
|
).role("checkbox").default([...DEFAULT_MEMBER_INFO_ITEMS]).description("\u663E\u793A\u7684\u8BE6\u7EC6\u4FE1\u606F\u9879")
|
|
166
254
|
}).description("\u7528\u6237\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
167
|
-
botInfo:
|
|
168
|
-
variableName:
|
|
169
|
-
items:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
255
|
+
botInfo: import_koishi4.Schema.object({
|
|
256
|
+
variableName: import_koishi4.Schema.string().default("botInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
257
|
+
items: import_koishi4.Schema.array(
|
|
258
|
+
import_koishi4.Schema.union([
|
|
259
|
+
import_koishi4.Schema.const("userId").description("\u673A\u5668\u4EBA ID"),
|
|
260
|
+
import_koishi4.Schema.const("nickname").description("\u7FA4\u6635\u79F0"),
|
|
261
|
+
import_koishi4.Schema.const("role").description("\u7FA4\u5185\u8EAB\u4EFD"),
|
|
262
|
+
import_koishi4.Schema.const("level").description("\u7FA4\u7B49\u7EA7"),
|
|
263
|
+
import_koishi4.Schema.const("title").description("\u7FA4\u5934\u8854"),
|
|
264
|
+
import_koishi4.Schema.const("gender").description("\u6027\u522B"),
|
|
265
|
+
import_koishi4.Schema.const("age").description("\u5E74\u9F84"),
|
|
266
|
+
import_koishi4.Schema.const("area").description("\u5730\u533A"),
|
|
267
|
+
import_koishi4.Schema.const("joinTime").description("\u5165\u7FA4\u65F6\u95F4"),
|
|
268
|
+
import_koishi4.Schema.const("lastSentTime").description("\u6700\u540E\u53D1\u8A00\u65F6\u95F4")
|
|
181
269
|
])
|
|
182
270
|
).role("checkbox").default([...DEFAULT_MEMBER_INFO_ITEMS]).description("\u663E\u793A\u7684\u673A\u5668\u4EBA\u8BE6\u7EC6\u4FE1\u606F\u9879")
|
|
183
271
|
}).description("\u673A\u5668\u4EBA\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
184
|
-
groupInfo:
|
|
185
|
-
variableName:
|
|
186
|
-
items:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
272
|
+
groupInfo: import_koishi4.Schema.object({
|
|
273
|
+
variableName: import_koishi4.Schema.string().default("groupInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
274
|
+
items: import_koishi4.Schema.array(
|
|
275
|
+
import_koishi4.Schema.union([
|
|
276
|
+
import_koishi4.Schema.const("groupName").description("\u7FA4\u540D\u79F0"),
|
|
277
|
+
import_koishi4.Schema.const("groupId").description("\u7FA4\u53F7"),
|
|
278
|
+
import_koishi4.Schema.const("memberCount").description("\u6210\u5458\u6570\u91CF"),
|
|
279
|
+
import_koishi4.Schema.const("createTime").description("\u521B\u5EFA\u65F6\u95F4\uFF08\u4EC5\u90E8\u5206\u5B9E\u73B0\u652F\u6301\uFF09"),
|
|
280
|
+
import_koishi4.Schema.const("ownerList").description("\u7FA4\u4E3B\u540D\u5355"),
|
|
281
|
+
import_koishi4.Schema.const("adminList").description("\u7BA1\u7406\u5458\u540D\u5355")
|
|
194
282
|
])
|
|
195
283
|
).role("checkbox").default([...DEFAULT_GROUP_INFO_ITEMS]).description("\u663E\u793A\u7684\u7FA4\u4FE1\u606F\u9879")
|
|
196
284
|
}).description("\u7FA4\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
197
|
-
|
|
198
|
-
variableName:
|
|
199
|
-
|
|
200
|
-
|
|
285
|
+
groupShutList: import_koishi4.Schema.object({
|
|
286
|
+
variableName: import_koishi4.Schema.string().default("groupShutList").description("\u53D8\u91CF\u540D\u79F0")
|
|
287
|
+
}).description("\u7FA4\u7981\u8A00\u5217\u8868\u53D8\u91CF").collapse(),
|
|
288
|
+
random: import_koishi4.Schema.object({
|
|
289
|
+
variableName: import_koishi4.Schema.string().default("random").description("\u53D8\u91CF\u540D\u79F0"),
|
|
290
|
+
min: import_koishi4.Schema.number().default(0).description("\u9ED8\u8BA4\u968F\u673A\u6570\u4E0B\u9650"),
|
|
291
|
+
max: import_koishi4.Schema.number().default(100).description("\u9ED8\u8BA4\u968F\u673A\u6570\u4E0A\u9650")
|
|
201
292
|
}).description("\u968F\u673A\u6570\u53D8\u91CF").collapse()
|
|
202
293
|
}).default({
|
|
203
294
|
userInfo: {
|
|
@@ -209,19 +300,21 @@ var VariablesSchema = import_koishi3.Schema.object({
|
|
|
209
300
|
variableName: "groupInfo",
|
|
210
301
|
items: [...DEFAULT_GROUP_INFO_ITEMS]
|
|
211
302
|
},
|
|
303
|
+
groupShutList: { variableName: "groupShutList" },
|
|
212
304
|
random: { variableName: "random", min: 0, max: 100 }
|
|
213
305
|
}).description("\u5176\u4ED6\u53D8\u91CF");
|
|
214
306
|
|
|
215
307
|
// src/schema/index.ts
|
|
216
|
-
var OtherSettingsSchema =
|
|
217
|
-
debugLogging:
|
|
308
|
+
var OtherSettingsSchema = import_koishi5.Schema.object({
|
|
309
|
+
debugLogging: import_koishi5.Schema.boolean().default(false).description("\u8F93\u51FA\u8C03\u8BD5\u65E5\u5FD7")
|
|
218
310
|
}).description("\u5176\u4ED6\u8BBE\u7F6E");
|
|
219
311
|
var name = "chatluna-toolbox";
|
|
220
312
|
var inject = {
|
|
221
313
|
required: ["chatluna"],
|
|
222
314
|
optional: ["chatluna_character"]
|
|
223
315
|
};
|
|
224
|
-
var ConfigSchema =
|
|
316
|
+
var ConfigSchema = import_koishi5.Schema.intersect([
|
|
317
|
+
BasicSettingsSchema,
|
|
225
318
|
NativeToolsSchema,
|
|
226
319
|
XmlToolsSchema,
|
|
227
320
|
VariablesSchema,
|
|
@@ -305,10 +398,10 @@ async function sendDeleteMessage(params) {
|
|
|
305
398
|
}
|
|
306
399
|
}
|
|
307
400
|
function createDeleteMessageTool(deps) {
|
|
308
|
-
const { toolName, log } = deps;
|
|
401
|
+
const { toolName, description, log } = deps;
|
|
309
402
|
const tool = {
|
|
310
403
|
name: toolName || "delete_msg",
|
|
311
|
-
description:
|
|
404
|
+
description: description || DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION,
|
|
312
405
|
schema: import_zod.z.object({
|
|
313
406
|
messageId: import_zod.z.string().min(1, "messageId is required").describe("Specific message ID to delete.")
|
|
314
407
|
}),
|
|
@@ -375,10 +468,10 @@ async function sendPoke(params) {
|
|
|
375
468
|
}
|
|
376
469
|
}
|
|
377
470
|
function createPokeTool(deps) {
|
|
378
|
-
const { toolName, log, protocol } = deps;
|
|
471
|
+
const { toolName, description, log, protocol } = deps;
|
|
379
472
|
return new class extends import_tools.StructuredTool {
|
|
380
473
|
name = toolName || "poke_user";
|
|
381
|
-
description =
|
|
474
|
+
description = description || DEFAULT_POKE_TOOL_DESCRIPTION;
|
|
382
475
|
schema = import_zod2.z.object({
|
|
383
476
|
userId: import_zod2.z.string().min(1, "userId is required").describe("The user ID to poke."),
|
|
384
477
|
groupId: import_zod2.z.string().optional().describe("Optional: specify a different group ID.")
|
|
@@ -396,18 +489,92 @@ function createPokeTool(deps) {
|
|
|
396
489
|
}();
|
|
397
490
|
}
|
|
398
491
|
|
|
399
|
-
// src/features/native-tools/tools/set-group-
|
|
492
|
+
// src/features/native-tools/tools/set-group-ban.ts
|
|
400
493
|
var import_zod3 = require("zod");
|
|
401
494
|
var import_tools2 = require("@langchain/core/tools");
|
|
402
|
-
function
|
|
403
|
-
|
|
495
|
+
function resolveGroupId(session, groupId) {
|
|
496
|
+
return groupId?.trim() || (session.guildId || "").trim() || (session.channelId || "").trim() || (session.roomId || "").trim();
|
|
497
|
+
}
|
|
498
|
+
function parseDuration(duration) {
|
|
499
|
+
const raw = String(duration).trim();
|
|
500
|
+
if (!raw) return null;
|
|
501
|
+
if (!/^\d+$/.test(raw)) return null;
|
|
502
|
+
const parsed = Number(raw);
|
|
503
|
+
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
504
|
+
}
|
|
505
|
+
async function sendGroupBan(params) {
|
|
506
|
+
try {
|
|
507
|
+
const { session, userId, groupId, duration, log } = params;
|
|
508
|
+
const {
|
|
509
|
+
error,
|
|
510
|
+
internal,
|
|
511
|
+
session: validatedSession
|
|
512
|
+
} = ensureOneBotSession(session);
|
|
513
|
+
if (error) return error;
|
|
514
|
+
const resolvedGroupId = resolveGroupId(validatedSession, groupId);
|
|
515
|
+
if (!resolvedGroupId) {
|
|
516
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
517
|
+
}
|
|
518
|
+
const userIdRaw = userId.trim();
|
|
519
|
+
if (!userIdRaw) return "userId is required.";
|
|
520
|
+
const parsedDuration = parseDuration(duration);
|
|
521
|
+
if (parsedDuration === null) {
|
|
522
|
+
return "duration must be a non-negative integer in seconds.";
|
|
523
|
+
}
|
|
524
|
+
await callOneBotAPI(
|
|
525
|
+
internal,
|
|
526
|
+
"set_group_ban",
|
|
527
|
+
{
|
|
528
|
+
group_id: resolvedGroupId,
|
|
529
|
+
user_id: userIdRaw,
|
|
530
|
+
duration: parsedDuration
|
|
531
|
+
},
|
|
532
|
+
["setGroupBan"]
|
|
533
|
+
);
|
|
534
|
+
const success = parsedDuration === 0 ? `\u5DF2\u89E3\u9664\u7FA4 ${resolvedGroupId} \u4E2D\u7528\u6237 ${userIdRaw} \u7684\u7981\u8A00\u3002` : `\u5DF2\u5728\u7FA4 ${resolvedGroupId} \u4E2D\u7981\u8A00\u7528\u6237 ${userIdRaw} ${parsedDuration} \u79D2\u3002`;
|
|
535
|
+
log?.("info", success);
|
|
536
|
+
return success;
|
|
537
|
+
} catch (error) {
|
|
538
|
+
params.log?.("warn", "set_group_ban failed", error);
|
|
539
|
+
return `set_group_ban failed: ${error.message}`;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function createSetGroupBanTool(deps) {
|
|
543
|
+
const { toolName, description, protocol, log } = deps;
|
|
404
544
|
return new class extends import_tools2.StructuredTool {
|
|
405
|
-
name = toolName || "
|
|
406
|
-
description =
|
|
545
|
+
name = toolName || "set_group_ban";
|
|
546
|
+
description = description || DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION;
|
|
407
547
|
schema = import_zod3.z.object({
|
|
408
548
|
groupId: import_zod3.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
409
549
|
userId: import_zod3.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
410
|
-
|
|
550
|
+
duration: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number().int().min(0)]).describe("Mute duration in seconds. Use 0 to unmute.")
|
|
551
|
+
});
|
|
552
|
+
async _call(input, _manager, runnable) {
|
|
553
|
+
const session = getSession(runnable);
|
|
554
|
+
return sendGroupBan({
|
|
555
|
+
session,
|
|
556
|
+
userId: input.userId,
|
|
557
|
+
duration: input.duration,
|
|
558
|
+
groupId: input.groupId,
|
|
559
|
+
protocol,
|
|
560
|
+
log
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// src/features/native-tools/tools/set-group-card.ts
|
|
567
|
+
var import_zod4 = require("zod");
|
|
568
|
+
var import_tools3 = require("@langchain/core/tools");
|
|
569
|
+
function createSetGroupCardTool(deps) {
|
|
570
|
+
const { toolName, description, log } = deps;
|
|
571
|
+
return new class extends import_tools3.StructuredTool {
|
|
572
|
+
name = toolName || "set_group_card";
|
|
573
|
+
description = description || DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION;
|
|
574
|
+
schema = import_zod4.z.object({
|
|
575
|
+
groupId: import_zod4.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
576
|
+
userId: import_zod4.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
577
|
+
card: import_zod4.z.string().min(1, "card is required").describe("New group card for the member.")
|
|
411
578
|
});
|
|
412
579
|
async _call(input, _manager, runnable) {
|
|
413
580
|
try {
|
|
@@ -440,8 +607,8 @@ function createSetGroupCardTool(deps) {
|
|
|
440
607
|
}
|
|
441
608
|
|
|
442
609
|
// src/features/native-tools/tools/set-msg-emoji.ts
|
|
443
|
-
var
|
|
444
|
-
var
|
|
610
|
+
var import_zod5 = require("zod");
|
|
611
|
+
var import_tools4 = require("@langchain/core/tools");
|
|
445
612
|
async function sendMsgEmoji(params) {
|
|
446
613
|
try {
|
|
447
614
|
const { session, messageId, emojiId, log, protocol } = params;
|
|
@@ -473,13 +640,13 @@ async function sendMsgEmoji(params) {
|
|
|
473
640
|
}
|
|
474
641
|
}
|
|
475
642
|
function createSetMsgEmojiTool(deps) {
|
|
476
|
-
const { toolName, log, protocol } = deps;
|
|
477
|
-
return new class extends
|
|
643
|
+
const { toolName, description, log, protocol } = deps;
|
|
644
|
+
return new class extends import_tools4.StructuredTool {
|
|
478
645
|
name = toolName || "set_msg_emoji";
|
|
479
|
-
description =
|
|
480
|
-
schema =
|
|
481
|
-
messageId:
|
|
482
|
-
emojiId:
|
|
646
|
+
description = description || DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION;
|
|
647
|
+
schema = import_zod5.z.object({
|
|
648
|
+
messageId: import_zod5.z.string().min(1, "message_id is required").describe("Target message ID."),
|
|
649
|
+
emojiId: import_zod5.z.string().min(1, "emoji_id is required").describe("Emoji ID to send.")
|
|
483
650
|
});
|
|
484
651
|
async _call(input, _manager, runnable) {
|
|
485
652
|
const session = getSession(runnable);
|
|
@@ -495,22 +662,22 @@ function createSetMsgEmojiTool(deps) {
|
|
|
495
662
|
}
|
|
496
663
|
|
|
497
664
|
// src/features/native-tools/tools/profile.ts
|
|
498
|
-
var
|
|
499
|
-
var
|
|
665
|
+
var import_zod6 = require("zod");
|
|
666
|
+
var import_tools5 = require("@langchain/core/tools");
|
|
500
667
|
var genders = {
|
|
501
668
|
unknown: "0",
|
|
502
669
|
male: "1",
|
|
503
670
|
female: "2"
|
|
504
671
|
};
|
|
505
672
|
function createSetProfileTool(deps) {
|
|
506
|
-
const { toolName, log, protocol } = deps;
|
|
507
|
-
return new class extends
|
|
673
|
+
const { toolName, description, log, protocol } = deps;
|
|
674
|
+
return new class extends import_tools5.StructuredTool {
|
|
508
675
|
name = toolName || "set_self_profile";
|
|
509
|
-
description =
|
|
510
|
-
schema =
|
|
511
|
-
nickname:
|
|
512
|
-
signature:
|
|
513
|
-
gender:
|
|
676
|
+
description = description || DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION;
|
|
677
|
+
schema = import_zod6.z.object({
|
|
678
|
+
nickname: import_zod6.z.string().min(1, "nickname is required").describe("The new nickname for the bot."),
|
|
679
|
+
signature: import_zod6.z.string().optional().describe("Optional: the new personal signature."),
|
|
680
|
+
gender: import_zod6.z.enum(["unknown", "male", "female"]).optional().describe("Optional: the new gender.")
|
|
514
681
|
});
|
|
515
682
|
async _call(input, _manager, runnable) {
|
|
516
683
|
try {
|
|
@@ -536,6 +703,14 @@ function createSetProfileTool(deps) {
|
|
|
536
703
|
}
|
|
537
704
|
|
|
538
705
|
// src/features/native-tools/register.ts
|
|
706
|
+
function resolveToolName(value, fallback) {
|
|
707
|
+
const trimmedValue = value.trim();
|
|
708
|
+
return trimmedValue || fallback;
|
|
709
|
+
}
|
|
710
|
+
function resolveToolDescription(value, fallback) {
|
|
711
|
+
const trimmedValue = value.trim();
|
|
712
|
+
return trimmedValue || fallback;
|
|
713
|
+
}
|
|
539
714
|
function resolveOneBotProtocol(config, log) {
|
|
540
715
|
if (config.enableNapCatProtocol && config.enableLlbotProtocol) {
|
|
541
716
|
log?.("warn", "NapCat \u4E0E LLBot \u534F\u8BAE\u540C\u65F6\u542F\u7528\uFF0C\u5C06\u4F18\u5148\u4F7F\u7528 LLBot\u3002");
|
|
@@ -548,56 +723,96 @@ function resolveOneBotProtocol(config, log) {
|
|
|
548
723
|
}
|
|
549
724
|
function registerNativeTools(deps) {
|
|
550
725
|
const { ctx, config, plugin, protocol, log } = deps;
|
|
551
|
-
if (config.
|
|
552
|
-
const toolName =
|
|
726
|
+
if (config.poke.enabled) {
|
|
727
|
+
const toolName = resolveToolName(config.poke.toolName, "poke_user");
|
|
728
|
+
const description = resolveToolDescription(
|
|
729
|
+
config.poke.description,
|
|
730
|
+
DEFAULT_POKE_TOOL_DESCRIPTION
|
|
731
|
+
);
|
|
553
732
|
plugin.registerTool(toolName, {
|
|
554
733
|
selector: () => true,
|
|
555
734
|
authorization: (session) => session?.platform === "onebot",
|
|
556
|
-
createTool: () => createPokeTool({ ctx, toolName, log, protocol })
|
|
735
|
+
createTool: () => createPokeTool({ ctx, toolName, description, log, protocol })
|
|
557
736
|
});
|
|
558
737
|
log?.("info", `\u6233\u4E00\u6233\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
559
738
|
}
|
|
560
|
-
if (config.
|
|
561
|
-
const toolName =
|
|
562
|
-
config.
|
|
563
|
-
|
|
739
|
+
if (config.setSelfProfile.enabled) {
|
|
740
|
+
const toolName = resolveToolName(
|
|
741
|
+
config.setSelfProfile.toolName,
|
|
742
|
+
"set_self_profile"
|
|
743
|
+
);
|
|
744
|
+
const description = resolveToolDescription(
|
|
745
|
+
config.setSelfProfile.description,
|
|
746
|
+
DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION
|
|
747
|
+
);
|
|
564
748
|
plugin.registerTool(toolName, {
|
|
565
749
|
selector: () => true,
|
|
566
750
|
authorization: (session) => session?.platform === "onebot",
|
|
567
|
-
createTool: () => createSetProfileTool({ ctx, toolName, log, protocol })
|
|
751
|
+
createTool: () => createSetProfileTool({ ctx, toolName, description, log, protocol })
|
|
568
752
|
});
|
|
569
753
|
log?.("info", `\u8BBE\u7F6E\u8D44\u6599\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
570
754
|
}
|
|
571
|
-
if (config.
|
|
572
|
-
const toolName =
|
|
573
|
-
config.
|
|
574
|
-
|
|
755
|
+
if (config.setGroupCard.enabled) {
|
|
756
|
+
const toolName = resolveToolName(
|
|
757
|
+
config.setGroupCard.toolName,
|
|
758
|
+
"set_group_card"
|
|
759
|
+
);
|
|
760
|
+
const description = resolveToolDescription(
|
|
761
|
+
config.setGroupCard.description,
|
|
762
|
+
DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION
|
|
763
|
+
);
|
|
575
764
|
plugin.registerTool(toolName, {
|
|
576
765
|
selector: () => true,
|
|
577
766
|
authorization: (session) => session?.platform === "onebot",
|
|
578
|
-
createTool: () => createSetGroupCardTool({ ctx, toolName, log })
|
|
767
|
+
createTool: () => createSetGroupCardTool({ ctx, toolName, description, log })
|
|
579
768
|
});
|
|
580
769
|
log?.("info", `\u7FA4\u6635\u79F0\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
581
770
|
}
|
|
582
|
-
if (config.
|
|
583
|
-
const toolName =
|
|
584
|
-
config.
|
|
585
|
-
|
|
771
|
+
if (config.setGroupBan.enabled) {
|
|
772
|
+
const toolName = resolveToolName(
|
|
773
|
+
config.setGroupBan.toolName,
|
|
774
|
+
"set_group_ban"
|
|
775
|
+
);
|
|
776
|
+
const description = resolveToolDescription(
|
|
777
|
+
config.setGroupBan.description,
|
|
778
|
+
DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION
|
|
779
|
+
);
|
|
586
780
|
plugin.registerTool(toolName, {
|
|
587
781
|
selector: () => true,
|
|
588
782
|
authorization: (session) => session?.platform === "onebot",
|
|
589
|
-
createTool: () =>
|
|
783
|
+
createTool: () => createSetGroupBanTool({ toolName, description, log, protocol })
|
|
784
|
+
});
|
|
785
|
+
log?.("info", `\u7FA4\u6210\u5458\u7981\u8A00\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
786
|
+
}
|
|
787
|
+
if (config.setMsgEmoji.enabled) {
|
|
788
|
+
const toolName = resolveToolName(
|
|
789
|
+
config.setMsgEmoji.toolName,
|
|
790
|
+
"set_msg_emoji"
|
|
791
|
+
);
|
|
792
|
+
const description = resolveToolDescription(
|
|
793
|
+
config.setMsgEmoji.description,
|
|
794
|
+
DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION
|
|
795
|
+
);
|
|
796
|
+
plugin.registerTool(toolName, {
|
|
797
|
+
selector: () => true,
|
|
798
|
+
authorization: (session) => session?.platform === "onebot",
|
|
799
|
+
createTool: () => createSetMsgEmojiTool({ toolName, description, log, protocol })
|
|
590
800
|
});
|
|
591
801
|
log?.("info", `\u6D88\u606F\u8868\u60C5\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
592
802
|
}
|
|
593
|
-
if (config.
|
|
594
|
-
const toolName =
|
|
595
|
-
config.
|
|
596
|
-
|
|
803
|
+
if (config.deleteMessage.enabled) {
|
|
804
|
+
const toolName = resolveToolName(
|
|
805
|
+
config.deleteMessage.toolName,
|
|
806
|
+
"delete_msg"
|
|
807
|
+
);
|
|
808
|
+
const description = resolveToolDescription(
|
|
809
|
+
config.deleteMessage.description,
|
|
810
|
+
DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION
|
|
811
|
+
);
|
|
597
812
|
plugin.registerTool(toolName, {
|
|
598
813
|
selector: () => true,
|
|
599
814
|
authorization: (session) => session?.platform === "onebot",
|
|
600
|
-
createTool: () => createDeleteMessageTool({ toolName, log })
|
|
815
|
+
createTool: () => createDeleteMessageTool({ toolName, description, log })
|
|
601
816
|
});
|
|
602
817
|
log?.("info", `\u5220\u9664\u6D88\u606F\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
603
818
|
}
|
|
@@ -627,14 +842,19 @@ function createXmlProcessor(deps) {
|
|
|
627
842
|
log,
|
|
628
843
|
sendPoke: runPoke = sendPoke,
|
|
629
844
|
sendMsgEmoji: runEmoji = sendMsgEmoji,
|
|
630
|
-
sendDeleteMessage: runDelete = sendDeleteMessage
|
|
845
|
+
sendDeleteMessage: runDelete = sendDeleteMessage,
|
|
846
|
+
sendGroupBan: runBan = sendGroupBan
|
|
631
847
|
} = deps;
|
|
632
|
-
return async ({
|
|
848
|
+
return async ({
|
|
849
|
+
response,
|
|
850
|
+
session
|
|
851
|
+
}) => {
|
|
633
852
|
const content = String(response || "").trim();
|
|
634
853
|
if (!content) return false;
|
|
635
854
|
const pokeTags = parseSelfClosingXmlTags(content, "poke");
|
|
636
855
|
const emojiTags = parseSelfClosingXmlTags(content, "emoji");
|
|
637
856
|
const deleteTags = parseSelfClosingXmlTags(content, "delete");
|
|
857
|
+
const banTags = parseSelfClosingXmlTags(content, "ban");
|
|
638
858
|
let handled = false;
|
|
639
859
|
if (config.enablePokeXmlTool && pokeTags.length > 0) {
|
|
640
860
|
if (!session) {
|
|
@@ -690,6 +910,30 @@ function createXmlProcessor(deps) {
|
|
|
690
910
|
}
|
|
691
911
|
}
|
|
692
912
|
}
|
|
913
|
+
if (config.enableBanXmlTool && banTags.length > 0) {
|
|
914
|
+
if (!session) {
|
|
915
|
+
log?.("warn", "\u68C0\u6D4B\u5230\u7981\u8A00\u6807\u8BB0\u4F46\u7F3A\u5C11\u4F1A\u8BDD\u4E0A\u4E0B\u6587");
|
|
916
|
+
} else {
|
|
917
|
+
const items = banTags.map((attrs) => ({
|
|
918
|
+
userId: String(attrs.id || "").trim(),
|
|
919
|
+
duration: String(attrs.duration || "").trim()
|
|
920
|
+
})).filter((item) => item.userId && item.duration);
|
|
921
|
+
if (items.length > 0) handled = true;
|
|
922
|
+
for (const item of items) {
|
|
923
|
+
try {
|
|
924
|
+
await runBan({
|
|
925
|
+
session,
|
|
926
|
+
userId: item.userId,
|
|
927
|
+
duration: item.duration,
|
|
928
|
+
protocol,
|
|
929
|
+
log
|
|
930
|
+
});
|
|
931
|
+
} catch (error) {
|
|
932
|
+
log?.("warn", "XML \u89E6\u53D1\u7981\u8A00\u5931\u8D25", error);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
693
937
|
return handled;
|
|
694
938
|
};
|
|
695
939
|
}
|
|
@@ -1262,6 +1506,113 @@ function createGroupInfoProvider(deps) {
|
|
|
1262
1506
|
};
|
|
1263
1507
|
}
|
|
1264
1508
|
|
|
1509
|
+
// src/features/variables/providers/group-shut-list.ts
|
|
1510
|
+
function normalizeTimestamp2(raw) {
|
|
1511
|
+
if (raw === null || raw === void 0 || raw === "" || Number(raw) === 0)
|
|
1512
|
+
return null;
|
|
1513
|
+
const numeric = Number(raw);
|
|
1514
|
+
if (!Number.isFinite(numeric)) return null;
|
|
1515
|
+
return numeric < 1e11 ? numeric * 1e3 : numeric;
|
|
1516
|
+
}
|
|
1517
|
+
function formatDateTime2(value) {
|
|
1518
|
+
if (!value) return "\u672A\u77E5";
|
|
1519
|
+
const date = new Date(value);
|
|
1520
|
+
if (Number.isNaN(date.valueOf())) return "\u672A\u77E5";
|
|
1521
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} ${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
1522
|
+
}
|
|
1523
|
+
function pickFirst2(...values) {
|
|
1524
|
+
for (const value of values) {
|
|
1525
|
+
if (value === null || value === void 0) continue;
|
|
1526
|
+
const text = String(value).trim();
|
|
1527
|
+
if (text) return text;
|
|
1528
|
+
}
|
|
1529
|
+
return "";
|
|
1530
|
+
}
|
|
1531
|
+
function extractList(result) {
|
|
1532
|
+
if (Array.isArray(result)) return result;
|
|
1533
|
+
if (result && typeof result === "object" && Array.isArray(result.data)) {
|
|
1534
|
+
return result.data;
|
|
1535
|
+
}
|
|
1536
|
+
return [];
|
|
1537
|
+
}
|
|
1538
|
+
function normalizeShutItem(item) {
|
|
1539
|
+
const userId = pickFirst2(
|
|
1540
|
+
item.uin,
|
|
1541
|
+
item.user_id
|
|
1542
|
+
);
|
|
1543
|
+
if (!userId) return null;
|
|
1544
|
+
const cardName = pickFirst2(
|
|
1545
|
+
item.cardName,
|
|
1546
|
+
item.remark,
|
|
1547
|
+
item.nick,
|
|
1548
|
+
item.nickname,
|
|
1549
|
+
userId
|
|
1550
|
+
);
|
|
1551
|
+
const shutUpTimeText = formatDateTime2(
|
|
1552
|
+
normalizeTimestamp2(
|
|
1553
|
+
pickFirst2(
|
|
1554
|
+
item.shutUpTime,
|
|
1555
|
+
item.shut_up_time
|
|
1556
|
+
)
|
|
1557
|
+
)
|
|
1558
|
+
);
|
|
1559
|
+
return {
|
|
1560
|
+
userId,
|
|
1561
|
+
cardName,
|
|
1562
|
+
shutUpTimeText
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
async function fetchGroupShutList(session, config) {
|
|
1566
|
+
const { error, internal } = ensureOneBotSession(session);
|
|
1567
|
+
if (error || !internal)
|
|
1568
|
+
throw new Error(error || "\u7F3A\u5C11 OneBot internal \u63A5\u53E3\u3002");
|
|
1569
|
+
const preferredProtocol = resolveOneBotProtocol(config);
|
|
1570
|
+
const preferredGroupId = preferredProtocol === "llbot" ? String(session.guildId) : Number(session.guildId);
|
|
1571
|
+
const fallbackGroupId = preferredProtocol === "llbot" ? Number(session.guildId) : String(session.guildId);
|
|
1572
|
+
try {
|
|
1573
|
+
const result = await callOneBotAPI(
|
|
1574
|
+
internal,
|
|
1575
|
+
"get_group_shut_list",
|
|
1576
|
+
{ group_id: preferredGroupId },
|
|
1577
|
+
["getGroupShutList"]
|
|
1578
|
+
);
|
|
1579
|
+
return extractList(result);
|
|
1580
|
+
} catch (error2) {
|
|
1581
|
+
if (preferredGroupId === fallbackGroupId) throw error2;
|
|
1582
|
+
const result = await callOneBotAPI(
|
|
1583
|
+
internal,
|
|
1584
|
+
"get_group_shut_list",
|
|
1585
|
+
{ group_id: fallbackGroupId },
|
|
1586
|
+
["getGroupShutList"]
|
|
1587
|
+
);
|
|
1588
|
+
return extractList(result);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
function renderShutList(items) {
|
|
1592
|
+
if (items.length === 0) return "\u5F53\u524D\u7FA4\u6682\u65E0\u7981\u8A00\u6210\u5458\u3002";
|
|
1593
|
+
return items.map(
|
|
1594
|
+
(item) => `id\uFF1A${item.userId}\uFF0Cname\uFF1A${item.cardName}\uFF0C\u7981\u8A00\u622A\u81F3\uFF1A${item.shutUpTimeText}`
|
|
1595
|
+
).join("\n");
|
|
1596
|
+
}
|
|
1597
|
+
function createGroupShutListProvider(deps) {
|
|
1598
|
+
const { config, log } = deps;
|
|
1599
|
+
return async (_args, _variables, configurable) => {
|
|
1600
|
+
const session = configurable?.session;
|
|
1601
|
+
if (!session) return "\u6682\u65E0\u7FA4\u7981\u8A00\u5217\u8868\u3002";
|
|
1602
|
+
if (!session.guildId) return "";
|
|
1603
|
+
if (session.platform !== "onebot")
|
|
1604
|
+
return "\u5F53\u524D\u5E73\u53F0\u6682\u4E0D\u652F\u6301\u67E5\u8BE2\u7FA4\u7981\u8A00\u5217\u8868\u3002";
|
|
1605
|
+
try {
|
|
1606
|
+
const list = await fetchGroupShutList(session, config);
|
|
1607
|
+
const normalized = list.map(normalizeShutItem).filter(Boolean);
|
|
1608
|
+
return renderShutList(normalized);
|
|
1609
|
+
} catch (error) {
|
|
1610
|
+
log?.("debug", "\u7FA4\u7981\u8A00\u5217\u8868\u53D8\u91CF\u89E3\u6790\u5931\u8D25", error);
|
|
1611
|
+
return "\u83B7\u53D6\u7FA4\u7981\u8A00\u5217\u8868\u5931\u8D25\u3002";
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1265
1616
|
// src/features/variables/providers/random.ts
|
|
1266
1617
|
function createRandomProvider(deps) {
|
|
1267
1618
|
const { config } = deps;
|
|
@@ -1286,7 +1637,7 @@ function translateGender2(value) {
|
|
|
1286
1637
|
if (["\u672A\u77E5", "unknown", "0", "secret"].includes(text)) return "";
|
|
1287
1638
|
return String(value);
|
|
1288
1639
|
}
|
|
1289
|
-
function
|
|
1640
|
+
function normalizeTimestamp3(raw) {
|
|
1290
1641
|
if (raw === null || raw === void 0 || raw === "") return null;
|
|
1291
1642
|
const numeric = Number(raw);
|
|
1292
1643
|
if (!Number.isFinite(numeric)) return null;
|
|
@@ -1298,13 +1649,13 @@ function formatDateOnly3(value) {
|
|
|
1298
1649
|
if (Number.isNaN(date.valueOf())) return "";
|
|
1299
1650
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
1300
1651
|
}
|
|
1301
|
-
function
|
|
1652
|
+
function formatDateTime3(value) {
|
|
1302
1653
|
if (!value) return "";
|
|
1303
1654
|
const date = new Date(value);
|
|
1304
1655
|
if (Number.isNaN(date.valueOf())) return "";
|
|
1305
1656
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} ${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
1306
1657
|
}
|
|
1307
|
-
function
|
|
1658
|
+
function pickFirst3(...values) {
|
|
1308
1659
|
for (const value of values) {
|
|
1309
1660
|
if (value === null || value === void 0) continue;
|
|
1310
1661
|
const text = String(value).trim();
|
|
@@ -1362,7 +1713,7 @@ function renderUserInfo(session, member, items) {
|
|
|
1362
1713
|
switch (item) {
|
|
1363
1714
|
case "nickname": {
|
|
1364
1715
|
const name2 = String(
|
|
1365
|
-
|
|
1716
|
+
pickFirst3(
|
|
1366
1717
|
member?.card,
|
|
1367
1718
|
member?.remark,
|
|
1368
1719
|
member?.displayName,
|
|
@@ -1381,7 +1732,7 @@ function renderUserInfo(session, member, items) {
|
|
|
1381
1732
|
break;
|
|
1382
1733
|
case "role": {
|
|
1383
1734
|
const role = normalizeRole2(
|
|
1384
|
-
|
|
1735
|
+
pickFirst3(
|
|
1385
1736
|
member?.role,
|
|
1386
1737
|
member?.roleName,
|
|
1387
1738
|
member?.permission,
|
|
@@ -1392,7 +1743,7 @@ function renderUserInfo(session, member, items) {
|
|
|
1392
1743
|
break;
|
|
1393
1744
|
}
|
|
1394
1745
|
case "level": {
|
|
1395
|
-
const level =
|
|
1746
|
+
const level = pickFirst3(
|
|
1396
1747
|
member?.level,
|
|
1397
1748
|
member?.levelName,
|
|
1398
1749
|
member?.level_name,
|
|
@@ -1402,7 +1753,7 @@ function renderUserInfo(session, member, items) {
|
|
|
1402
1753
|
break;
|
|
1403
1754
|
}
|
|
1404
1755
|
case "title": {
|
|
1405
|
-
const title =
|
|
1756
|
+
const title = pickFirst3(
|
|
1406
1757
|
member?.title,
|
|
1407
1758
|
member?.specialTitle,
|
|
1408
1759
|
member?.special_title
|
|
@@ -1421,14 +1772,14 @@ function renderUserInfo(session, member, items) {
|
|
|
1421
1772
|
break;
|
|
1422
1773
|
}
|
|
1423
1774
|
case "area": {
|
|
1424
|
-
const area =
|
|
1775
|
+
const area = pickFirst3(member?.area, member?.region, member?.location);
|
|
1425
1776
|
if (area !== null) values.push(`\u5730\u533A:${area}`);
|
|
1426
1777
|
break;
|
|
1427
1778
|
}
|
|
1428
1779
|
case "joinTime": {
|
|
1429
1780
|
const joinTime = formatDateOnly3(
|
|
1430
|
-
|
|
1431
|
-
|
|
1781
|
+
normalizeTimestamp3(
|
|
1782
|
+
pickFirst3(
|
|
1432
1783
|
member?.join_time,
|
|
1433
1784
|
member?.joined_at,
|
|
1434
1785
|
member?.joinTime,
|
|
@@ -1440,9 +1791,9 @@ function renderUserInfo(session, member, items) {
|
|
|
1440
1791
|
break;
|
|
1441
1792
|
}
|
|
1442
1793
|
case "lastSentTime": {
|
|
1443
|
-
const lastSentTime =
|
|
1444
|
-
|
|
1445
|
-
|
|
1794
|
+
const lastSentTime = formatDateTime3(
|
|
1795
|
+
normalizeTimestamp3(
|
|
1796
|
+
pickFirst3(
|
|
1446
1797
|
member?.last_sent_time,
|
|
1447
1798
|
member?.lastSentTime,
|
|
1448
1799
|
member?.lastSpeakTimestamp
|
|
@@ -1498,6 +1849,17 @@ function registerVariables(deps) {
|
|
|
1498
1849
|
promptRenderer.registerFunctionProvider(groupInfoName, groupInfoProvider);
|
|
1499
1850
|
log?.("info", `\u7FA4\u7EC4\u4FE1\u606F\u53D8\u91CF\u5DF2\u6CE8\u518C: ${groupInfoName}`);
|
|
1500
1851
|
}
|
|
1852
|
+
const groupShutListProvider = createGroupShutListProvider({ config, log });
|
|
1853
|
+
const groupShutListName = String(
|
|
1854
|
+
config.groupShutList?.variableName || "groupShutList"
|
|
1855
|
+
).trim();
|
|
1856
|
+
if (groupShutListName) {
|
|
1857
|
+
promptRenderer.registerFunctionProvider(
|
|
1858
|
+
groupShutListName,
|
|
1859
|
+
groupShutListProvider
|
|
1860
|
+
);
|
|
1861
|
+
log?.("info", `\u7FA4\u7981\u8A00\u5217\u8868\u53D8\u91CF\u5DF2\u6CE8\u518C: ${groupShutListName}`);
|
|
1862
|
+
}
|
|
1501
1863
|
const randomProvider = createRandomProvider({ config });
|
|
1502
1864
|
const randomName = String(config.random?.variableName || "random").trim();
|
|
1503
1865
|
if (randomName) {
|
|
@@ -1533,7 +1895,7 @@ function apply(ctx, config) {
|
|
|
1533
1895
|
xmlRuntime?.stop();
|
|
1534
1896
|
xmlRuntime = null;
|
|
1535
1897
|
};
|
|
1536
|
-
if (config.enablePokeXmlTool || config.enableEmojiXmlTool || config.enableDeleteXmlTool) {
|
|
1898
|
+
if (config.enablePokeXmlTool || config.enableEmojiXmlTool || config.enableDeleteXmlTool || config.enableBanXmlTool) {
|
|
1537
1899
|
ctx.inject(["chatluna_character"], (innerCtx) => {
|
|
1538
1900
|
characterCtx = innerCtx;
|
|
1539
1901
|
if (!xmlRuntime) return;
|
|
@@ -1556,6 +1918,7 @@ function apply(ctx, config) {
|
|
|
1556
1918
|
}
|
|
1557
1919
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1558
1920
|
0 && (module.exports = {
|
|
1921
|
+
BasicSettingsSchema,
|
|
1559
1922
|
Config,
|
|
1560
1923
|
ConfigSchema,
|
|
1561
1924
|
DEFAULT_GROUP_INFO_ITEMS,
|
|
@@ -1570,9 +1933,11 @@ function apply(ctx, config) {
|
|
|
1570
1933
|
createCharacterTempXmlRuntime,
|
|
1571
1934
|
createDeleteMessageTool,
|
|
1572
1935
|
createGroupInfoProvider,
|
|
1936
|
+
createGroupShutListProvider,
|
|
1573
1937
|
createLogger,
|
|
1574
1938
|
createPokeTool,
|
|
1575
1939
|
createRandomProvider,
|
|
1940
|
+
createSetGroupBanTool,
|
|
1576
1941
|
createSetGroupCardTool,
|
|
1577
1942
|
createSetMsgEmojiTool,
|
|
1578
1943
|
createSetProfileTool,
|
|
@@ -1588,6 +1953,7 @@ function apply(ctx, config) {
|
|
|
1588
1953
|
registerXmlTools,
|
|
1589
1954
|
resolveOneBotProtocol,
|
|
1590
1955
|
sendDeleteMessage,
|
|
1956
|
+
sendGroupBan,
|
|
1591
1957
|
sendMsgEmoji,
|
|
1592
1958
|
sendPoke
|
|
1593
1959
|
});
|