karin-plugin-teamspeak 1.5.7 → 1.5.8

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;
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.8",
4
4
  "description": "karin 的 teamspeak 插件",
5
5
  "homepage": "https://github.com/jacksixth/karin-plugin-teamspeak3",
6
6
  "bugs": {