koishi-plugin-noah 2.4.5 → 2.4.6

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.
@@ -18,4 +18,4 @@ export declare function isPluginAdmin(session: Session, config: CoreConfig): boo
18
18
  * @param session - 会话对象
19
19
  * @returns 用户是否为群组管理员
20
20
  */
21
- export declare function isGuildAdmin(session: Session): boolean;
21
+ export declare function isGuildAdmin(session: Session): Promise<boolean>;
package/lib/index.cjs CHANGED
@@ -1861,13 +1861,12 @@ function isPluginAdmin(session, config) {
1861
1861
  return config.adminUsers?.includes(session.userId) ?? false;
1862
1862
  }
1863
1863
  __name(isPluginAdmin, "isPluginAdmin");
1864
- function isGuildAdmin(session) {
1864
+ async function isGuildAdmin(session) {
1865
1865
  const platform = session.event.platform;
1866
1866
  if (platform === "onebot") {
1867
- if (session.guildId == null) return true;
1868
- const role = session.event.member.roles[0];
1869
- const guildMember = typeof role === "string" ? role : role?.name || "";
1870
- return guildMember === "owner" || guildMember === "admin" || guildMember === "SUBCHANNEL_ADMIN" || guildMember === "OWNER" || guildMember === "ADMIN";
1867
+ if (!session.guildId) return true;
1868
+ const member = await session.onebot.getGroupMemberInfo(session.guildId, session.userId);
1869
+ return member.role === "owner" || member.role === "admin";
1871
1870
  } else if (platform === "qq") {
1872
1871
  return true;
1873
1872
  } else {
@@ -1879,7 +1878,7 @@ __name(isGuildAdmin, "isGuildAdmin");
1879
1878
  // src/core/commands/locale.ts
1880
1879
  function locale(ctx, config) {
1881
1880
  ctx.command("locale", { slash: true }).alias("language").option("channel", "-c").option("reset", "-r").userFields(["locales"]).channelFields(["locales"]).action(async ({ session, options }) => {
1882
- if (options.channel && !hasPermission(isPluginAdmin(session, config), isGuildAdmin(session))) {
1881
+ if (options.channel && !hasPermission(isPluginAdmin(session, config), await isGuildAdmin(session))) {
1883
1882
  return session.text(".noAuth");
1884
1883
  }
1885
1884
  if (options.reset) {
@@ -2033,7 +2032,7 @@ function server(ctx, config, serverService, userService) {
2033
2032
  const atGuild = session.guildId != null;
2034
2033
  if (options.channel) {
2035
2034
  if (!atGuild) return session.text(".no-channel");
2036
- if (!hasPermission(isGuildAdmin(session), isPluginAdmin(session, config)))
2035
+ if (!hasPermission(await isGuildAdmin(session), isPluginAdmin(session, config)))
2037
2036
  return session.text(".no-auth");
2038
2037
  const userDefaultServer2 = await serverService.getDefaultServerByUid(session.user.id);
2039
2038
  const userDefaultServerId2 = userDefaultServer2 ? userDefaultServer2.id : 0;
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
1
  {
2
- "name": "koishi-plugin-noah",
3
- "version": "2.4.5",
4
- "contributors": [
5
- "Logthm <logthm@outlook.com>"
6
- ],
7
- "homepage": "https://docs.logthm.cn/noah",
8
- "type": "module",
9
- "main": "lib/index.cjs",
10
- "typings": "lib/index.d.ts",
11
- "files": [
12
- "lib",
13
- "dist"
14
- ],
15
- "license": "MIT",
16
- "keywords": [
17
- "chatbot",
18
- "koishi",
19
- "plugin"
20
- ],
21
- "peerDependencies": {
22
- "koishi": "^4.18.11"
23
- },
24
- "dependencies": {
25
- "@koishijs/plugin-server": "^3.2.9",
26
- "adm-zip": "^0.5.18",
27
- "bwip-js": "^4.11.2",
28
- "javascript-barcode-reader": "^0.6.9",
29
- "koishi-plugin-adapter-onebot": "^6.9.4",
30
- "sharp": "^0.33.5",
31
- "xml2js": "^0.6.2"
32
- },
33
- "koishi": {
34
- "description": {
35
- "en": "A tool bot for arcade music games",
36
- "zh": "街机音游工具机器人"
2
+ "name": "koishi-plugin-noah",
3
+ "version": "2.4.6",
4
+ "contributors": [
5
+ "Logthm <logthm@outlook.com>"
6
+ ],
7
+ "homepage": "https://docs.logthm.cn/noah",
8
+ "type": "module",
9
+ "main": "lib/index.cjs",
10
+ "typings": "lib/index.d.ts",
11
+ "files": [
12
+ "lib",
13
+ "dist"
14
+ ],
15
+ "license": "MIT",
16
+ "keywords": [
17
+ "chatbot",
18
+ "koishi",
19
+ "plugin"
20
+ ],
21
+ "peerDependencies": {
22
+ "koishi": "^4.18.11"
23
+ },
24
+ "dependencies": {
25
+ "@koishijs/plugin-server": "^3.2.9",
26
+ "adm-zip": "^0.5.18",
27
+ "bwip-js": "^4.11.2",
28
+ "javascript-barcode-reader": "^0.6.9",
29
+ "koishi-plugin-adapter-onebot": "^6.9.4",
30
+ "sharp": "^0.33.5",
31
+ "xml2js": "^0.6.2"
37
32
  },
38
- "service": {
39
- "required": [
40
- "database",
41
- "skia",
42
- "server"
43
- ]
33
+ "koishi": {
34
+ "description": {
35
+ "en": "A tool bot for arcade music games",
36
+ "zh": "街机音游工具机器人"
37
+ },
38
+ "service": {
39
+ "required": [
40
+ "database",
41
+ "skia",
42
+ "server"
43
+ ]
44
+ },
45
+ "locales": [
46
+ "en",
47
+ "zh"
48
+ ]
44
49
  },
45
- "locales": [
46
- "en",
47
- "zh"
48
- ]
49
- },
50
- "devDependencies": {
51
- "@haixee/eslint-config": "^2.3.2",
52
- "@koishijs/plugin-adapter-discord": "^4.6.1",
53
- "@ltxhhz/koishi-plugin-skia-canvas": "^0.0.8",
54
- "@types/adm-zip": "^0",
55
- "@types/xml2js": "^0",
56
- "eslint": "^9.39.4",
57
- "eslint-config-prettier": "^10.1.8",
58
- "eslint-import-resolver-typescript": "^3.10.1",
59
- "eslint-plugin-prettier": "^5.5.6",
60
- "husky": "^9.1.7",
61
- "koishi": "^4.18.11",
62
- "lint-staged": "^16.4.0",
63
- "prettier": "^3.9.4",
64
- "yml-register": "^1.2.5"
65
- },
66
- "scripts": {
67
- "lint": "eslint --ext .js,.ts,.tsx src/",
68
- "format": "prettier --write \"src/**/*.{js,ts,tsx,json,css,md}\""
69
- },
70
- "husky": {
71
- "hooks": {
72
- "pre-commit": "lint-staged"
50
+ "devDependencies": {
51
+ "@haixee/eslint-config": "^2.3.2",
52
+ "@koishijs/plugin-adapter-discord": "^4.6.1",
53
+ "@ltxhhz/koishi-plugin-skia-canvas": "^0.0.8",
54
+ "@types/adm-zip": "^0",
55
+ "@types/xml2js": "^0",
56
+ "eslint": "^9.39.4",
57
+ "eslint-config-prettier": "^10.1.8",
58
+ "eslint-import-resolver-typescript": "^3.10.1",
59
+ "eslint-plugin-prettier": "^5.5.6",
60
+ "husky": "^9.1.7",
61
+ "koishi": "^4.18.11",
62
+ "lint-staged": "^16.4.0",
63
+ "prettier": "^3.9.4",
64
+ "yml-register": "^1.2.5"
65
+ },
66
+ "scripts": {
67
+ "lint": "eslint --ext .js,.ts,.tsx src/",
68
+ "format": "prettier --write \"src/**/*.{js,ts,tsx,json,css,md}\""
69
+ },
70
+ "husky": {
71
+ "hooks": {
72
+ "pre-commit": "lint-staged"
73
+ }
74
+ },
75
+ "lint-staged": {
76
+ "*.{js,ts,tsx}": [
77
+ "eslint --fix",
78
+ "prettier --write"
79
+ ],
80
+ "*.{css,md,json}": [
81
+ "prettier --write"
82
+ ]
73
83
  }
74
- },
75
- "lint-staged": {
76
- "*.{js,ts,tsx}": [
77
- "eslint --fix",
78
- "prettier --write"
79
- ],
80
- "*.{css,md,json}": [
81
- "prettier --write"
82
- ]
83
- }
84
84
  }