koishi-plugin-chatluna-toolbox 0.0.18 → 0.0.20
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/lib/index.js +386 -68
- package/package.json +2 -3
- package/client/ToolboxDetailsLoader.vue +0 -20
- package/client/constants.ts +0 -19
- package/client/index.ts +0 -15
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -418,11 +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,
|
|
425
|
+
createSearchGroupMemberTool: () => createSearchGroupMemberTool,
|
|
424
426
|
createSetGroupBanTool: () => createSetGroupBanTool,
|
|
425
427
|
createSetGroupCardTool: () => createSetGroupCardTool,
|
|
428
|
+
createSetGroupKickTool: () => createSetGroupKickTool,
|
|
426
429
|
createSetGroupSpecialTitleTool: () => createSetGroupSpecialTitleTool,
|
|
427
430
|
createSetMsgEmojiTool: () => createSetMsgEmojiTool,
|
|
428
431
|
createSetProfileTool: () => createSetProfileTool,
|
|
@@ -440,8 +443,11 @@ __export(index_exports, {
|
|
|
440
443
|
registerVariables: () => registerVariables,
|
|
441
444
|
registerXmlTools: () => registerXmlTools,
|
|
442
445
|
resolveOneBotProtocol: () => resolveOneBotProtocol,
|
|
446
|
+
searchGroupMember: () => searchGroupMember,
|
|
443
447
|
sendDeleteMessage: () => sendDeleteMessage,
|
|
444
448
|
sendGroupBan: () => sendGroupBan,
|
|
449
|
+
sendGroupKick: () => sendGroupKick,
|
|
450
|
+
sendLeaveGroup: () => sendLeaveGroup,
|
|
445
451
|
sendMsgEmoji: () => sendMsgEmoji,
|
|
446
452
|
sendPoke: () => sendPoke,
|
|
447
453
|
sendSetGroupCard: () => sendSetGroupCard,
|
|
@@ -472,7 +478,10 @@ var DEFAULT_POKE_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u7528\u6237\u6267\u884C\
|
|
|
472
478
|
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";
|
|
473
479
|
var DEFAULT_SET_QQ_AVATAR_TOOL_DESCRIPTION = "\u4FEE\u6539\u673A\u5668\u4EBA QQ \u5934\u50CF\u3002\u63D0\u4F9B imageUrl\uFF1BHTTP/HTTPS \u56FE\u7247\u4F1A\u5148\u7531 Koishi \u8BFB\u53D6\u5E76\u8F6C\u4E3A OneBot base64 \u6587\u4EF6\uFF0C\u907F\u514D\u4E34\u65F6 URL \u8FC7\u671F\u6216 OneBot \u7AEF\u65E0\u6CD5\u8BBF\u95EE\u3002";
|
|
474
480
|
var DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION = "\u4FEE\u6539\u7FA4\u6210\u5458\u7684\u7FA4\u6635\u79F0\u3002";
|
|
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";
|
|
475
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";
|
|
476
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";
|
|
477
486
|
var DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\u56DE\u5E94\u3002";
|
|
478
487
|
var DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION = "\u6839\u636E\u6D88\u606F ID \u64A4\u56DE\u6307\u5B9A\u6D88\u606F\u3002";
|
|
@@ -484,7 +493,10 @@ var EnabledNativeToolsSchema = import_koishi2.Schema.array(
|
|
|
484
493
|
import_koishi2.Schema.const("setSelfProfile").description("\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F"),
|
|
485
494
|
import_koishi2.Schema.const("setQQAvatar").description("\u4FEE\u6539 QQ \u5934\u50CF"),
|
|
486
495
|
import_koishi2.Schema.const("setGroupCard").description("\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0"),
|
|
496
|
+
import_koishi2.Schema.const("searchGroupMember").description("\u641C\u7D22\u7FA4\u6210\u5458"),
|
|
487
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"),
|
|
488
500
|
import_koishi2.Schema.const("setGroupSpecialTitle").description("\u4FEE\u6539\u7FA4\u6210\u5458\u4E13\u5C5E\u5934\u8854"),
|
|
489
501
|
import_koishi2.Schema.const("setMsgEmoji").description("\u6D88\u606F\u8868\u60C5"),
|
|
490
502
|
import_koishi2.Schema.const("deleteMessage").description("\u64A4\u56DE\u6D88\u606F")
|
|
@@ -513,11 +525,26 @@ var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
|
|
|
513
525
|
toolName: import_koishi2.Schema.string().default("set_group_card").description("\u5DE5\u5177\u540D\u79F0"),
|
|
514
526
|
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
515
527
|
}).description("\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0\u5DE5\u5177").collapse(),
|
|
528
|
+
searchGroupMember: import_koishi2.Schema.object({
|
|
529
|
+
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
530
|
+
toolName: import_koishi2.Schema.string().default("search_group_member").description("\u5DE5\u5177\u540D\u79F0"),
|
|
531
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SEARCH_GROUP_MEMBER_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
532
|
+
}).description("\u641C\u7D22\u7FA4\u6210\u5458\u5DE5\u5177").collapse(),
|
|
516
533
|
setGroupBan: import_koishi2.Schema.object({
|
|
517
534
|
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
518
535
|
toolName: import_koishi2.Schema.string().default("set_group_ban").description("\u5DE5\u5177\u540D\u79F0"),
|
|
519
536
|
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
520
537
|
}).description("\u7981\u8A00\u5DE5\u5177").collapse(),
|
|
538
|
+
leaveGroup: import_koishi2.Schema.object({
|
|
539
|
+
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
540
|
+
toolName: import_koishi2.Schema.string().default("set_group_leave").description("\u5DE5\u5177\u540D\u79F0"),
|
|
541
|
+
description: import_koishi2.Schema.string().default(DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
542
|
+
}).description("\u9000\u7FA4\u5DE5\u5177").collapse(),
|
|
543
|
+
setGroupKick: import_koishi2.Schema.object({
|
|
544
|
+
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
545
|
+
toolName: import_koishi2.Schema.string().default("set_group_kick").description("\u5DE5\u5177\u540D\u79F0"),
|
|
546
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
547
|
+
}).description("\u8E22\u51FA\u7FA4\u6210\u5458\u5DE5\u5177").collapse(),
|
|
521
548
|
setGroupSpecialTitle: import_koishi2.Schema.object({
|
|
522
549
|
enabled: import_koishi2.Schema.boolean().default(false).hidden(),
|
|
523
550
|
toolName: import_koishi2.Schema.string().default("set_group_special_title").description("\u5DE5\u5177\u540D\u79F0"),
|
|
@@ -835,9 +862,60 @@ function createDeleteMessageTool(deps) {
|
|
|
835
862
|
}();
|
|
836
863
|
}
|
|
837
864
|
|
|
838
|
-
// src/features/native-tools/tools/
|
|
865
|
+
// src/features/native-tools/tools/leave-group.ts
|
|
839
866
|
var import_zod2 = require("zod");
|
|
840
867
|
var import_tools2 = require("@langchain/core/tools");
|
|
868
|
+
function resolveGroupId(session, groupId) {
|
|
869
|
+
return groupId?.trim() || (session.guildId ? String(session.guildId).trim() : "") || (session.channelId ? String(session.channelId).trim() : "");
|
|
870
|
+
}
|
|
871
|
+
async function sendLeaveGroup(params) {
|
|
872
|
+
try {
|
|
873
|
+
const { session, groupId, log } = params;
|
|
874
|
+
const {
|
|
875
|
+
error,
|
|
876
|
+
internal,
|
|
877
|
+
session: validatedSession
|
|
878
|
+
} = ensureOneBotSession(session);
|
|
879
|
+
if (error) return error;
|
|
880
|
+
const resolvedGroupId = resolveGroupId(validatedSession, groupId);
|
|
881
|
+
if (!resolvedGroupId) {
|
|
882
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
883
|
+
}
|
|
884
|
+
await callOneBotAPI(
|
|
885
|
+
internal,
|
|
886
|
+
"set_group_leave",
|
|
887
|
+
{ group_id: resolvedGroupId },
|
|
888
|
+
["setGroupLeave"]
|
|
889
|
+
);
|
|
890
|
+
const message = `\u5DF2\u9000\u51FA\u7FA4 ${resolvedGroupId}\u3002`;
|
|
891
|
+
log?.("info", message);
|
|
892
|
+
return message;
|
|
893
|
+
} catch (error) {
|
|
894
|
+
params.log?.("warn", "set_group_leave failed", error);
|
|
895
|
+
return `set_group_leave failed: ${error.message}`;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
function createLeaveGroupTool(deps) {
|
|
899
|
+
const { toolName, description, log } = deps;
|
|
900
|
+
return new class extends import_tools2.StructuredTool {
|
|
901
|
+
name = toolName || "set_group_leave";
|
|
902
|
+
description = description || DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION;
|
|
903
|
+
schema = import_zod2.z.object({
|
|
904
|
+
groupId: import_zod2.z.string().optional().describe("Target group ID. Defaults to current session group.")
|
|
905
|
+
});
|
|
906
|
+
async _call(input, _manager, runnable) {
|
|
907
|
+
return sendLeaveGroup({
|
|
908
|
+
session: getSession(runnable),
|
|
909
|
+
groupId: input.groupId,
|
|
910
|
+
log
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
}();
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// src/features/native-tools/tools/poke.ts
|
|
917
|
+
var import_zod3 = require("zod");
|
|
918
|
+
var import_tools3 = require("@langchain/core/tools");
|
|
841
919
|
async function sendPoke(params) {
|
|
842
920
|
try {
|
|
843
921
|
const { session, userId, groupId, log, protocol } = params;
|
|
@@ -884,12 +962,12 @@ async function sendPoke(params) {
|
|
|
884
962
|
}
|
|
885
963
|
function createPokeTool(deps) {
|
|
886
964
|
const { toolName, description, log, protocol } = deps;
|
|
887
|
-
return new class extends
|
|
965
|
+
return new class extends import_tools3.StructuredTool {
|
|
888
966
|
name = toolName || "poke_user";
|
|
889
967
|
description = description || DEFAULT_POKE_TOOL_DESCRIPTION;
|
|
890
|
-
schema =
|
|
891
|
-
userId:
|
|
892
|
-
groupId:
|
|
968
|
+
schema = import_zod3.z.object({
|
|
969
|
+
userId: import_zod3.z.string().min(1, "userId is required").describe("The user ID to poke."),
|
|
970
|
+
groupId: import_zod3.z.string().optional().describe("Optional: specify a different group ID.")
|
|
893
971
|
});
|
|
894
972
|
async _call(input, _manager, runnable) {
|
|
895
973
|
const session = getSession(runnable);
|
|
@@ -904,10 +982,135 @@ function createPokeTool(deps) {
|
|
|
904
982
|
}();
|
|
905
983
|
}
|
|
906
984
|
|
|
985
|
+
// src/features/native-tools/tools/search-group-member.ts
|
|
986
|
+
var import_zod4 = require("zod");
|
|
987
|
+
var import_tools4 = require("@langchain/core/tools");
|
|
988
|
+
var MAX_RESULTS = 10;
|
|
989
|
+
function pickFirst(...values) {
|
|
990
|
+
for (const value of values) {
|
|
991
|
+
if (value === null || value === void 0) continue;
|
|
992
|
+
const text = String(value).trim();
|
|
993
|
+
if (text) return text;
|
|
994
|
+
}
|
|
995
|
+
return "";
|
|
996
|
+
}
|
|
997
|
+
function resolveGroupId2(session, groupId) {
|
|
998
|
+
return groupId?.trim() || session.guildId?.trim() || (session.event?.guild?.id || "");
|
|
999
|
+
}
|
|
1000
|
+
function normalizeId(value) {
|
|
1001
|
+
return /^\d+$/.test(value) ? Number(value) : value;
|
|
1002
|
+
}
|
|
1003
|
+
function getUserId(member) {
|
|
1004
|
+
return pickFirst(
|
|
1005
|
+
member.user_id,
|
|
1006
|
+
member.userId,
|
|
1007
|
+
member.id,
|
|
1008
|
+
member.qq,
|
|
1009
|
+
member.uid
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
function getGroupCard(member) {
|
|
1013
|
+
return pickFirst(member.card, member.remark, member.displayName);
|
|
1014
|
+
}
|
|
1015
|
+
function getNickname(member) {
|
|
1016
|
+
return pickFirst(
|
|
1017
|
+
member.nick,
|
|
1018
|
+
member.nickname,
|
|
1019
|
+
member.name,
|
|
1020
|
+
member.user?.nickname,
|
|
1021
|
+
member.user?.name
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function matchByName(member, query) {
|
|
1025
|
+
const keyword = query.toLowerCase();
|
|
1026
|
+
return [getGroupCard(member), getNickname(member)].filter(Boolean).some((value) => value.toLowerCase().includes(keyword));
|
|
1027
|
+
}
|
|
1028
|
+
async function fetchGroupMembers(session, groupId) {
|
|
1029
|
+
const internal = session.bot.internal;
|
|
1030
|
+
if (!internal) return [];
|
|
1031
|
+
if (typeof internal.getGroupMemberList === "function") {
|
|
1032
|
+
const result = await internal.getGroupMemberList(normalizeId(groupId));
|
|
1033
|
+
return Array.isArray(result) ? result : [];
|
|
1034
|
+
}
|
|
1035
|
+
if (typeof internal._request === "function") {
|
|
1036
|
+
const result = await internal._request("get_group_member_list", {
|
|
1037
|
+
group_id: normalizeId(groupId)
|
|
1038
|
+
});
|
|
1039
|
+
if (Array.isArray(result)) return result;
|
|
1040
|
+
const data = result?.data;
|
|
1041
|
+
return Array.isArray(data) ? data : [];
|
|
1042
|
+
}
|
|
1043
|
+
throw new Error("\u5F53\u524D OneBot \u9002\u914D\u5668\u4E0D\u652F\u6301 get_group_member_list \u63A5\u53E3\u3002");
|
|
1044
|
+
}
|
|
1045
|
+
function formatMember(index, member) {
|
|
1046
|
+
const userId = getUserId(member) || "\u672A\u77E5";
|
|
1047
|
+
const groupCard = getGroupCard(member) || "\u65E0";
|
|
1048
|
+
const nickname = getNickname(member) || "\u65E0";
|
|
1049
|
+
return `${index}. qqid\uFF1A${userId}\uFF0C\u7FA4\u6635\u79F0\uFF1A${groupCard}\uFF0CQQ\u6635\u79F0\uFF1A${nickname}`;
|
|
1050
|
+
}
|
|
1051
|
+
async function searchGroupMember(params) {
|
|
1052
|
+
try {
|
|
1053
|
+
const { session, query, groupId, log } = params;
|
|
1054
|
+
const mode = params.mode || "auto";
|
|
1055
|
+
if (!["auto", "byName", "byQQ"].includes(mode)) {
|
|
1056
|
+
return "mode must be auto, byName, or byQQ.";
|
|
1057
|
+
}
|
|
1058
|
+
const queryText = query.trim();
|
|
1059
|
+
if (!queryText) return "query is required.";
|
|
1060
|
+
const {
|
|
1061
|
+
error,
|
|
1062
|
+
session: validatedSession
|
|
1063
|
+
} = ensureOneBotSession(session);
|
|
1064
|
+
if (error) return error;
|
|
1065
|
+
const resolvedGroupId = resolveGroupId2(validatedSession, groupId);
|
|
1066
|
+
if (!resolvedGroupId) {
|
|
1067
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1068
|
+
}
|
|
1069
|
+
const members = await fetchGroupMembers(validatedSession, resolvedGroupId);
|
|
1070
|
+
const shouldSearchQQ = mode === "byQQ" || mode === "auto" && /^\d+$/.test(queryText);
|
|
1071
|
+
const matches = members.filter(
|
|
1072
|
+
(member) => shouldSearchQQ ? getUserId(member) === queryText : matchByName(member, queryText)
|
|
1073
|
+
);
|
|
1074
|
+
if (matches.length === 0) return "\u672A\u627E\u5230\u5339\u914D\u7684\u7FA4\u6210\u5458\u3002";
|
|
1075
|
+
const visibleMatches = matches.slice(0, MAX_RESULTS);
|
|
1076
|
+
const header = matches.length > MAX_RESULTS ? `\u4EC5\u663E\u793A\u524D ${MAX_RESULTS} \u6761\uFF0C\u5171 ${matches.length} \u6761\u5339\u914D\uFF1A` : `\u627E\u5230 ${matches.length} \u4E2A\u5339\u914D\u6210\u5458\uFF1A`;
|
|
1077
|
+
const message = [
|
|
1078
|
+
header,
|
|
1079
|
+
...visibleMatches.map((member, index) => formatMember(index + 1, member))
|
|
1080
|
+
].join("\n");
|
|
1081
|
+
log?.("info", `\u7FA4 ${resolvedGroupId} \u6210\u5458\u641C\u7D22\u5B8C\u6210\uFF1A${matches.length} \u6761\u5339\u914D`);
|
|
1082
|
+
return message;
|
|
1083
|
+
} catch (error) {
|
|
1084
|
+
params.log?.("warn", "search_group_member failed", error);
|
|
1085
|
+
return `search_group_member failed: ${error.message}`;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function createSearchGroupMemberTool(deps) {
|
|
1089
|
+
const { toolName, description, log } = deps;
|
|
1090
|
+
return new class extends import_tools4.StructuredTool {
|
|
1091
|
+
name = toolName || "search_group_member";
|
|
1092
|
+
description = description || DEFAULT_SEARCH_GROUP_MEMBER_TOOL_DESCRIPTION;
|
|
1093
|
+
schema = import_zod4.z.object({
|
|
1094
|
+
groupId: import_zod4.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1095
|
+
query: import_zod4.z.string().min(1, "query is required").describe("qqid, group card, or QQ nickname to search."),
|
|
1096
|
+
mode: import_zod4.z.enum(["auto", "byName", "byQQ"]).optional().describe("Search mode. Defaults to auto.")
|
|
1097
|
+
});
|
|
1098
|
+
async _call(input, _manager, runnable) {
|
|
1099
|
+
return searchGroupMember({
|
|
1100
|
+
session: getSession(runnable),
|
|
1101
|
+
groupId: input.groupId,
|
|
1102
|
+
query: input.query,
|
|
1103
|
+
mode: input.mode,
|
|
1104
|
+
log
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
}();
|
|
1108
|
+
}
|
|
1109
|
+
|
|
907
1110
|
// src/features/native-tools/tools/set-group-ban.ts
|
|
908
|
-
var
|
|
909
|
-
var
|
|
910
|
-
function
|
|
1111
|
+
var import_zod5 = require("zod");
|
|
1112
|
+
var import_tools5 = require("@langchain/core/tools");
|
|
1113
|
+
function resolveGroupId3(session, groupId) {
|
|
911
1114
|
return groupId?.trim() || (session.guildId || "").trim() || (session.channelId || "").trim() || (session.roomId || "").trim();
|
|
912
1115
|
}
|
|
913
1116
|
function parseDuration(duration) {
|
|
@@ -926,7 +1129,7 @@ async function sendGroupBan(params) {
|
|
|
926
1129
|
session: validatedSession
|
|
927
1130
|
} = ensureOneBotSession(session);
|
|
928
1131
|
if (error) return error;
|
|
929
|
-
const resolvedGroupId =
|
|
1132
|
+
const resolvedGroupId = resolveGroupId3(validatedSession, groupId);
|
|
930
1133
|
if (!resolvedGroupId) {
|
|
931
1134
|
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
932
1135
|
}
|
|
@@ -956,13 +1159,13 @@ async function sendGroupBan(params) {
|
|
|
956
1159
|
}
|
|
957
1160
|
function createSetGroupBanTool(deps) {
|
|
958
1161
|
const { toolName, description, protocol, log } = deps;
|
|
959
|
-
return new class extends
|
|
1162
|
+
return new class extends import_tools5.StructuredTool {
|
|
960
1163
|
name = toolName || "set_group_ban";
|
|
961
1164
|
description = description || DEFAULT_SET_GROUP_BAN_TOOL_DESCRIPTION;
|
|
962
|
-
schema =
|
|
963
|
-
groupId:
|
|
964
|
-
userId:
|
|
965
|
-
duration:
|
|
1165
|
+
schema = import_zod5.z.object({
|
|
1166
|
+
groupId: import_zod5.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1167
|
+
userId: import_zod5.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1168
|
+
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.")
|
|
966
1169
|
});
|
|
967
1170
|
async _call(input, _manager, runnable) {
|
|
968
1171
|
const session = getSession(runnable);
|
|
@@ -979,8 +1182,8 @@ function createSetGroupBanTool(deps) {
|
|
|
979
1182
|
}
|
|
980
1183
|
|
|
981
1184
|
// src/features/native-tools/tools/set-group-card.ts
|
|
982
|
-
var
|
|
983
|
-
var
|
|
1185
|
+
var import_zod6 = require("zod");
|
|
1186
|
+
var import_tools6 = require("@langchain/core/tools");
|
|
984
1187
|
async function sendSetGroupCard(params) {
|
|
985
1188
|
try {
|
|
986
1189
|
const { session, userId, card, groupId, log } = params;
|
|
@@ -1011,13 +1214,13 @@ async function sendSetGroupCard(params) {
|
|
|
1011
1214
|
}
|
|
1012
1215
|
function createSetGroupCardTool(deps) {
|
|
1013
1216
|
const { toolName, description, log } = deps;
|
|
1014
|
-
return new class extends
|
|
1217
|
+
return new class extends import_tools6.StructuredTool {
|
|
1015
1218
|
name = toolName || "set_group_card";
|
|
1016
1219
|
description = description || DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION;
|
|
1017
|
-
schema =
|
|
1018
|
-
groupId:
|
|
1019
|
-
userId:
|
|
1020
|
-
card:
|
|
1220
|
+
schema = import_zod6.z.object({
|
|
1221
|
+
groupId: import_zod6.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1222
|
+
userId: import_zod6.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1223
|
+
card: import_zod6.z.string().min(1, "card is required").describe("New group card for the member.")
|
|
1021
1224
|
});
|
|
1022
1225
|
async _call(input, _manager, runnable) {
|
|
1023
1226
|
return sendSetGroupCard({
|
|
@@ -1031,10 +1234,65 @@ function createSetGroupCardTool(deps) {
|
|
|
1031
1234
|
}();
|
|
1032
1235
|
}
|
|
1033
1236
|
|
|
1237
|
+
// src/features/native-tools/tools/set-group-kick.ts
|
|
1238
|
+
var import_zod7 = require("zod");
|
|
1239
|
+
var import_tools7 = require("@langchain/core/tools");
|
|
1240
|
+
function resolveGroupId4(session, groupId) {
|
|
1241
|
+
return groupId?.trim() || (session.guildId ? String(session.guildId).trim() : "") || (session.channelId ? String(session.channelId).trim() : "");
|
|
1242
|
+
}
|
|
1243
|
+
async function sendGroupKick(params) {
|
|
1244
|
+
try {
|
|
1245
|
+
const { session, userId, groupId, log } = params;
|
|
1246
|
+
const {
|
|
1247
|
+
error,
|
|
1248
|
+
internal,
|
|
1249
|
+
session: validatedSession
|
|
1250
|
+
} = ensureOneBotSession(session);
|
|
1251
|
+
if (error) return error;
|
|
1252
|
+
const resolvedGroupId = resolveGroupId4(validatedSession, groupId);
|
|
1253
|
+
if (!resolvedGroupId) {
|
|
1254
|
+
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1255
|
+
}
|
|
1256
|
+
const userIdRaw = userId.trim();
|
|
1257
|
+
if (!userIdRaw) return "userId is required.";
|
|
1258
|
+
await callOneBotAPI(
|
|
1259
|
+
internal,
|
|
1260
|
+
"set_group_kick",
|
|
1261
|
+
{ group_id: resolvedGroupId, user_id: userIdRaw },
|
|
1262
|
+
["setGroupKick"]
|
|
1263
|
+
);
|
|
1264
|
+
const message = `\u5DF2\u5C06\u7528\u6237 ${userIdRaw} \u79FB\u51FA\u7FA4 ${resolvedGroupId}\u3002`;
|
|
1265
|
+
log?.("info", message);
|
|
1266
|
+
return message;
|
|
1267
|
+
} catch (error) {
|
|
1268
|
+
params.log?.("warn", "set_group_kick failed", error);
|
|
1269
|
+
return `set_group_kick failed: ${error.message}`;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function createSetGroupKickTool(deps) {
|
|
1273
|
+
const { toolName, description, log } = deps;
|
|
1274
|
+
return new class extends import_tools7.StructuredTool {
|
|
1275
|
+
name = toolName || "set_group_kick";
|
|
1276
|
+
description = description || DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION;
|
|
1277
|
+
schema = import_zod7.z.object({
|
|
1278
|
+
groupId: import_zod7.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1279
|
+
userId: import_zod7.z.string().min(1, "userId is required").describe("Target member user ID.")
|
|
1280
|
+
});
|
|
1281
|
+
async _call(input, _manager, runnable) {
|
|
1282
|
+
return sendGroupKick({
|
|
1283
|
+
session: getSession(runnable),
|
|
1284
|
+
groupId: input.groupId,
|
|
1285
|
+
userId: input.userId,
|
|
1286
|
+
log
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
}();
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1034
1292
|
// src/features/native-tools/tools/set-group-special-title.ts
|
|
1035
|
-
var
|
|
1036
|
-
var
|
|
1037
|
-
function
|
|
1293
|
+
var import_zod8 = require("zod");
|
|
1294
|
+
var import_tools8 = require("@langchain/core/tools");
|
|
1295
|
+
function resolveGroupId5(session, groupId) {
|
|
1038
1296
|
return groupId?.trim() || (session.guildId || "").trim() || (session.channelId || "").trim() || (session.roomId || "").trim();
|
|
1039
1297
|
}
|
|
1040
1298
|
async function sendSetGroupSpecialTitle(params) {
|
|
@@ -1046,7 +1304,7 @@ async function sendSetGroupSpecialTitle(params) {
|
|
|
1046
1304
|
session: validatedSession
|
|
1047
1305
|
} = ensureOneBotSession(session);
|
|
1048
1306
|
if (error) return error;
|
|
1049
|
-
const resolvedGroupId =
|
|
1307
|
+
const resolvedGroupId = resolveGroupId5(validatedSession, groupId);
|
|
1050
1308
|
if (!resolvedGroupId) {
|
|
1051
1309
|
return "Missing groupId. Provide groupId explicitly or run inside a group session.";
|
|
1052
1310
|
}
|
|
@@ -1073,13 +1331,13 @@ async function sendSetGroupSpecialTitle(params) {
|
|
|
1073
1331
|
}
|
|
1074
1332
|
function createSetGroupSpecialTitleTool(deps) {
|
|
1075
1333
|
const { toolName, description, protocol, log } = deps;
|
|
1076
|
-
return new class extends
|
|
1334
|
+
return new class extends import_tools8.StructuredTool {
|
|
1077
1335
|
name = toolName || "set_group_special_title";
|
|
1078
1336
|
description = description || DEFAULT_SET_GROUP_SPECIAL_TITLE_TOOL_DESCRIPTION;
|
|
1079
|
-
schema =
|
|
1080
|
-
groupId:
|
|
1081
|
-
userId:
|
|
1082
|
-
title:
|
|
1337
|
+
schema = import_zod8.z.object({
|
|
1338
|
+
groupId: import_zod8.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
1339
|
+
userId: import_zod8.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
1340
|
+
title: import_zod8.z.string().describe("New special title. Use an empty string to clear it.")
|
|
1083
1341
|
});
|
|
1084
1342
|
async _call(input, _manager, runnable) {
|
|
1085
1343
|
const session = getSession(runnable);
|
|
@@ -1096,8 +1354,8 @@ function createSetGroupSpecialTitleTool(deps) {
|
|
|
1096
1354
|
}
|
|
1097
1355
|
|
|
1098
1356
|
// src/features/native-tools/tools/set-msg-emoji.ts
|
|
1099
|
-
var
|
|
1100
|
-
var
|
|
1357
|
+
var import_zod9 = require("zod");
|
|
1358
|
+
var import_tools9 = require("@langchain/core/tools");
|
|
1101
1359
|
async function sendMsgEmoji(params) {
|
|
1102
1360
|
try {
|
|
1103
1361
|
const { session, messageId, emojiId, log, protocol } = params;
|
|
@@ -1128,12 +1386,12 @@ async function sendMsgEmoji(params) {
|
|
|
1128
1386
|
}
|
|
1129
1387
|
function createSetMsgEmojiTool(deps) {
|
|
1130
1388
|
const { toolName, description, log, protocol } = deps;
|
|
1131
|
-
return new class extends
|
|
1389
|
+
return new class extends import_tools9.StructuredTool {
|
|
1132
1390
|
name = toolName || "set_msg_emoji";
|
|
1133
1391
|
description = description || DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION;
|
|
1134
|
-
schema =
|
|
1135
|
-
messageId:
|
|
1136
|
-
emojiId:
|
|
1392
|
+
schema = import_zod9.z.object({
|
|
1393
|
+
messageId: import_zod9.z.string().min(1, "message_id is required").describe("Target message ID."),
|
|
1394
|
+
emojiId: import_zod9.z.string().min(1, "emoji_id is required").describe("Emoji ID to send.")
|
|
1137
1395
|
});
|
|
1138
1396
|
async _call(input, _manager, runnable) {
|
|
1139
1397
|
const session = getSession(runnable);
|
|
@@ -1149,8 +1407,8 @@ function createSetMsgEmojiTool(deps) {
|
|
|
1149
1407
|
}
|
|
1150
1408
|
|
|
1151
1409
|
// src/features/native-tools/tools/profile.ts
|
|
1152
|
-
var
|
|
1153
|
-
var
|
|
1410
|
+
var import_zod10 = require("zod");
|
|
1411
|
+
var import_tools10 = require("@langchain/core/tools");
|
|
1154
1412
|
var genders = {
|
|
1155
1413
|
unknown: "0",
|
|
1156
1414
|
male: "1",
|
|
@@ -1177,13 +1435,13 @@ async function sendSetProfile(params) {
|
|
|
1177
1435
|
}
|
|
1178
1436
|
function createSetProfileTool(deps) {
|
|
1179
1437
|
const { toolName, description, log, protocol } = deps;
|
|
1180
|
-
return new class extends
|
|
1438
|
+
return new class extends import_tools10.StructuredTool {
|
|
1181
1439
|
name = toolName || "set_self_profile";
|
|
1182
1440
|
description = description || DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION;
|
|
1183
|
-
schema =
|
|
1184
|
-
nickname:
|
|
1185
|
-
signature:
|
|
1186
|
-
gender:
|
|
1441
|
+
schema = import_zod10.z.object({
|
|
1442
|
+
nickname: import_zod10.z.string().min(1, "nickname is required").describe("The new nickname for the bot."),
|
|
1443
|
+
signature: import_zod10.z.string().optional().describe("Optional: the new personal signature."),
|
|
1444
|
+
gender: import_zod10.z.enum(["unknown", "male", "female"]).optional().describe("Optional: the new gender.")
|
|
1187
1445
|
});
|
|
1188
1446
|
async _call(input, _manager, runnable) {
|
|
1189
1447
|
return sendSetProfile({
|
|
@@ -1199,8 +1457,8 @@ function createSetProfileTool(deps) {
|
|
|
1199
1457
|
}
|
|
1200
1458
|
|
|
1201
1459
|
// src/features/native-tools/tools/set-qq-avatar.ts
|
|
1202
|
-
var
|
|
1203
|
-
var
|
|
1460
|
+
var import_zod11 = require("zod");
|
|
1461
|
+
var import_tools11 = require("@langchain/core/tools");
|
|
1204
1462
|
function isHttpUrl(value) {
|
|
1205
1463
|
return /^https?:\/\//i.test(value);
|
|
1206
1464
|
}
|
|
@@ -1259,11 +1517,11 @@ async function sendSetQQAvatar(params) {
|
|
|
1259
1517
|
}
|
|
1260
1518
|
function createSetQQAvatarTool(deps) {
|
|
1261
1519
|
const { ctx, toolName, description, log } = deps;
|
|
1262
|
-
return new class extends
|
|
1520
|
+
return new class extends import_tools11.StructuredTool {
|
|
1263
1521
|
name = toolName || "set_qq_avatar";
|
|
1264
1522
|
description = description || DEFAULT_SET_QQ_AVATAR_TOOL_DESCRIPTION;
|
|
1265
|
-
schema =
|
|
1266
|
-
imageUrl:
|
|
1523
|
+
schema = import_zod11.z.object({
|
|
1524
|
+
imageUrl: import_zod11.z.string().min(1, "imageUrl is required").describe("Image URL or local file path readable by the OneBot side.")
|
|
1267
1525
|
});
|
|
1268
1526
|
async _call(input, _manager, runnable) {
|
|
1269
1527
|
return sendSetQQAvatar({
|
|
@@ -1379,6 +1637,24 @@ function registerNativeTools(deps) {
|
|
|
1379
1637
|
});
|
|
1380
1638
|
log?.("info", `\u7FA4\u6635\u79F0\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1381
1639
|
}
|
|
1640
|
+
if (isNativeToolEnabled(config, "searchGroupMember")) {
|
|
1641
|
+
const toolName = resolveToolName(
|
|
1642
|
+
config.searchGroupMember.toolName,
|
|
1643
|
+
"search_group_member"
|
|
1644
|
+
);
|
|
1645
|
+
const description = resolveToolDescription(
|
|
1646
|
+
config.searchGroupMember.description,
|
|
1647
|
+
DEFAULT_SEARCH_GROUP_MEMBER_TOOL_DESCRIPTION
|
|
1648
|
+
);
|
|
1649
|
+
plugin.registerTool(toolName, {
|
|
1650
|
+
selector: () => true,
|
|
1651
|
+
authorization: (session) => session?.platform === "onebot",
|
|
1652
|
+
description,
|
|
1653
|
+
createTool: () => createSearchGroupMemberTool({ toolName, description, log }),
|
|
1654
|
+
meta: createNativeToolMeta("onebot", ["group"])
|
|
1655
|
+
});
|
|
1656
|
+
log?.("info", `\u7FA4\u6210\u5458\u641C\u7D22\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1657
|
+
}
|
|
1382
1658
|
if (isNativeToolEnabled(config, "setGroupBan")) {
|
|
1383
1659
|
const toolName = resolveToolName(
|
|
1384
1660
|
config.setGroupBan.toolName,
|
|
@@ -1397,6 +1673,42 @@ function registerNativeTools(deps) {
|
|
|
1397
1673
|
});
|
|
1398
1674
|
log?.("info", `\u7FA4\u6210\u5458\u7981\u8A00\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1399
1675
|
}
|
|
1676
|
+
if (isNativeToolEnabled(config, "leaveGroup")) {
|
|
1677
|
+
const toolName = resolveToolName(
|
|
1678
|
+
config.leaveGroup.toolName,
|
|
1679
|
+
"set_group_leave"
|
|
1680
|
+
);
|
|
1681
|
+
const description = resolveToolDescription(
|
|
1682
|
+
config.leaveGroup.description,
|
|
1683
|
+
DEFAULT_LEAVE_GROUP_TOOL_DESCRIPTION
|
|
1684
|
+
);
|
|
1685
|
+
plugin.registerTool(toolName, {
|
|
1686
|
+
selector: () => true,
|
|
1687
|
+
authorization: (session) => session?.platform === "onebot",
|
|
1688
|
+
description,
|
|
1689
|
+
createTool: () => createLeaveGroupTool({ toolName, description, log }),
|
|
1690
|
+
meta: createNativeToolMeta("onebot", ["group"])
|
|
1691
|
+
});
|
|
1692
|
+
log?.("info", `\u9000\u7FA4\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1693
|
+
}
|
|
1694
|
+
if (isNativeToolEnabled(config, "setGroupKick")) {
|
|
1695
|
+
const toolName = resolveToolName(
|
|
1696
|
+
config.setGroupKick.toolName,
|
|
1697
|
+
"set_group_kick"
|
|
1698
|
+
);
|
|
1699
|
+
const description = resolveToolDescription(
|
|
1700
|
+
config.setGroupKick.description,
|
|
1701
|
+
DEFAULT_SET_GROUP_KICK_TOOL_DESCRIPTION
|
|
1702
|
+
);
|
|
1703
|
+
plugin.registerTool(toolName, {
|
|
1704
|
+
selector: () => true,
|
|
1705
|
+
authorization: (session) => session?.platform === "onebot",
|
|
1706
|
+
description,
|
|
1707
|
+
createTool: () => createSetGroupKickTool({ toolName, description, log }),
|
|
1708
|
+
meta: createNativeToolMeta("onebot", ["group"])
|
|
1709
|
+
});
|
|
1710
|
+
log?.("info", `\u8E22\u51FA\u7FA4\u6210\u5458\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
1711
|
+
}
|
|
1400
1712
|
if (isNativeToolEnabled(config, "setGroupSpecialTitle")) {
|
|
1401
1713
|
const toolName = resolveToolName(
|
|
1402
1714
|
config.setGroupSpecialTitle.toolName,
|
|
@@ -1849,7 +2161,7 @@ function registerXmlTools(deps) {
|
|
|
1849
2161
|
}
|
|
1850
2162
|
|
|
1851
2163
|
// src/features/variables/providers/bot-info.ts
|
|
1852
|
-
function
|
|
2164
|
+
function pickFirst2(...values) {
|
|
1853
2165
|
for (const value of values) {
|
|
1854
2166
|
if (value === null || value === void 0) continue;
|
|
1855
2167
|
const text = String(value).trim();
|
|
@@ -1936,7 +2248,7 @@ function renderBotInfo(session, member, items) {
|
|
|
1936
2248
|
switch (item) {
|
|
1937
2249
|
case "nickname": {
|
|
1938
2250
|
const name2 = String(
|
|
1939
|
-
|
|
2251
|
+
pickFirst2(
|
|
1940
2252
|
member?.card,
|
|
1941
2253
|
member?.remark,
|
|
1942
2254
|
member?.displayName,
|
|
@@ -1954,7 +2266,7 @@ function renderBotInfo(session, member, items) {
|
|
|
1954
2266
|
break;
|
|
1955
2267
|
case "role": {
|
|
1956
2268
|
const role = normalizeRole(
|
|
1957
|
-
|
|
2269
|
+
pickFirst2(
|
|
1958
2270
|
member?.role,
|
|
1959
2271
|
member?.roleName,
|
|
1960
2272
|
member?.permission,
|
|
@@ -1965,7 +2277,7 @@ function renderBotInfo(session, member, items) {
|
|
|
1965
2277
|
break;
|
|
1966
2278
|
}
|
|
1967
2279
|
case "level": {
|
|
1968
|
-
const level =
|
|
2280
|
+
const level = pickFirst2(
|
|
1969
2281
|
member?.level,
|
|
1970
2282
|
member?.levelName,
|
|
1971
2283
|
member?.level_name,
|
|
@@ -1975,7 +2287,7 @@ function renderBotInfo(session, member, items) {
|
|
|
1975
2287
|
break;
|
|
1976
2288
|
}
|
|
1977
2289
|
case "title": {
|
|
1978
|
-
const title =
|
|
2290
|
+
const title = pickFirst2(
|
|
1979
2291
|
member?.title,
|
|
1980
2292
|
member?.specialTitle,
|
|
1981
2293
|
member?.special_title
|
|
@@ -1994,14 +2306,14 @@ function renderBotInfo(session, member, items) {
|
|
|
1994
2306
|
break;
|
|
1995
2307
|
}
|
|
1996
2308
|
case "area": {
|
|
1997
|
-
const area =
|
|
2309
|
+
const area = pickFirst2(member?.area, member?.region, member?.location);
|
|
1998
2310
|
if (area !== null) values.push(`\u5730\u533A:${area}`);
|
|
1999
2311
|
break;
|
|
2000
2312
|
}
|
|
2001
2313
|
case "joinTime": {
|
|
2002
2314
|
const joinTime = formatDateOnly(
|
|
2003
2315
|
normalizeTimestamp(
|
|
2004
|
-
|
|
2316
|
+
pickFirst2(
|
|
2005
2317
|
member?.join_time,
|
|
2006
2318
|
member?.joined_at,
|
|
2007
2319
|
member?.joinTime,
|
|
@@ -2015,7 +2327,7 @@ function renderBotInfo(session, member, items) {
|
|
|
2015
2327
|
case "lastSentTime": {
|
|
2016
2328
|
const lastSentTime = formatDateTime(
|
|
2017
2329
|
normalizeTimestamp(
|
|
2018
|
-
|
|
2330
|
+
pickFirst2(
|
|
2019
2331
|
member?.last_sent_time,
|
|
2020
2332
|
member?.lastSentTime,
|
|
2021
2333
|
member?.lastSpeakTimestamp
|
|
@@ -2212,7 +2524,7 @@ function formatDateTime2(value) {
|
|
|
2212
2524
|
if (Number.isNaN(date.valueOf())) return "\u672A\u77E5";
|
|
2213
2525
|
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")}`;
|
|
2214
2526
|
}
|
|
2215
|
-
function
|
|
2527
|
+
function pickFirst3(...values) {
|
|
2216
2528
|
for (const value of values) {
|
|
2217
2529
|
if (value === null || value === void 0) continue;
|
|
2218
2530
|
const text = String(value).trim();
|
|
@@ -2221,12 +2533,12 @@ function pickFirst2(...values) {
|
|
|
2221
2533
|
return "";
|
|
2222
2534
|
}
|
|
2223
2535
|
function normalizeShutItem(item) {
|
|
2224
|
-
const userId =
|
|
2536
|
+
const userId = pickFirst3(
|
|
2225
2537
|
item.uin,
|
|
2226
2538
|
item.user_id
|
|
2227
2539
|
);
|
|
2228
2540
|
if (!userId) return null;
|
|
2229
|
-
const cardName =
|
|
2541
|
+
const cardName = pickFirst3(
|
|
2230
2542
|
item.cardName,
|
|
2231
2543
|
item.remark,
|
|
2232
2544
|
item.nick,
|
|
@@ -2235,7 +2547,7 @@ function normalizeShutItem(item) {
|
|
|
2235
2547
|
);
|
|
2236
2548
|
const shutUpTimeText = formatDateTime2(
|
|
2237
2549
|
normalizeTimestamp2(
|
|
2238
|
-
|
|
2550
|
+
pickFirst3(
|
|
2239
2551
|
item.shutUpTime,
|
|
2240
2552
|
item.shut_up_time
|
|
2241
2553
|
)
|
|
@@ -2564,7 +2876,7 @@ function formatDateTime3(value) {
|
|
|
2564
2876
|
if (Number.isNaN(date.valueOf())) return "";
|
|
2565
2877
|
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")}`;
|
|
2566
2878
|
}
|
|
2567
|
-
function
|
|
2879
|
+
function pickFirst4(...values) {
|
|
2568
2880
|
for (const value of values) {
|
|
2569
2881
|
if (value === null || value === void 0) continue;
|
|
2570
2882
|
const text = String(value).trim();
|
|
@@ -2622,7 +2934,7 @@ function renderUserInfo(session, member, items) {
|
|
|
2622
2934
|
switch (item) {
|
|
2623
2935
|
case "nickname": {
|
|
2624
2936
|
const name2 = String(
|
|
2625
|
-
|
|
2937
|
+
pickFirst4(
|
|
2626
2938
|
member?.card,
|
|
2627
2939
|
member?.remark,
|
|
2628
2940
|
member?.displayName,
|
|
@@ -2641,7 +2953,7 @@ function renderUserInfo(session, member, items) {
|
|
|
2641
2953
|
break;
|
|
2642
2954
|
case "role": {
|
|
2643
2955
|
const role = normalizeRole2(
|
|
2644
|
-
|
|
2956
|
+
pickFirst4(
|
|
2645
2957
|
member?.role,
|
|
2646
2958
|
member?.roleName,
|
|
2647
2959
|
member?.permission,
|
|
@@ -2652,7 +2964,7 @@ function renderUserInfo(session, member, items) {
|
|
|
2652
2964
|
break;
|
|
2653
2965
|
}
|
|
2654
2966
|
case "level": {
|
|
2655
|
-
const level =
|
|
2967
|
+
const level = pickFirst4(
|
|
2656
2968
|
member?.level,
|
|
2657
2969
|
member?.levelName,
|
|
2658
2970
|
member?.level_name,
|
|
@@ -2662,7 +2974,7 @@ function renderUserInfo(session, member, items) {
|
|
|
2662
2974
|
break;
|
|
2663
2975
|
}
|
|
2664
2976
|
case "title": {
|
|
2665
|
-
const title =
|
|
2977
|
+
const title = pickFirst4(
|
|
2666
2978
|
member?.title,
|
|
2667
2979
|
member?.specialTitle,
|
|
2668
2980
|
member?.special_title
|
|
@@ -2681,14 +2993,14 @@ function renderUserInfo(session, member, items) {
|
|
|
2681
2993
|
break;
|
|
2682
2994
|
}
|
|
2683
2995
|
case "area": {
|
|
2684
|
-
const area =
|
|
2996
|
+
const area = pickFirst4(member?.area, member?.region, member?.location);
|
|
2685
2997
|
if (area !== null) values.push(`\u5730\u533A:${area}`);
|
|
2686
2998
|
break;
|
|
2687
2999
|
}
|
|
2688
3000
|
case "joinTime": {
|
|
2689
3001
|
const joinTime = formatDateOnly3(
|
|
2690
3002
|
normalizeTimestamp3(
|
|
2691
|
-
|
|
3003
|
+
pickFirst4(
|
|
2692
3004
|
member?.join_time,
|
|
2693
3005
|
member?.joined_at,
|
|
2694
3006
|
member?.joinTime,
|
|
@@ -2702,7 +3014,7 @@ function renderUserInfo(session, member, items) {
|
|
|
2702
3014
|
case "lastSentTime": {
|
|
2703
3015
|
const lastSentTime = formatDateTime3(
|
|
2704
3016
|
normalizeTimestamp3(
|
|
2705
|
-
|
|
3017
|
+
pickFirst4(
|
|
2706
3018
|
member?.last_sent_time,
|
|
2707
3019
|
member?.lastSentTime,
|
|
2708
3020
|
member?.lastSpeakTimestamp
|
|
@@ -2872,11 +3184,14 @@ Character XML \u5DE5\u5177\u4EC5\u4F9B [koishi-plugin-chatluna-character](https:
|
|
|
2872
3184
|
createDeleteMessageTool,
|
|
2873
3185
|
createGroupInfoProvider,
|
|
2874
3186
|
createGroupShutListProvider,
|
|
3187
|
+
createLeaveGroupTool,
|
|
2875
3188
|
createLogger,
|
|
2876
3189
|
createPokeTool,
|
|
2877
3190
|
createRandomProvider,
|
|
3191
|
+
createSearchGroupMemberTool,
|
|
2878
3192
|
createSetGroupBanTool,
|
|
2879
3193
|
createSetGroupCardTool,
|
|
3194
|
+
createSetGroupKickTool,
|
|
2880
3195
|
createSetGroupSpecialTitleTool,
|
|
2881
3196
|
createSetMsgEmojiTool,
|
|
2882
3197
|
createSetProfileTool,
|
|
@@ -2894,8 +3209,11 @@ Character XML \u5DE5\u5177\u4EC5\u4F9B [koishi-plugin-chatluna-character](https:
|
|
|
2894
3209
|
registerVariables,
|
|
2895
3210
|
registerXmlTools,
|
|
2896
3211
|
resolveOneBotProtocol,
|
|
3212
|
+
searchGroupMember,
|
|
2897
3213
|
sendDeleteMessage,
|
|
2898
3214
|
sendGroupBan,
|
|
3215
|
+
sendGroupKick,
|
|
3216
|
+
sendLeaveGroup,
|
|
2899
3217
|
sendMsgEmoji,
|
|
2900
3218
|
sendPoke,
|
|
2901
3219
|
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.20",
|
|
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",
|
|
@@ -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
|
-
};
|