koishi-plugin-chatluna-toolbox 0.0.19 → 0.0.21
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/README.md +2 -0
- package/dist/index.js +101 -97
- package/lib/index.js +225 -68
- package/package.json +5 -6
- package/client/ToolboxDetailsLoader.vue +0 -20
- package/client/constants.ts +0 -19
- package/client/index.ts +0 -15
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { openBlock as y, createElementBlock as
|
|
2
|
-
const
|
|
3
|
-
const r =
|
|
4
|
-
for (const [c, t] of
|
|
1
|
+
import { openBlock as y, createElementBlock as k, createElementVNode as _, defineComponent as b, Fragment as E, renderList as N, normalizeClass as v, toDisplayString as z, reactive as I, computed as f, onUnmounted as L, ref as T, onMounted as B, normalizeStyle as A, createVNode as x, withModifiers as D, unref as $, inject as K, createBlock as X, createCommentVNode as O } from "vue";
|
|
2
|
+
const S = (n, e) => {
|
|
3
|
+
const r = n.__vccOpts || n;
|
|
4
|
+
for (const [c, t] of e)
|
|
5
5
|
r[c] = t;
|
|
6
6
|
return r;
|
|
7
7
|
}, V = {}, Y = {
|
|
@@ -10,40 +10,40 @@ const M = (s, o) => {
|
|
|
10
10
|
width: "20",
|
|
11
11
|
height: "20"
|
|
12
12
|
};
|
|
13
|
-
function q(
|
|
14
|
-
return y(),
|
|
15
|
-
|
|
13
|
+
function q(n, e) {
|
|
14
|
+
return y(), k("svg", Y, [...e[0] || (e[0] = [
|
|
15
|
+
_("path", {
|
|
16
16
|
d: "M288 224c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zm320 0c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zM288 512c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zm320 0c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zM352 864c-35.3 0-64-28.7-64-64s28.7-64 64-64 64 28.7 64 64-28.7 64-64 64zm320 0c-35.3 0-64-28.7-64-64s28.7-64 64-64 64 28.7 64 64-28.7 64-64 64z",
|
|
17
17
|
fill: "currentColor"
|
|
18
18
|
}, null, -1)
|
|
19
19
|
])]);
|
|
20
20
|
}
|
|
21
|
-
const P = /* @__PURE__ */
|
|
21
|
+
const P = /* @__PURE__ */ S(V, [["render", q]]), W = {}, j = {
|
|
22
22
|
viewBox: "0 0 1024 1024",
|
|
23
23
|
xmlns: "http://www.w3.org/2000/svg",
|
|
24
24
|
width: "20",
|
|
25
25
|
height: "20"
|
|
26
26
|
};
|
|
27
|
-
function U(
|
|
28
|
-
return y(),
|
|
29
|
-
|
|
27
|
+
function U(n, e) {
|
|
28
|
+
return y(), k("svg", j, [...e[0] || (e[0] = [
|
|
29
|
+
_("path", {
|
|
30
30
|
d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z",
|
|
31
31
|
fill: "currentColor"
|
|
32
32
|
}, null, -1)
|
|
33
33
|
])]);
|
|
34
34
|
}
|
|
35
|
-
const F = /* @__PURE__ */
|
|
35
|
+
const F = /* @__PURE__ */ S(W, [["render", U]]), G = ["onClick"], H = /* @__PURE__ */ b({
|
|
36
36
|
__name: "NavSection",
|
|
37
37
|
props: {
|
|
38
38
|
sections: {},
|
|
39
39
|
activeKey: {}
|
|
40
40
|
},
|
|
41
41
|
emits: ["select"],
|
|
42
|
-
setup(
|
|
43
|
-
return (
|
|
42
|
+
setup(n) {
|
|
43
|
+
return (e, r) => (y(!0), k(E, null, N(n.sections, (c) => (y(), k("div", {
|
|
44
44
|
key: c.key,
|
|
45
|
-
class:
|
|
46
|
-
onClick: (t) =>
|
|
45
|
+
class: v([e.$style.item, n.activeKey === c.key ? e.$style.active : ""]),
|
|
46
|
+
onClick: (t) => e.$emit("select", c)
|
|
47
47
|
}, z(c.title), 11, G))), 128));
|
|
48
48
|
}
|
|
49
49
|
}), J = "_item_1m2kp_1", Q = "_active_1m2kp_16", Z = {
|
|
@@ -51,24 +51,24 @@ const F = /* @__PURE__ */ M(W, [["render", U]]), G = ["onClick"], H = /* @__PURE
|
|
|
51
51
|
active: Q
|
|
52
52
|
}, tt = {
|
|
53
53
|
$style: Z
|
|
54
|
-
}, et = /* @__PURE__ */
|
|
55
|
-
function R(
|
|
56
|
-
return
|
|
57
|
-
x:
|
|
58
|
-
y:
|
|
54
|
+
}, et = /* @__PURE__ */ S(H, [["__cssModules", tt]]);
|
|
55
|
+
function R(n) {
|
|
56
|
+
return n instanceof TouchEvent ? {
|
|
57
|
+
x: n.touches[0].clientX,
|
|
58
|
+
y: n.touches[0].clientY
|
|
59
59
|
} : {
|
|
60
|
-
x:
|
|
61
|
-
y:
|
|
60
|
+
x: n.clientX,
|
|
61
|
+
y: n.clientY
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function ot(
|
|
64
|
+
function ot(n = {}) {
|
|
65
65
|
const {
|
|
66
|
-
initialTop:
|
|
66
|
+
initialTop: e = 100,
|
|
67
67
|
initialRight: r = 20,
|
|
68
68
|
boundarySelector: c = ".plugin-view"
|
|
69
|
-
} =
|
|
69
|
+
} = n, t = I({
|
|
70
70
|
isDragging: !1,
|
|
71
|
-
top:
|
|
71
|
+
top: e,
|
|
72
72
|
right: r,
|
|
73
73
|
startTop: 0,
|
|
74
74
|
startRight: 0,
|
|
@@ -79,16 +79,16 @@ function ot(s = {}) {
|
|
|
79
79
|
}), g = f(() => ({
|
|
80
80
|
top: `${t.top}px`,
|
|
81
81
|
right: `${t.right}px`
|
|
82
|
-
})), i = (
|
|
82
|
+
})), i = (h) => {
|
|
83
83
|
var C;
|
|
84
84
|
if (!t.isDragging)
|
|
85
85
|
return;
|
|
86
|
-
const
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
}, p = (
|
|
90
|
-
const l = R(
|
|
91
|
-
|
|
86
|
+
const d = R(h), l = t.startTop + (d.y - t.startY), a = t.startRight - (d.x - t.startX), o = (C = document.querySelector(c)) == null ? void 0 : C.getBoundingClientRect();
|
|
87
|
+
let s = 0, m = window.innerHeight - t.height, w = 0, M = window.innerWidth - t.width;
|
|
88
|
+
o && (s = o.top, m = o.bottom - t.height, w = window.innerWidth - o.right, M = window.innerWidth - o.left - t.width), t.top = Math.max(s, Math.min(m, l)), t.right = Math.max(w, Math.min(M, a));
|
|
89
|
+
}, p = (h, d) => {
|
|
90
|
+
const l = R(h), a = d == null ? void 0 : d.getBoundingClientRect();
|
|
91
|
+
a && (t.width = a.width, t.height = a.height), t.startTop = t.top, t.startRight = t.right, t.startX = l.x, t.startY = l.y, t.isDragging = !0;
|
|
92
92
|
}, u = () => {
|
|
93
93
|
t.isDragging = !1;
|
|
94
94
|
};
|
|
@@ -99,22 +99,22 @@ function ot(s = {}) {
|
|
|
99
99
|
startDrag: p
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function nt(
|
|
102
|
+
function nt(n) {
|
|
103
103
|
const {
|
|
104
|
-
titleToKeyMap:
|
|
104
|
+
titleToKeyMap: e,
|
|
105
105
|
headerSelector: r = ".k-schema-header",
|
|
106
106
|
rootMargin: c = "-20% 0px -60% 0px",
|
|
107
107
|
threshold: t = 0
|
|
108
|
-
} =
|
|
108
|
+
} = n, g = T("");
|
|
109
109
|
let i = null;
|
|
110
110
|
const p = /* @__PURE__ */ new Map(), u = () => {
|
|
111
111
|
i == null || i.disconnect(), p.clear(), i = new IntersectionObserver(
|
|
112
112
|
(l) => {
|
|
113
|
-
for (const
|
|
114
|
-
if (!
|
|
113
|
+
for (const a of l) {
|
|
114
|
+
if (!a.isIntersecting)
|
|
115
115
|
continue;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const o = p.get(a.target);
|
|
117
|
+
o && (g.value = o);
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
{
|
|
@@ -123,21 +123,21 @@ function nt(s) {
|
|
|
123
123
|
threshold: t
|
|
124
124
|
}
|
|
125
125
|
), document.querySelectorAll(r).forEach((l) => {
|
|
126
|
-
const
|
|
127
|
-
for (const [
|
|
128
|
-
if (
|
|
129
|
-
i == null || i.observe(l), p.set(l,
|
|
126
|
+
const a = l.textContent || "";
|
|
127
|
+
for (const [o, s] of Object.entries(e))
|
|
128
|
+
if (a.includes(o)) {
|
|
129
|
+
i == null || i.observe(l), p.set(l, s);
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
},
|
|
133
|
+
}, h = () => {
|
|
134
134
|
setTimeout(u, 500);
|
|
135
135
|
};
|
|
136
|
-
return B(
|
|
136
|
+
return B(h), L(() => {
|
|
137
137
|
i == null || i.disconnect();
|
|
138
138
|
}), {
|
|
139
139
|
activeSection: g,
|
|
140
|
-
refresh:
|
|
140
|
+
refresh: h
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
const st = /* @__PURE__ */ b({
|
|
@@ -148,76 +148,80 @@ const st = /* @__PURE__ */ b({
|
|
|
148
148
|
boundarySelector: { default: ".plugin-view" },
|
|
149
149
|
initialTop: { default: 100 },
|
|
150
150
|
initialRight: { default: 20 },
|
|
151
|
+
width: {},
|
|
151
152
|
rootMargin: { default: "-20% 0px -60% 0px" },
|
|
152
153
|
threshold: { default: 0 }
|
|
153
154
|
},
|
|
154
|
-
setup(
|
|
155
|
-
const
|
|
156
|
-
() =>
|
|
157
|
-
(
|
|
155
|
+
setup(n) {
|
|
156
|
+
const e = n, r = T(!1), c = T(null), t = f(
|
|
157
|
+
() => e.sections.reduce(
|
|
158
|
+
(o, s) => (o[s.matchText ?? s.title] = s.key, o),
|
|
158
159
|
{}
|
|
159
160
|
)
|
|
160
161
|
), g = f(
|
|
161
|
-
() =>
|
|
162
|
-
(
|
|
162
|
+
() => e.sections.reduce(
|
|
163
|
+
(o, s) => (o[s.key] = s.matchText ?? s.title, o),
|
|
163
164
|
{}
|
|
164
165
|
)
|
|
165
|
-
), i = (
|
|
166
|
-
|
|
166
|
+
), i = (o) => {
|
|
167
|
+
o.stopPropagation(), r.value = !r.value;
|
|
167
168
|
}, { position: p, startDrag: u } = ot({
|
|
168
|
-
initialTop:
|
|
169
|
-
initialRight:
|
|
170
|
-
boundarySelector:
|
|
171
|
-
}),
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
initialTop: e.initialTop,
|
|
170
|
+
initialRight: e.initialRight,
|
|
171
|
+
boundarySelector: e.boundarySelector
|
|
172
|
+
}), h = f(() => ({
|
|
173
|
+
...p.value,
|
|
174
|
+
...e.width ? { width: `${e.width}px` } : {}
|
|
175
|
+
})), d = (o) => {
|
|
176
|
+
u(o, c.value);
|
|
177
|
+
}, { activeSection: l } = nt({
|
|
174
178
|
titleToKeyMap: t.value,
|
|
175
|
-
headerSelector:
|
|
176
|
-
rootMargin:
|
|
177
|
-
threshold:
|
|
178
|
-
}),
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
for (let
|
|
182
|
-
const
|
|
183
|
-
if ((
|
|
184
|
-
|
|
179
|
+
headerSelector: e.headerSelector,
|
|
180
|
+
rootMargin: e.rootMargin,
|
|
181
|
+
threshold: e.threshold
|
|
182
|
+
}), a = (o) => {
|
|
183
|
+
l.value = o.key;
|
|
184
|
+
const s = document.querySelectorAll(e.headerSelector);
|
|
185
|
+
for (let m = 0; m < s.length; m += 1) {
|
|
186
|
+
const w = s[m];
|
|
187
|
+
if ((w.textContent || "").includes(g.value[o.key])) {
|
|
188
|
+
w.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
192
|
};
|
|
189
|
-
return (
|
|
193
|
+
return (o, s) => (y(), k("div", {
|
|
190
194
|
ref_key: "containerRef",
|
|
191
195
|
ref: c,
|
|
192
|
-
class:
|
|
193
|
-
style: A(
|
|
196
|
+
class: v([o.$style.container, r.value ? o.$style.collapsed : ""]),
|
|
197
|
+
style: A(h.value)
|
|
194
198
|
}, [
|
|
195
|
-
|
|
196
|
-
class:
|
|
199
|
+
_("div", {
|
|
200
|
+
class: v(o.$style.header),
|
|
197
201
|
onMousedown: d,
|
|
198
202
|
onTouchstart: d
|
|
199
203
|
}, [
|
|
200
204
|
x(P, {
|
|
201
|
-
class:
|
|
205
|
+
class: v(o.$style.move)
|
|
202
206
|
}, null, 8, ["class"]),
|
|
203
|
-
|
|
204
|
-
class:
|
|
207
|
+
_("div", {
|
|
208
|
+
class: v(o.$style.toggle),
|
|
205
209
|
onClick: i,
|
|
206
|
-
onMousedown:
|
|
210
|
+
onMousedown: s[0] || (s[0] = D(() => {
|
|
207
211
|
}, ["stop"])),
|
|
208
|
-
onTouchstart:
|
|
212
|
+
onTouchstart: s[1] || (s[1] = D(() => {
|
|
209
213
|
}, ["stop"]))
|
|
210
214
|
}, [
|
|
211
215
|
x(F)
|
|
212
216
|
], 34)
|
|
213
217
|
], 34),
|
|
214
|
-
|
|
215
|
-
class:
|
|
218
|
+
_("div", {
|
|
219
|
+
class: v(o.$style.body)
|
|
216
220
|
}, [
|
|
217
221
|
x(et, {
|
|
218
|
-
sections:
|
|
219
|
-
"active-key":
|
|
220
|
-
onSelect:
|
|
222
|
+
sections: n.sections,
|
|
223
|
+
"active-key": $(l),
|
|
224
|
+
onSelect: a
|
|
221
225
|
}, null, 8, ["sections", "active-key"])
|
|
222
226
|
], 2)
|
|
223
227
|
], 6));
|
|
@@ -231,7 +235,7 @@ const st = /* @__PURE__ */ b({
|
|
|
231
235
|
collapsed: dt
|
|
232
236
|
}, ht = {
|
|
233
237
|
$style: ut
|
|
234
|
-
}, gt = /* @__PURE__ */
|
|
238
|
+
}, gt = /* @__PURE__ */ S(st, [["__cssModules", ht]]), pt = [
|
|
235
239
|
{ title: "基础设置", key: "basic" },
|
|
236
240
|
{ title: "原生工具", key: "nativeTools" },
|
|
237
241
|
{ title: "Character XML 工具", key: "xmlTools" },
|
|
@@ -240,22 +244,22 @@ const st = /* @__PURE__ */ b({
|
|
|
240
244
|
], mt = [
|
|
241
245
|
"chatluna-toolbox",
|
|
242
246
|
"koishi-plugin-chatluna-toolbox"
|
|
243
|
-
],
|
|
247
|
+
], vt = /* @__PURE__ */ b({
|
|
244
248
|
__name: "ToolboxDetailsLoader",
|
|
245
|
-
setup(
|
|
246
|
-
const
|
|
247
|
-
const t = (
|
|
249
|
+
setup(n) {
|
|
250
|
+
const e = K("plugin:name"), r = pt, c = f(() => {
|
|
251
|
+
const t = (e == null ? void 0 : e.value) || "";
|
|
248
252
|
return mt.includes(t);
|
|
249
253
|
});
|
|
250
|
-
return (t, g) => c.value ? (y(), X(
|
|
254
|
+
return (t, g) => c.value ? (y(), X($(gt), {
|
|
251
255
|
key: 0,
|
|
252
|
-
sections:
|
|
256
|
+
sections: $(r)
|
|
253
257
|
}, null, 8, ["sections"])) : O("", !0);
|
|
254
258
|
}
|
|
255
|
-
}), wt = (
|
|
256
|
-
|
|
259
|
+
}), wt = (n) => {
|
|
260
|
+
n.slot({
|
|
257
261
|
type: "plugin-details",
|
|
258
|
-
component:
|
|
262
|
+
component: vt,
|
|
259
263
|
order: -999
|
|
260
264
|
});
|
|
261
265
|
};
|
package/lib/index.js
CHANGED
|
@@ -418,12 +418,14 @@ __export(index_exports, {
|
|
|
418
418
|
createDeleteMessageTool: () => createDeleteMessageTool,
|
|
419
419
|
createGroupInfoProvider: () => createGroupInfoProvider,
|
|
420
420
|
createGroupShutListProvider: () => createGroupShutListProvider,
|
|
421
|
+
createLeaveGroupTool: () => createLeaveGroupTool,
|
|
421
422
|
createLogger: () => createLogger,
|
|
422
423
|
createPokeTool: () => createPokeTool,
|
|
423
424
|
createRandomProvider: () => createRandomProvider,
|
|
424
425
|
createSearchGroupMemberTool: () => createSearchGroupMemberTool,
|
|
425
426
|
createSetGroupBanTool: () => createSetGroupBanTool,
|
|
426
427
|
createSetGroupCardTool: () => createSetGroupCardTool,
|
|
428
|
+
createSetGroupKickTool: () => createSetGroupKickTool,
|
|
427
429
|
createSetGroupSpecialTitleTool: () => createSetGroupSpecialTitleTool,
|
|
428
430
|
createSetMsgEmojiTool: () => createSetMsgEmojiTool,
|
|
429
431
|
createSetProfileTool: () => createSetProfileTool,
|
|
@@ -444,6 +446,8 @@ __export(index_exports, {
|
|
|
444
446
|
searchGroupMember: () => searchGroupMember,
|
|
445
447
|
sendDeleteMessage: () => sendDeleteMessage,
|
|
446
448
|
sendGroupBan: () => sendGroupBan,
|
|
449
|
+
sendGroupKick: () => sendGroupKick,
|
|
450
|
+
sendLeaveGroup: () => sendLeaveGroup,
|
|
447
451
|
sendMsgEmoji: () => sendMsgEmoji,
|
|
448
452
|
sendPoke: () => sendPoke,
|
|
449
453
|
sendSetGroupCard: () => sendSetGroupCard,
|
|
@@ -476,6 +480,8 @@ var DEFAULT_SET_QQ_AVATAR_TOOL_DESCRIPTION = "\u4FEE\u6539\u673A\u5668\u4EBA QQ
|
|
|
476
480
|
var DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION = "\u4FEE\u6539\u7FA4\u6210\u5458\u7684\u7FA4\u6635\u79F0\u3002";
|
|
477
481
|
var DEFAULT_SEARCH_GROUP_MEMBER_TOOL_DESCRIPTION = "\u6839\u636E qqid \u7CBE\u786E\u67E5\u8BE2\u7FA4\u6210\u5458\u7684\u7FA4\u6635\u79F0\u4E0E QQ \u6635\u79F0\uFF0C\u6216\u6839\u636E\u7FA4\u6635\u79F0/QQ \u6635\u79F0\u641C\u7D22 qqid\u3002\u9ED8\u8BA4\u67E5\u8BE2\u5F53\u524D\u7FA4\u804A\uFF0C\u53EF\u901A\u8FC7 groupId \u67E5\u8BE2\u6307\u5B9A\u7FA4\u3002";
|
|
478
482
|
var DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION = "\u7528\u4E8E\u7BA1\u7406\u7FA4\u6210\u5458\u7981\u8A00\u72B6\u6001\uFF0C\u53EF\u8BBE\u7F6E\u7981\u8A00\u65F6\u957F\u6216\u89E3\u9664\u7981\u8A00\u3002";
|
|
483
|
+
var DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION = "\u8BA9\u673A\u5668\u4EBA\u9000\u51FA\u5F53\u524D\u7FA4\u804A\u3002";
|
|
484
|
+
var DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION = "\u5C06\u6307\u5B9A\u6210\u5458\u8E22\u51FA\u7FA4\u804A\u3002";
|
|
479
485
|
var DEFAULT_SET_GROUP_SPECIAL_TITLE_TOOL_DESCRIPTION = "\u4FEE\u6539\u6216\u6E05\u9664\u7FA4\u6210\u5458\u7684 QQ \u7FA4\u4E13\u5C5E\u5934\u8854\u3002";
|
|
480
486
|
var DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\u56DE\u5E94\u3002";
|
|
481
487
|
var DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION = "\u6839\u636E\u6D88\u606F ID \u64A4\u56DE\u6307\u5B9A\u6D88\u606F\u3002";
|
|
@@ -489,14 +495,15 @@ var EnabledNativeToolsSchema = import_koishi2.Schema.array(
|
|
|
489
495
|
import_koishi2.Schema.const("setGroupCard").description("\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0"),
|
|
490
496
|
import_koishi2.Schema.const("searchGroupMember").description("\u641C\u7D22\u7FA4\u6210\u5458"),
|
|
491
497
|
import_koishi2.Schema.const("setGroupBan").description("\u7981\u8A00\u7FA4\u6210\u5458"),
|
|
498
|
+
import_koishi2.Schema.const("leaveGroup").description("\u9000\u7FA4"),
|
|
499
|
+
import_koishi2.Schema.const("setGroupKick").description("\u8E22\u51FA\u7FA4\u6210\u5458"),
|
|
492
500
|
import_koishi2.Schema.const("setGroupSpecialTitle").description("\u4FEE\u6539\u7FA4\u6210\u5458\u4E13\u5C5E\u5934\u8854"),
|
|
493
501
|
import_koishi2.Schema.const("setMsgEmoji").description("\u6D88\u606F\u8868\u60C5"),
|
|
494
502
|
import_koishi2.Schema.const("deleteMessage").description("\u64A4\u56DE\u6D88\u606F")
|
|
495
503
|
])
|
|
496
|
-
).role("checkbox").extra("default", void 0).description(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
|
|
504
|
+
).role("checkbox").extra("default", void 0).description("\u9009\u62E9\u8981\u6CE8\u518C\u5230 ChatLuna \u7684\u539F\u751F\u5DE5\u5177");
|
|
505
|
+
var NativeToolsSchema = import_koishi2.Schema.object({
|
|
506
|
+
enabledNativeTools: EnabledNativeToolsSchema,
|
|
500
507
|
poke: import_koishi2.Schema.object({
|
|
501
508
|
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
502
509
|
toolName: import_koishi2.Schema.string().default("poke_user").description("\u5DE5\u5177\u540D\u79F0"),
|
|
@@ -527,6 +534,16 @@ var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
|
|
|
527
534
|
toolName: import_koishi2.Schema.string().default("set_group_ban").description("\u5DE5\u5177\u540D\u79F0"),
|
|
528
535
|
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
529
536
|
}).description("\u7981\u8A00\u5DE5\u5177").collapse(),
|
|
537
|
+
leaveGroup: import_koishi2.Schema.object({
|
|
538
|
+
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
539
|
+
toolName: import_koishi2.Schema.string().default("set_group_leave").description("\u5DE5\u5177\u540D\u79F0"),
|
|
540
|
+
description: import_koishi2.Schema.string().default(DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
541
|
+
}).description("\u9000\u7FA4\u5DE5\u5177").collapse(),
|
|
542
|
+
setGroupKick: import_koishi2.Schema.object({
|
|
543
|
+
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
544
|
+
toolName: import_koishi2.Schema.string().default("set_group_kick").description("\u5DE5\u5177\u540D\u79F0"),
|
|
545
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
546
|
+
}).description("\u8E22\u51FA\u7FA4\u6210\u5458\u5DE5\u5177").collapse(),
|
|
530
547
|
setGroupSpecialTitle: import_koishi2.Schema.object({
|
|
531
548
|
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
532
549
|
toolName: import_koishi2.Schema.string().default("set_group_special_title").description("\u5DE5\u5177\u540D\u79F0"),
|
|
@@ -542,13 +559,7 @@ var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
|
|
|
542
559
|
toolName: import_koishi2.Schema.string().default("delete_msg").description("\u5DE5\u5177\u540D\u79F0"),
|
|
543
560
|
description: import_koishi2.Schema.string().default(DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
544
561
|
}).description("\u64A4\u56DE\u6D88\u606F\u5DE5\u5177").collapse()
|
|
545
|
-
}).description("\
|
|
546
|
-
var NativeToolsSchema = import_koishi2.Schema.intersect([
|
|
547
|
-
import_koishi2.Schema.object({
|
|
548
|
-
enabledNativeTools: EnabledNativeToolsSchema
|
|
549
|
-
}).description(""),
|
|
550
|
-
NativeToolAdvancedSettingsSchema
|
|
551
|
-
]).description("\u539F\u751F\u5DE5\u5177");
|
|
562
|
+
}).description("\u539F\u751F\u5DE5\u5177");
|
|
552
563
|
|
|
553
564
|
// src/schema/xml-tools.ts
|
|
554
565
|
var import_koishi3 = require("koishi");
|
|
@@ -844,9 +855,60 @@ function createDeleteMessageTool(deps) {
|
|
|
844
855
|
}();
|
|
845
856
|
}
|
|
846
857
|
|
|
847
|
-
// src/features/native-tools/tools/
|
|
858
|
+
// src/features/native-tools/tools/leave-group.ts
|
|
848
859
|
var import_zod2 = require("zod");
|
|
849
860
|
var import_tools2 = require("@langchain/core/tools");
|
|
861
|
+
function resolveGroupId(session, groupId) {
|
|
862
|
+
return groupId?.trim() || (session.guildId ? String(session.guildId).trim() : "") || (session.channelId ? String(session.channelId).trim() : "");
|
|
863
|
+
}
|
|
864
|
+
async function sendLeaveGroup(params) {
|
|
865
|
+
try {
|
|
866
|
+
const { session, groupId, log } = params;
|
|
867
|
+
const {
|
|
868
|
+
error,
|
|
869
|
+
internal,
|
|
870
|
+
session: validatedSession
|
|
871
|
+
} = ensureOneBotSession(session);
|
|
872
|
+
if (error) return error;
|
|
873
|
+
const resolvedGroupId = resolveGroupId(validatedSession, groupId);
|
|
874
|
+
if (!resolvedGroupId) {
|
|
875
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
876
|
+
}
|
|
877
|
+
await callOneBotAPI(
|
|
878
|
+
internal,
|
|
879
|
+
"set_group_leave",
|
|
880
|
+
{ group_id: resolvedGroupId },
|
|
881
|
+
["setGroupLeave"]
|
|
882
|
+
);
|
|
883
|
+
const message = `\u5DF2\u9000\u51FA\u7FA4 ${resolvedGroupId}\u3002`;
|
|
884
|
+
log?.("info", message);
|
|
885
|
+
return message;
|
|
886
|
+
} catch (error) {
|
|
887
|
+
params.log?.("warn", "set_group_leave failed", error);
|
|
888
|
+
return `set_group_leave failed: ${error.message}`;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
function createLeaveGroupTool(deps) {
|
|
892
|
+
const { toolName, description, log } = deps;
|
|
893
|
+
return new class extends import_tools2.StructuredTool {
|
|
894
|
+
name = toolName || "set_group_leave";
|
|
895
|
+
description = description || DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION;
|
|
896
|
+
schema = import_zod2.z.object({
|
|
897
|
+
groupId: import_zod2.z.string().optional().describe("Target group ID. Defaults to current session group.")
|
|
898
|
+
});
|
|
899
|
+
async _call(input, _manager, runnable) {
|
|
900
|
+
return sendLeaveGroup({
|
|
901
|
+
session: getSession(runnable),
|
|
902
|
+
groupId: input.groupId,
|
|
903
|
+
log
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}();
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// src/features/native-tools/tools/poke.ts
|
|
910
|
+
var import_zod3 = require("zod");
|
|
911
|
+
var import_tools3 = require("@langchain/core/tools");
|
|
850
912
|
async function sendPoke(params) {
|
|
851
913
|
try {
|
|
852
914
|
const { session, userId, groupId, log, protocol } = params;
|
|
@@ -893,12 +955,12 @@ async function sendPoke(params) {
|
|
|
893
955
|
}
|
|
894
956
|
function createPokeTool(deps) {
|
|
895
957
|
const { toolName, description, log, protocol } = deps;
|
|
896
|
-
return new class extends
|
|
958
|
+
return new class extends import_tools3.StructuredTool {
|
|
897
959
|
name = toolName || "poke_user";
|
|
898
960
|
description = description || DEFAULT_POKE_TOOL_DESCRIPTION;
|
|
899
|
-
schema =
|
|
900
|
-
userId:
|
|
901
|
-
groupId:
|
|
961
|
+
schema = import_zod3.z.object({
|
|
962
|
+
userId: import_zod3.z.string().min(1, "userId is required").describe("The user ID to poke."),
|
|
963
|
+
groupId: import_zod3.z.string().optional().describe("Optional: specify a different group ID.")
|
|
902
964
|
});
|
|
903
965
|
async _call(input, _manager, runnable) {
|
|
904
966
|
const session = getSession(runnable);
|
|
@@ -914,8 +976,8 @@ function createPokeTool(deps) {
|
|
|
914
976
|
}
|
|
915
977
|
|
|
916
978
|
// src/features/native-tools/tools/search-group-member.ts
|
|
917
|
-
var
|
|
918
|
-
var
|
|
979
|
+
var import_zod4 = require("zod");
|
|
980
|
+
var import_tools4 = require("@langchain/core/tools");
|
|
919
981
|
var MAX_RESULTS = 10;
|
|
920
982
|
function pickFirst(...values) {
|
|
921
983
|
for (const value of values) {
|
|
@@ -925,7 +987,7 @@ function pickFirst(...values) {
|
|
|
925
987
|
}
|
|
926
988
|
return "";
|
|
927
989
|
}
|
|
928
|
-
function
|
|
990
|
+
function resolveGroupId2(session, groupId) {
|
|
929
991
|
return groupId?.trim() || session.guildId?.trim() || (session.event?.guild?.id || "");
|
|
930
992
|
}
|
|
931
993
|
function normalizeId(value) {
|
|
@@ -993,7 +1055,7 @@ async function searchGroupMember(params) {
|
|
|
993
1055
|
session: validatedSession
|
|
994
1056
|
} = ensureOneBotSession(session);
|
|
995
1057
|
if (error) return error;
|
|
996
|
-
const resolvedGroupId =
|
|
1058
|
+
const resolvedGroupId = resolveGroupId2(validatedSession, groupId);
|
|
997
1059
|
if (!resolvedGroupId) {
|
|
998
1060
|
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
999
1061
|
}
|
|
@@ -1018,13 +1080,13 @@ async function searchGroupMember(params) {
|
|
|
1018
1080
|
}
|
|
1019
1081
|
function createSearchGroupMemberTool(deps) {
|
|
1020
1082
|
const { toolName, description, log } = deps;
|
|
1021
|
-
return new class extends
|
|
1083
|
+
return new class extends import_tools4.StructuredTool {
|
|
1022
1084
|
name = toolName || "search_group_member";
|
|
1023
1085
|
description = description || DEFAULT_SEARCH_GROUP_MEMBER_TOOL_DESCRIPTION;
|
|
1024
|
-
schema =
|
|
1025
|
-
groupId:
|
|
1026
|
-
query:
|
|
1027
|
-
mode:
|
|
1086
|
+
schema = import_zod4.z.object({
|
|
1087
|
+
groupId: import_zod4.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1088
|
+
query: import_zod4.z.string().min(1, "query is required").describe("qqid, group card, or QQ nickname to search."),
|
|
1089
|
+
mode: import_zod4.z.enum(["auto", "byName", "byQQ"]).optional().describe("Search mode. Defaults to auto.")
|
|
1028
1090
|
});
|
|
1029
1091
|
async _call(input, _manager, runnable) {
|
|
1030
1092
|
return searchGroupMember({
|
|
@@ -1039,9 +1101,9 @@ function createSearchGroupMemberTool(deps) {
|
|
|
1039
1101
|
}
|
|
1040
1102
|
|
|
1041
1103
|
// src/features/native-tools/tools/set-group-ban.ts
|
|
1042
|
-
var
|
|
1043
|
-
var
|
|
1044
|
-
function
|
|
1104
|
+
var import_zod5 = require("zod");
|
|
1105
|
+
var import_tools5 = require("@langchain/core/tools");
|
|
1106
|
+
function resolveGroupId3(session, groupId) {
|
|
1045
1107
|
return groupId?.trim() || (session.guildId || "").trim() || (session.channelId || "").trim() || (session.roomId || "").trim();
|
|
1046
1108
|
}
|
|
1047
1109
|
function parseDuration(duration) {
|
|
@@ -1060,7 +1122,7 @@ async function sendGroupBan(params) {
|
|
|
1060
1122
|
session: validatedSession
|
|
1061
1123
|
} = ensureOneBotSession(session);
|
|
1062
1124
|
if (error) return error;
|
|
1063
|
-
const resolvedGroupId =
|
|
1125
|
+
const resolvedGroupId = resolveGroupId3(validatedSession, groupId);
|
|
1064
1126
|
if (!resolvedGroupId) {
|
|
1065
1127
|
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1066
1128
|
}
|
|
@@ -1090,13 +1152,13 @@ async function sendGroupBan(params) {
|
|
|
1090
1152
|
}
|
|
1091
1153
|
function createSetGroupBanTool(deps) {
|
|
1092
1154
|
const { toolName, description, protocol, log } = deps;
|
|
1093
|
-
return new class extends
|
|
1155
|
+
return new class extends import_tools5.StructuredTool {
|
|
1094
1156
|
name = toolName || "set_group_ban";
|
|
1095
1157
|
description = description || DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION;
|
|
1096
|
-
schema =
|
|
1097
|
-
groupId:
|
|
1098
|
-
userId:
|
|
1099
|
-
duration:
|
|
1158
|
+
schema = import_zod5.z.object({
|
|
1159
|
+
groupId: import_zod5.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1160
|
+
userId: import_zod5.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1161
|
+
duration: import_zod5.z.union([import_zod5.z.string(), import_zod5.z.number().int().min(0)]).describe("Mute duration in seconds. Use 0 to unmute.")
|
|
1100
1162
|
});
|
|
1101
1163
|
async _call(input, _manager, runnable) {
|
|
1102
1164
|
const session = getSession(runnable);
|
|
@@ -1113,8 +1175,8 @@ function createSetGroupBanTool(deps) {
|
|
|
1113
1175
|
}
|
|
1114
1176
|
|
|
1115
1177
|
// src/features/native-tools/tools/set-group-card.ts
|
|
1116
|
-
var
|
|
1117
|
-
var
|
|
1178
|
+
var import_zod6 = require("zod");
|
|
1179
|
+
var import_tools6 = require("@langchain/core/tools");
|
|
1118
1180
|
async function sendSetGroupCard(params) {
|
|
1119
1181
|
try {
|
|
1120
1182
|
const { session, userId, card, groupId, log } = params;
|
|
@@ -1145,13 +1207,13 @@ async function sendSetGroupCard(params) {
|
|
|
1145
1207
|
}
|
|
1146
1208
|
function createSetGroupCardTool(deps) {
|
|
1147
1209
|
const { toolName, description, log } = deps;
|
|
1148
|
-
return new class extends
|
|
1210
|
+
return new class extends import_tools6.StructuredTool {
|
|
1149
1211
|
name = toolName || "set_group_card";
|
|
1150
1212
|
description = description || DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION;
|
|
1151
|
-
schema =
|
|
1152
|
-
groupId:
|
|
1153
|
-
userId:
|
|
1154
|
-
card:
|
|
1213
|
+
schema = import_zod6.z.object({
|
|
1214
|
+
groupId: import_zod6.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1215
|
+
userId: import_zod6.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1216
|
+
card: import_zod6.z.string().min(1, "card is required").describe("New group card for the member.")
|
|
1155
1217
|
});
|
|
1156
1218
|
async _call(input, _manager, runnable) {
|
|
1157
1219
|
return sendSetGroupCard({
|
|
@@ -1165,10 +1227,65 @@ function createSetGroupCardTool(deps) {
|
|
|
1165
1227
|
}();
|
|
1166
1228
|
}
|
|
1167
1229
|
|
|
1230
|
+
// src/features/native-tools/tools/set-group-kick.ts
|
|
1231
|
+
var import_zod7 = require("zod");
|
|
1232
|
+
var import_tools7 = require("@langchain/core/tools");
|
|
1233
|
+
function resolveGroupId4(session, groupId) {
|
|
1234
|
+
return groupId?.trim() || (session.guildId ? String(session.guildId).trim() : "") || (session.channelId ? String(session.channelId).trim() : "");
|
|
1235
|
+
}
|
|
1236
|
+
async function sendGroupKick(params) {
|
|
1237
|
+
try {
|
|
1238
|
+
const { session, userId, groupId, log } = params;
|
|
1239
|
+
const {
|
|
1240
|
+
error,
|
|
1241
|
+
internal,
|
|
1242
|
+
session: validatedSession
|
|
1243
|
+
} = ensureOneBotSession(session);
|
|
1244
|
+
if (error) return error;
|
|
1245
|
+
const resolvedGroupId = resolveGroupId4(validatedSession, groupId);
|
|
1246
|
+
if (!resolvedGroupId) {
|
|
1247
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1248
|
+
}
|
|
1249
|
+
const userIdRaw = userId.trim();
|
|
1250
|
+
if (!userIdRaw) return "userId is required.";
|
|
1251
|
+
await callOneBotAPI(
|
|
1252
|
+
internal,
|
|
1253
|
+
"set_group_kick",
|
|
1254
|
+
{ group_id: resolvedGroupId, user_id: userIdRaw },
|
|
1255
|
+
["setGroupKick"]
|
|
1256
|
+
);
|
|
1257
|
+
const message = `\u5DF2\u5C06\u7528\u6237 ${userIdRaw} \u79FB\u51FA\u7FA4 ${resolvedGroupId}\u3002`;
|
|
1258
|
+
log?.("info", message);
|
|
1259
|
+
return message;
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
params.log?.("warn", "set_group_kick failed", error);
|
|
1262
|
+
return `set_group_kick failed: ${error.message}`;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function createSetGroupKickTool(deps) {
|
|
1266
|
+
const { toolName, description, log } = deps;
|
|
1267
|
+
return new class extends import_tools7.StructuredTool {
|
|
1268
|
+
name = toolName || "set_group_kick";
|
|
1269
|
+
description = description || DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION;
|
|
1270
|
+
schema = import_zod7.z.object({
|
|
1271
|
+
groupId: import_zod7.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1272
|
+
userId: import_zod7.z.string().min(1, "userId is required").describe("Target member user ID.")
|
|
1273
|
+
});
|
|
1274
|
+
async _call(input, _manager, runnable) {
|
|
1275
|
+
return sendGroupKick({
|
|
1276
|
+
session: getSession(runnable),
|
|
1277
|
+
groupId: input.groupId,
|
|
1278
|
+
userId: input.userId,
|
|
1279
|
+
log
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
}();
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1168
1285
|
// src/features/native-tools/tools/set-group-special-title.ts
|
|
1169
|
-
var
|
|
1170
|
-
var
|
|
1171
|
-
function
|
|
1286
|
+
var import_zod8 = require("zod");
|
|
1287
|
+
var import_tools8 = require("@langchain/core/tools");
|
|
1288
|
+
function resolveGroupId5(session, groupId) {
|
|
1172
1289
|
return groupId?.trim() || (session.guildId || "").trim() || (session.channelId || "").trim() || (session.roomId || "").trim();
|
|
1173
1290
|
}
|
|
1174
1291
|
async function sendSetGroupSpecialTitle(params) {
|
|
@@ -1180,7 +1297,7 @@ async function sendSetGroupSpecialTitle(params) {
|
|
|
1180
1297
|
session: validatedSession
|
|
1181
1298
|
} = ensureOneBotSession(session);
|
|
1182
1299
|
if (error) return error;
|
|
1183
|
-
const resolvedGroupId =
|
|
1300
|
+
const resolvedGroupId = resolveGroupId5(validatedSession, groupId);
|
|
1184
1301
|
if (!resolvedGroupId) {
|
|
1185
1302
|
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1186
1303
|
}
|
|
@@ -1207,13 +1324,13 @@ async function sendSetGroupSpecialTitle(params) {
|
|
|
1207
1324
|
}
|
|
1208
1325
|
function createSetGroupSpecialTitleTool(deps) {
|
|
1209
1326
|
const { toolName, description, protocol, log } = deps;
|
|
1210
|
-
return new class extends
|
|
1327
|
+
return new class extends import_tools8.StructuredTool {
|
|
1211
1328
|
name = toolName || "set_group_special_title";
|
|
1212
1329
|
description = description || DEFAULT_SET_GROUP_SPECIAL_TITLE_TOOL_DESCRIPTION;
|
|
1213
|
-
schema =
|
|
1214
|
-
groupId:
|
|
1215
|
-
userId:
|
|
1216
|
-
title:
|
|
1330
|
+
schema = import_zod8.z.object({
|
|
1331
|
+
groupId: import_zod8.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1332
|
+
userId: import_zod8.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1333
|
+
title: import_zod8.z.string().describe("New special title. Use an empty string to clear it.")
|
|
1217
1334
|
});
|
|
1218
1335
|
async _call(input, _manager, runnable) {
|
|
1219
1336
|
const session = getSession(runnable);
|
|
@@ -1230,8 +1347,8 @@ function createSetGroupSpecialTitleTool(deps) {
|
|
|
1230
1347
|
}
|
|
1231
1348
|
|
|
1232
1349
|
// src/features/native-tools/tools/set-msg-emoji.ts
|
|
1233
|
-
var
|
|
1234
|
-
var
|
|
1350
|
+
var import_zod9 = require("zod");
|
|
1351
|
+
var import_tools9 = require("@langchain/core/tools");
|
|
1235
1352
|
async function sendMsgEmoji(params) {
|
|
1236
1353
|
try {
|
|
1237
1354
|
const { session, messageId, emojiId, log, protocol } = params;
|
|
@@ -1262,12 +1379,12 @@ async function sendMsgEmoji(params) {
|
|
|
1262
1379
|
}
|
|
1263
1380
|
function createSetMsgEmojiTool(deps) {
|
|
1264
1381
|
const { toolName, description, log, protocol } = deps;
|
|
1265
|
-
return new class extends
|
|
1382
|
+
return new class extends import_tools9.StructuredTool {
|
|
1266
1383
|
name = toolName || "set_msg_emoji";
|
|
1267
1384
|
description = description || DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION;
|
|
1268
|
-
schema =
|
|
1269
|
-
messageId:
|
|
1270
|
-
emojiId:
|
|
1385
|
+
schema = import_zod9.z.object({
|
|
1386
|
+
messageId: import_zod9.z.string().min(1, "message_id is required").describe("Target message ID."),
|
|
1387
|
+
emojiId: import_zod9.z.string().min(1, "emoji_id is required").describe("Emoji ID to send.")
|
|
1271
1388
|
});
|
|
1272
1389
|
async _call(input, _manager, runnable) {
|
|
1273
1390
|
const session = getSession(runnable);
|
|
@@ -1283,8 +1400,8 @@ function createSetMsgEmojiTool(deps) {
|
|
|
1283
1400
|
}
|
|
1284
1401
|
|
|
1285
1402
|
// src/features/native-tools/tools/profile.ts
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1403
|
+
var import_zod10 = require("zod");
|
|
1404
|
+
var import_tools10 = require("@langchain/core/tools");
|
|
1288
1405
|
var genders = {
|
|
1289
1406
|
unknown: "0",
|
|
1290
1407
|
male: "1",
|
|
@@ -1311,13 +1428,13 @@ async function sendSetProfile(params) {
|
|
|
1311
1428
|
}
|
|
1312
1429
|
function createSetProfileTool(deps) {
|
|
1313
1430
|
const { toolName, description, log, protocol } = deps;
|
|
1314
|
-
return new class extends
|
|
1431
|
+
return new class extends import_tools10.StructuredTool {
|
|
1315
1432
|
name = toolName || "set_self_profile";
|
|
1316
1433
|
description = description || DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION;
|
|
1317
|
-
schema =
|
|
1318
|
-
nickname:
|
|
1319
|
-
signature:
|
|
1320
|
-
gender:
|
|
1434
|
+
schema = import_zod10.z.object({
|
|
1435
|
+
nickname: import_zod10.z.string().min(1, "nickname is required").describe("The new nickname for the bot."),
|
|
1436
|
+
signature: import_zod10.z.string().optional().describe("Optional: the new personal signature."),
|
|
1437
|
+
gender: import_zod10.z.enum(["unknown", "male", "female"]).optional().describe("Optional: the new gender.")
|
|
1321
1438
|
});
|
|
1322
1439
|
async _call(input, _manager, runnable) {
|
|
1323
1440
|
return sendSetProfile({
|
|
@@ -1333,8 +1450,8 @@ function createSetProfileTool(deps) {
|
|
|
1333
1450
|
}
|
|
1334
1451
|
|
|
1335
1452
|
// src/features/native-tools/tools/set-qq-avatar.ts
|
|
1336
|
-
var
|
|
1337
|
-
var
|
|
1453
|
+
var import_zod11 = require("zod");
|
|
1454
|
+
var import_tools11 = require("@langchain/core/tools");
|
|
1338
1455
|
function isHttpUrl(value) {
|
|
1339
1456
|
return /^https?:\/\//i.test(value);
|
|
1340
1457
|
}
|
|
@@ -1393,11 +1510,11 @@ async function sendSetQQAvatar(params) {
|
|
|
1393
1510
|
}
|
|
1394
1511
|
function createSetQQAvatarTool(deps) {
|
|
1395
1512
|
const { ctx, toolName, description, log } = deps;
|
|
1396
|
-
return new class extends
|
|
1513
|
+
return new class extends import_tools11.StructuredTool {
|
|
1397
1514
|
name = toolName || "set_qq_avatar";
|
|
1398
1515
|
description = description || DEFAULT_SET_QQ_AVATAR_TOOL_DESCRIPTION;
|
|
1399
|
-
schema =
|
|
1400
|
-
imageUrl:
|
|
1516
|
+
schema = import_zod11.z.object({
|
|
1517
|
+
imageUrl: import_zod11.z.string().min(1, "imageUrl is required").describe("Image URL or local file path readable by the OneBot side.")
|
|
1401
1518
|
});
|
|
1402
1519
|
async _call(input, _manager, runnable) {
|
|
1403
1520
|
return sendSetQQAvatar({
|
|
@@ -1549,6 +1666,42 @@ function registerNativeTools(deps) {
|
|
|
1549
1666
|
});
|
|
1550
1667
|
log?.("info", `\u7FA4\u6210\u5458\u7981\u8A00\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1551
1668
|
}
|
|
1669
|
+
if (isNativeToolEnabled(config, "leaveGroup")) {
|
|
1670
|
+
const toolName = resolveToolName(
|
|
1671
|
+
config.leaveGroup.toolName,
|
|
1672
|
+
"set_group_leave"
|
|
1673
|
+
);
|
|
1674
|
+
const description = resolveToolDescription(
|
|
1675
|
+
config.leaveGroup.description,
|
|
1676
|
+
DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION
|
|
1677
|
+
);
|
|
1678
|
+
plugin.registerTool(toolName, {
|
|
1679
|
+
selector: () => true,
|
|
1680
|
+
authorization: (session) => session?.platform === "onebot",
|
|
1681
|
+
description,
|
|
1682
|
+
createTool: () => createLeaveGroupTool({ toolName, description, log }),
|
|
1683
|
+
meta: createNativeToolMeta("onebot", ["group"])
|
|
1684
|
+
});
|
|
1685
|
+
log?.("info", `\u9000\u7FA4\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1686
|
+
}
|
|
1687
|
+
if (isNativeToolEnabled(config, "setGroupKick")) {
|
|
1688
|
+
const toolName = resolveToolName(
|
|
1689
|
+
config.setGroupKick.toolName,
|
|
1690
|
+
"set_group_kick"
|
|
1691
|
+
);
|
|
1692
|
+
const description = resolveToolDescription(
|
|
1693
|
+
config.setGroupKick.description,
|
|
1694
|
+
DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION
|
|
1695
|
+
);
|
|
1696
|
+
plugin.registerTool(toolName, {
|
|
1697
|
+
selector: () => true,
|
|
1698
|
+
authorization: (session) => session?.platform === "onebot",
|
|
1699
|
+
description,
|
|
1700
|
+
createTool: () => createSetGroupKickTool({ toolName, description, log }),
|
|
1701
|
+
meta: createNativeToolMeta("onebot", ["group"])
|
|
1702
|
+
});
|
|
1703
|
+
log?.("info", `\u8E22\u51FA\u7FA4\u6210\u5458\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1704
|
+
}
|
|
1552
1705
|
if (isNativeToolEnabled(config, "setGroupSpecialTitle")) {
|
|
1553
1706
|
const toolName = resolveToolName(
|
|
1554
1707
|
config.setGroupSpecialTitle.toolName,
|
|
@@ -3024,12 +3177,14 @@ Character XML \u5DE5\u5177\u4EC5\u4F9B [koishi-plugin-chatluna-character](https:
|
|
|
3024
3177
|
createDeleteMessageTool,
|
|
3025
3178
|
createGroupInfoProvider,
|
|
3026
3179
|
createGroupShutListProvider,
|
|
3180
|
+
createLeaveGroupTool,
|
|
3027
3181
|
createLogger,
|
|
3028
3182
|
createPokeTool,
|
|
3029
3183
|
createRandomProvider,
|
|
3030
3184
|
createSearchGroupMemberTool,
|
|
3031
3185
|
createSetGroupBanTool,
|
|
3032
3186
|
createSetGroupCardTool,
|
|
3187
|
+
createSetGroupKickTool,
|
|
3033
3188
|
createSetGroupSpecialTitleTool,
|
|
3034
3189
|
createSetMsgEmojiTool,
|
|
3035
3190
|
createSetProfileTool,
|
|
@@ -3050,6 +3205,8 @@ Character XML \u5DE5\u5177\u4EC5\u4F9B [koishi-plugin-chatluna-character](https:
|
|
|
3050
3205
|
searchGroupMember,
|
|
3051
3206
|
sendDeleteMessage,
|
|
3052
3207
|
sendGroupBan,
|
|
3208
|
+
sendGroupKick,
|
|
3209
|
+
sendLeaveGroup,
|
|
3053
3210
|
sendMsgEmoji,
|
|
3054
3211
|
sendPoke,
|
|
3055
3212
|
sendSetGroupCard,
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-toolbox",
|
|
3
3
|
"description": "为 ChatLuna 提供更多原生工具、Character XML 工具与变量,仅支持 onebot 平台。",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.21",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
|
-
"dist"
|
|
10
|
-
"client"
|
|
9
|
+
"dist"
|
|
11
10
|
],
|
|
12
11
|
"license": "MIT",
|
|
13
12
|
"homepage": "https://github.com/Sor85/AAAAACAT-chatluna-plugins",
|
|
@@ -50,12 +49,12 @@
|
|
|
50
49
|
"@types/node": "^22.10.1",
|
|
51
50
|
"@vitejs/plugin-vue": "^6.0.2",
|
|
52
51
|
"sass": "^1.77.0",
|
|
53
|
-
"shared-chatluna-xmltools": "
|
|
54
|
-
"shared-nav": "
|
|
52
|
+
"shared-chatluna-xmltools": "workspace:*",
|
|
53
|
+
"shared-nav": "workspace:*",
|
|
55
54
|
"tsup": "^8.0.0",
|
|
56
55
|
"typescript": "^5.7.2",
|
|
57
56
|
"vite": "^6.0.0",
|
|
58
57
|
"vitest": "^3.2.4",
|
|
59
58
|
"vue": "^3.5.21"
|
|
60
59
|
}
|
|
61
|
-
}
|
|
60
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Toolbox 详情加载器
|
|
3
|
-
根据当前插件名称决定是否显示共享导航组件
|
|
4
|
-
-->
|
|
5
|
-
<template>
|
|
6
|
-
<SharedNav v-if="isOwn" :sections="navSections" />
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { ComputedRef, computed, inject } from "vue";
|
|
11
|
-
import { SharedNav } from "shared-nav";
|
|
12
|
-
import { NAV_SECTIONS, PLUGIN_CANDIDATE_NAMES } from "./constants";
|
|
13
|
-
|
|
14
|
-
const pluginName = inject<ComputedRef<string>>("plugin:name");
|
|
15
|
-
const navSections = NAV_SECTIONS;
|
|
16
|
-
const isOwn = computed(() => {
|
|
17
|
-
const name = pluginName?.value || "";
|
|
18
|
-
return PLUGIN_CANDIDATE_NAMES.includes(name);
|
|
19
|
-
});
|
|
20
|
-
</script>
|
package/client/constants.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 前端常量定义
|
|
3
|
-
* 包含导航分组和插件候选名称
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { SharedNavSection } from "shared-nav";
|
|
7
|
-
|
|
8
|
-
export const NAV_SECTIONS: SharedNavSection[] = [
|
|
9
|
-
{ title: "基础设置", key: "basic" },
|
|
10
|
-
{ title: "原生工具", key: "nativeTools" },
|
|
11
|
-
{ title: "Character XML 工具", key: "xmlTools" },
|
|
12
|
-
{ title: "变量", key: "variables" },
|
|
13
|
-
{ title: "其他设置", key: "other" },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export const PLUGIN_CANDIDATE_NAMES = [
|
|
17
|
-
"chatluna-toolbox",
|
|
18
|
-
"koishi-plugin-chatluna-toolbox",
|
|
19
|
-
];
|
package/client/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 前端入口
|
|
3
|
-
* 注册 Koishi 控制台插件详情扩展
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Context } from "@koishijs/client";
|
|
7
|
-
import ToolboxDetailsLoader from "./ToolboxDetailsLoader.vue";
|
|
8
|
-
|
|
9
|
-
export default (ctx: Context) => {
|
|
10
|
-
ctx.slot({
|
|
11
|
-
type: "plugin-details",
|
|
12
|
-
component: ToolboxDetailsLoader,
|
|
13
|
-
order: -999,
|
|
14
|
-
});
|
|
15
|
-
};
|