karin-plugin-teamspeak 1.3.0 → 1.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.
@@ -13,5 +13,4 @@ export interface Config {
13
13
  RECONNECT_TIMER: number //断线重连次数 -1表示将不断尝试
14
14
  DIS_NOTIFY_NAME_LIST: string[] //不提醒的昵称列表 可多个 默认不提醒当前加入ts的机器人
15
15
  SERVER_NAME: string //展示的服务器名
16
- USE_PUPPETEER: boolean //是否使用puppeteer插件渲染人数列表
17
16
  }
@@ -14,6 +14,5 @@
14
14
  "DIS_NOTIFY_NAME_LIST": [
15
15
  "TESTBOT"
16
16
  ],
17
- "SERVER_NAME": "xxxxxxx",
18
- "USE_PUPPETEER": true
17
+ "SERVER_NAME": "xxxxxxx"
19
18
  }
@@ -1,4 +1,4 @@
1
- import { config, dirPath } from "../utils/index.js";
1
+ import { dirPath } from "../utils/index.js";
2
2
  import { karin, render, common, segment, logger } from "node-karin";
3
3
  import teamspeak3 from "./ts3.js";
4
4
  /**
@@ -7,9 +7,9 @@ import teamspeak3 from "./ts3.js";
7
7
  */
8
8
  export const image = karin.command(/^#?人数$/, async (e) => {
9
9
  try {
10
- let usePuppeteer = config().USE_PUPPETEER || false;
10
+ //默认尝试使用渲染器,调用失败则表示未连接将使用文字形式发送服务器人数
11
+ let usePuppeteer = true;
11
12
  try {
12
- //尝试调用渲染器,调用失败则表示未连接
13
13
  render.App();
14
14
  }
15
15
  catch (error) {
@@ -61,7 +61,7 @@ export const image = karin.command(/^#?人数$/, async (e) => {
61
61
  /** 插件触发是否打印触发日志 */
62
62
  log: true,
63
63
  /** 插件名称 */
64
- name: "显示ts3内人数",
64
+ name: "显示ts服务器内人数",
65
65
  /** 谁可以触发这个插件 'all' | 'master' | 'admin' | 'group.owner' | 'group.admin' */
66
66
  permission: "all",
67
67
  });
package/lib/apps/ts3.js CHANGED
@@ -85,9 +85,9 @@ class ts3 {
85
85
  if (!this.teamspeak) {
86
86
  return;
87
87
  }
88
- let usePuppeteer = config().USE_PUPPETEER || false;
88
+ //默认尝试使用渲染器,调用失败则表示未连接渲染器
89
+ let usePuppeteer = true;
89
90
  try {
90
- //尝试调用渲染器,调用失败则表示未连接渲染器
91
91
  render.App();
92
92
  }
93
93
  catch (error) {
@@ -1,4 +1,6 @@
1
1
  import { Config } from "../../config/config/config.d";
2
+ export declare const dir: string;
3
+ export declare const dirConfig: string;
2
4
  /**
3
5
  * @description 配置文件
4
6
  */
@@ -1,7 +1,8 @@
1
1
  import { dirPath, basename } from "../utils/index.js";
2
2
  import { watch, logger, basePath, filesByExt, copyConfigSync, requireFileSync, } from "node-karin";
3
- const dir = `${basePath}/${basename}`;
4
- const dirConfig = `${dir}/config`;
3
+ import teamspeak3 from "../apps/ts3.js";
4
+ export const dir = `${basePath}/${basename}`;
5
+ export const dirConfig = `${dir}/config`;
5
6
  const defDir = `${dirPath}/config`;
6
7
  const defConfig = `${defDir}/config`;
7
8
  /**
@@ -28,5 +29,6 @@ setTimeout(() => {
28
29
  list.forEach((file) => watch(file, (old, now) => {
29
30
  logger.info("旧数据:", old);
30
31
  logger.info("新数据:", now);
32
+ teamspeak3.init();
31
33
  }));
32
34
  }, 2000);
package/lib/web.config.js CHANGED
@@ -1,4 +1,6 @@
1
- import { components, logger } from "node-karin";
1
+ import { components, logger, writeJsonSync } from "node-karin";
2
+ import { config, dirConfig } from "./utils/index.js";
3
+ const defConfig = config();
2
4
  export default {
3
5
  info: {
4
6
  // 插件信息配置
@@ -7,6 +9,7 @@ export default {
7
9
  components: () => [
8
10
  components.input.string("HOST", {
9
11
  label: "teamspeak 服务器地址(不带端口)",
12
+ defaultValue: defConfig.HOST,
10
13
  variant: "underlined",
11
14
  placeholder: "请输入服务器地址",
12
15
  rules: [
@@ -19,11 +22,12 @@ export default {
19
22
  components.input.string("SERVER_NAME", {
20
23
  label: "展示的服务器名(不填写则显示服务器地址)",
21
24
  placeholder: "请输入展示的服务器名",
25
+ defaultValue: defConfig.SERVER_NAME,
22
26
  variant: "underlined",
23
27
  isRequired: false,
24
28
  }),
25
29
  components.radio.group("PROTOCOL", {
26
- defaultValue: "RAW",
30
+ defaultValue: defConfig.PROTOCOL,
27
31
  label: "teamspeak 服务器查询 (一般使用默认的RAW即可)",
28
32
  size: "sm",
29
33
  orientation: "horizontal",
@@ -47,38 +51,40 @@ export default {
47
51
  type: "number",
48
52
  placeholder: "请输入服务器查询端口",
49
53
  variant: "underlined",
50
- defaultValue: "10011",
54
+ defaultValue: defConfig.QUERY_PORT + "",
51
55
  rules: [{ min: 1, max: 65535 }],
52
56
  }),
53
57
  components.input.number("SERVER_PORT", {
54
58
  label: "teamspeak 服务器语音端口 (一般使用默认 9987 即可)",
55
- defaultValue: "9987",
59
+ defaultValue: defConfig.SERVER_PORT + "",
56
60
  placeholder: "请输入服务器语音端口",
57
61
  variant: "underlined",
58
62
  rules: [{ min: 1, max: 65535 }],
59
63
  }),
60
64
  components.input.number("RECONNECT_TIMER", {
61
65
  label: "teamspeak 连接断开后重连次数 (-1表示将不断尝试)",
62
- defaultValue: "5",
66
+ defaultValue: defConfig.RECONNECT_TIMER + "",
63
67
  placeholder: "请输入重连次数",
64
68
  variant: "underlined",
65
69
  rules: [{ min: -1 }],
66
70
  }),
67
71
  components.input.string("USERNAME", {
68
72
  label: "teamspeak 管理员用户名 (建服时出现的,没修改时默认是 serveradmin )",
69
- defaultValue: "serveradmin",
73
+ defaultValue: defConfig.USERNAME,
70
74
  placeholder: "请输入管理员用户名",
71
75
  variant: "underlined",
72
76
  }),
73
77
  components.input.string("PASSWORD", {
74
78
  label: "teamspeak 管理员密码 (建服时出现的,每个服务器都不一样)",
79
+ defaultValue: defConfig.PASSWORD,
80
+ type: "password",
75
81
  placeholder: "请输入管理员密码",
76
82
  variant: "underlined",
77
83
  }),
78
84
  components.input.string("NICKNAME", {
79
85
  label: "插件连接进服务器时使用的昵称 (默认为TSBOT,···客户端看不到该用户···) ",
80
86
  placeholder: "请输入连接昵称",
81
- defaultValue: "TSBOT",
87
+ defaultValue: defConfig.NICKNAME,
82
88
  variant: "underlined",
83
89
  }),
84
90
  components.input.group("NOTICE_GROUP_NO", {
@@ -90,7 +96,7 @@ export default {
90
96
  variant: "faded",
91
97
  placeholder: "请输入群号",
92
98
  },
93
- data: [],
99
+ data: [...defConfig.NOTICE_GROUP_NO.map((i) => i + "")],
94
100
  }),
95
101
  components.input.group("DIS_NOTIFY_NAME_LIST", {
96
102
  label: "不提醒的昵称列表 可多个 (不会提醒当前机器人,无需添加当前机器人昵称)",
@@ -101,12 +107,13 @@ export default {
101
107
  variant: "faded",
102
108
  placeholder: "请输入昵称",
103
109
  },
104
- data: [],
110
+ data: [...defConfig.DIS_NOTIFY_NAME_LIST],
105
111
  }),
106
112
  ],
107
113
  /** 前端点击保存之后调用的方法 */
108
114
  save: (config) => {
109
- console.log("保存的配置:", config);
115
+ Object.assign(defConfig, config);
116
+ writeJsonSync(`${dirConfig}/config.json`, config);
110
117
  logger.info("保存的配置:", config);
111
118
  // 在这里处理保存逻辑
112
119
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-teamspeak",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "karin 的 teamspeak3 插件",
5
5
  "homepage": "https://github.com/jacksixth/karin-plugin-teamspeak3",
6
6
  "bugs": {