mioku-plugin-help 2.3.0 → 2.3.1
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/help/role.ts +15 -4
- package/package.json +1 -1
- package/skills.ts +3 -0
package/help/role.ts
CHANGED
|
@@ -36,8 +36,14 @@ export function canInvokeCommand(
|
|
|
36
36
|
* mioki's `isOwner` allowlist.
|
|
37
37
|
* - Private chat skips the `isAdmin` check and defaults to `admin`,
|
|
38
38
|
* so anyone DM-ing the bot can see admin-level commands.
|
|
39
|
-
* - Group chat
|
|
40
|
-
* owner (group
|
|
39
|
+
* - Group chat resolves bot admin (mioki `isAdmin` allowlist), group
|
|
40
|
+
* owner (群主) and group admin (群管理) all to `admin`. This mirrors
|
|
41
|
+
* the admin plugin's execution gating (`isMaster || senderRole ===
|
|
42
|
+
* "owner" || senderRole === "admin"`) so the help image only hides
|
|
43
|
+
* commands the viewer genuinely can't run. `sender.role` is checked
|
|
44
|
+
* first (populated by OneBot on group events), with
|
|
45
|
+
* `getGroupMemberInfo` as a fallback when it's missing. Everyone else
|
|
46
|
+
* is `member`.
|
|
41
47
|
*/
|
|
42
48
|
export async function resolveViewerRole(
|
|
43
49
|
ctx: any,
|
|
@@ -54,6 +60,11 @@ export async function resolveViewerRole(
|
|
|
54
60
|
return "admin";
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
const senderRole = event?.sender?.role;
|
|
64
|
+
if (senderRole === "owner" || senderRole === "admin") {
|
|
65
|
+
return "admin";
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
if (event?.group_id != null && event?.user_id != null) {
|
|
58
69
|
const selfId =
|
|
59
70
|
event?.self_id != null ? Number(event.self_id) : undefined;
|
|
@@ -67,8 +78,8 @@ export async function resolveViewerRole(
|
|
|
67
78
|
event.group_id,
|
|
68
79
|
event.user_id,
|
|
69
80
|
);
|
|
70
|
-
if (info?.role === "owner") {
|
|
71
|
-
return "
|
|
81
|
+
if (info?.role === "owner" || info?.role === "admin") {
|
|
82
|
+
return "admin";
|
|
72
83
|
}
|
|
73
84
|
} catch {
|
|
74
85
|
// fall through to member
|
package/package.json
CHANGED
package/skills.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
buildHelpInfoText,
|
|
6
6
|
generateHelpImage,
|
|
7
7
|
resolveHelpBotProfile,
|
|
8
|
+
resolveViewerRole,
|
|
8
9
|
sendImageFromSkillContext,
|
|
9
10
|
} from "./help";
|
|
10
11
|
import { getRenderVersions } from "./utils";
|
|
@@ -61,6 +62,7 @@ const helpSkill: AISkill = {
|
|
|
61
62
|
ctx,
|
|
62
63
|
event,
|
|
63
64
|
);
|
|
65
|
+
const viewerRole = await resolveViewerRole(ctx, event);
|
|
64
66
|
const imagePath = await generateHelpImage({
|
|
65
67
|
helpService,
|
|
66
68
|
screenshotService,
|
|
@@ -68,6 +70,7 @@ const helpSkill: AISkill = {
|
|
|
68
70
|
miokuVersion,
|
|
69
71
|
botNickname,
|
|
70
72
|
botAvatarUrl,
|
|
73
|
+
viewerRole,
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
if (!imagePath) {
|