karin-plugin-teamspeak 1.5.7 → 1.5.9

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.
@@ -1,6 +1,7 @@
1
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
+ const loggerPluginName = logger.chalk.hex("#90CAF9")(" ===== ts3 ===== ");
4
5
  /**
5
6
  * 渲染ts3服务器内存在用户的列表
6
7
  * 触发指令: 人数
@@ -50,7 +51,7 @@ export const image = karin.command(/^#?人数$/, async (e) => {
50
51
  }
51
52
  }
52
53
  catch (error) {
53
- logger.error(error);
54
+ logger.error(loggerPluginName, error);
54
55
  await e.reply(JSON.stringify(error));
55
56
  return true;
56
57
  }
package/lib/apps/ts3.js CHANGED
@@ -3,8 +3,8 @@ import { config } from "../utils/index.js";
3
3
  import karin, { logger, segment, app } from "node-karin";
4
4
  import moment from "node-karin/moment";
5
5
  import express from "node-karin/express";
6
- const loggerHex = logger.chalk.hex("#90CAF9");
7
- logger.info(loggerHex(" ===== ts3 ===== ") + "初始化ts3插件");
6
+ const loggerPluginName = logger.chalk.hex("#90CAF9")(" ===== ts3 ===== ");
7
+ logger.info(loggerPluginName + "初始化ts3插件");
8
8
  let disNotifyNameList = [];
9
9
  class ts3 {
10
10
  teamspeak;
@@ -15,7 +15,7 @@ class ts3 {
15
15
  const TS = config();
16
16
  this.isReConnecting = false;
17
17
  disNotifyNameList = [TS.NICKNAME, ...TS.DIS_NOTIFY_NAME_LIST];
18
- logger.info(loggerHex(" ===== ts3 ===== ") + "开始连接ts3服务器...");
18
+ logger.info(loggerPluginName + "开始连接ts3服务器...");
19
19
  if (this.teamspeak) {
20
20
  await this.quitTs();
21
21
  }
@@ -29,22 +29,21 @@ class ts3 {
29
29
  nickname: TS.NICKNAME,
30
30
  });
31
31
  _teamspeak.on("ready", async () => {
32
- logger.info(loggerHex(" ===== ts3 ===== ") + "ts3连接成功");
32
+ logger.info(loggerPluginName + "ts3连接成功");
33
33
  this.teamspeak = _teamspeak;
34
34
  });
35
35
  _teamspeak.on("close", (e) => {
36
- logger.error(loggerHex(" ===== ts3 ===== ") + "ts3连接断开", e);
36
+ logger.error(loggerPluginName + "ts3连接断开", e);
37
37
  this.handelReconnect();
38
38
  });
39
39
  _teamspeak.on("error", (err) => {
40
- logger.error(loggerHex(" ===== ts3 ===== ") + "ts3连接出错", err);
40
+ logger.error(loggerPluginName + "ts3连接出错", err);
41
41
  this.handelReconnect();
42
42
  });
43
43
  _teamspeak.on("clientconnect", (e) => {
44
44
  if (!disNotifyNameList.includes(e.client.nickname)) {
45
- logger.info(loggerHex(" ===== ts3 ===== ") + e.client.nickname + "进入ts");
45
+ logger.info(loggerPluginName + e.client.nickname + "进入ts");
46
46
  const msg = segment.text(e.client.nickname + "进入ts");
47
- const qq = TS.BOT_SELF_ID;
48
47
  TS.NOTICE_GROUP_NO.forEach((groupNo) => {
49
48
  const contact = karin.contact("group", groupNo + "");
50
49
  karin.sendMsg(karin.getBotAll()[1].account.selfId, contact, msg);
@@ -54,7 +53,7 @@ class ts3 {
54
53
  _teamspeak.on("clientdisconnect", (e) => {
55
54
  if (e.client) {
56
55
  if (!disNotifyNameList.includes(e.client.nickname)) {
57
- logger.info(loggerHex(" ===== ts3 ===== ") + e.client.nickname + "离开ts");
56
+ logger.info(loggerPluginName + e.client.nickname + "离开ts");
58
57
  const msg = segment.text(e.client.nickname + "离开ts");
59
58
  TS.NOTICE_GROUP_NO.forEach((groupNo) => {
60
59
  const contact = karin.contact("group", groupNo + "");
@@ -143,13 +142,13 @@ class ts3 {
143
142
  if (!this.teamspeak || this.isReConnecting)
144
143
  return;
145
144
  this.isReConnecting = true;
146
- logger.info(loggerHex(" ===== ts3 ===== ") + "重连中...");
145
+ logger.info(loggerPluginName + "重连中...");
147
146
  try {
148
147
  await this.teamspeak.reconnect(TS.RECONNECT_TIMER, 1000);
149
- logger.info(loggerHex(" ===== ts3 ===== ") + "重连成功");
148
+ logger.info(loggerPluginName + "重连成功");
150
149
  }
151
150
  catch (e) {
152
- logger.error(loggerHex(" ===== ts3 ===== ") + "连接TS3失败", e);
151
+ logger.error(loggerPluginName + "连接TS3失败", e);
153
152
  }
154
153
  finally {
155
154
  this.isReConnecting = false;
@@ -27,8 +27,8 @@ export const pkg = () => requireFileSync(`${dirPath}/package.json`);
27
27
  setTimeout(() => {
28
28
  const list = filesByExt(dirConfig, ".json", "abs");
29
29
  list.forEach((file) => watch(file, (old, now) => {
30
- logger.info("旧数据:", old);
31
- logger.info("新数据:", now);
30
+ logger.info("旧数据:\n", old);
31
+ logger.info("新数据:\n", now);
32
32
  teamspeak3.init();
33
33
  }));
34
34
  }, 2000);
package/lib/web.config.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { components, logger, writeJsonSync } from "node-karin";
2
2
  import { config, dirConfig } from "./utils/index.js";
3
- const defConfig = config();
4
3
  export default {
5
4
  info: {
6
5
  // 插件信息配置
@@ -9,7 +8,7 @@ export default {
9
8
  components: () => [
10
9
  components.input.string("HOST", {
11
10
  label: "teamspeak 服务器地址或域名(不带端口)",
12
- defaultValue: defConfig.HOST,
11
+ defaultValue: config().HOST,
13
12
  variant: "underlined",
14
13
  placeholder: "请输入服务器地址或域名",
15
14
  rules: [
@@ -22,12 +21,12 @@ export default {
22
21
  components.input.string("SERVER_NAME", {
23
22
  label: "展示的服务器名(不填写则显示服务器地址)",
24
23
  placeholder: "请输入展示的服务器名",
25
- defaultValue: defConfig.SERVER_NAME,
24
+ defaultValue: config().SERVER_NAME,
26
25
  variant: "underlined",
27
26
  isRequired: false,
28
27
  }),
29
28
  components.radio.group("PROTOCOL", {
30
- defaultValue: defConfig.PROTOCOL,
29
+ defaultValue: config().PROTOCOL,
31
30
  label: "teamspeak 服务器查询 (一般使用默认的RAW即可)",
32
31
  size: "sm",
33
32
  orientation: "horizontal",
@@ -51,32 +50,32 @@ export default {
51
50
  type: "number",
52
51
  placeholder: "请输入服务器查询端口",
53
52
  variant: "underlined",
54
- defaultValue: defConfig.QUERY_PORT + "",
53
+ defaultValue: config().QUERY_PORT + "",
55
54
  rules: [{ min: 1, max: 65535 }],
56
55
  }),
57
56
  components.input.number("SERVER_PORT", {
58
57
  label: "teamspeak 服务器语音端口 (一般使用默认 9987 即可)",
59
- defaultValue: defConfig.SERVER_PORT + "",
58
+ defaultValue: config().SERVER_PORT + "",
60
59
  placeholder: "请输入服务器语音端口",
61
60
  variant: "underlined",
62
61
  rules: [{ min: 1, max: 65535 }],
63
62
  }),
64
63
  components.input.number("RECONNECT_TIMER", {
65
64
  label: "teamspeak 连接断开后重连次数 (-1表示将不断尝试)",
66
- defaultValue: defConfig.RECONNECT_TIMER + "",
65
+ defaultValue: config().RECONNECT_TIMER + "",
67
66
  placeholder: "请输入重连次数",
68
67
  variant: "underlined",
69
68
  rules: [{ min: -1 }],
70
69
  }),
71
70
  components.input.string("USERNAME", {
72
71
  label: "teamspeak 管理员用户名 (建服时出现的,没修改时默认是 serveradmin )",
73
- defaultValue: defConfig.USERNAME,
72
+ defaultValue: config().USERNAME,
74
73
  placeholder: "请输入管理员用户名",
75
74
  variant: "underlined",
76
75
  }),
77
76
  components.input.string("PASSWORD", {
78
77
  label: "teamspeak 管理员密码 (建服时出现的,每个服务器都不一样)",
79
- defaultValue: defConfig.PASSWORD,
78
+ defaultValue: config().PASSWORD,
80
79
  type: "password",
81
80
  placeholder: "请输入管理员密码",
82
81
  variant: "underlined",
@@ -84,7 +83,7 @@ export default {
84
83
  components.input.string("NICKNAME", {
85
84
  label: "插件连接进服务器时使用的昵称 (默认为TSBOT,···客户端看不到该用户···) ",
86
85
  placeholder: "请输入连接昵称",
87
- defaultValue: defConfig.NICKNAME,
86
+ defaultValue: config().NICKNAME,
88
87
  variant: "underlined",
89
88
  }),
90
89
  components.input.group("NOTICE_GROUP_NO", {
@@ -96,7 +95,7 @@ export default {
96
95
  variant: "faded",
97
96
  placeholder: "请输入群号",
98
97
  },
99
- data: [...defConfig.NOTICE_GROUP_NO.map((i) => i + "")],
98
+ data: [...config().NOTICE_GROUP_NO.map((i) => i + "")],
100
99
  }),
101
100
  components.input.group("DIS_NOTIFY_NAME_LIST", {
102
101
  label: "不提醒的昵称列表 可多个 (不会提醒当前机器人,无需添加当前机器人昵称)",
@@ -107,14 +106,13 @@ export default {
107
106
  variant: "faded",
108
107
  placeholder: "请输入昵称",
109
108
  },
110
- data: [...defConfig.DIS_NOTIFY_NAME_LIST],
109
+ data: [...config().DIS_NOTIFY_NAME_LIST],
111
110
  }),
112
111
  ],
113
112
  /** 前端点击保存之后调用的方法 */
114
113
  save: (config) => {
115
114
  logger.info("保存的配置:", config);
116
115
  writeJsonSync(`${dirConfig}/config.json`, config);
117
- // 在这里处理保存逻辑
118
116
  return {
119
117
  success: true,
120
118
  message: "保存成功",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-teamspeak",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "karin 的 teamspeak 插件",
5
5
  "homepage": "https://github.com/jacksixth/karin-plugin-teamspeak3",
6
6
  "bugs": {