karin-plugin-teamspeak 1.5.5 → 1.5.7

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/README.md CHANGED
@@ -13,3 +13,42 @@ karin 下的 [teamspeak](https://www.teamspeak.com/zh-CN/) 插件,使用 ts
13
13
  2. 运行 `npx karin .`
14
14
  3. 在 karin web 界面的插件页签中配置该插件
15
15
  4. 保存配置后查看命令行是否成功连接服务器
16
+
17
+ # 功能
18
+
19
+ 1. 监听 ts 服务器用户进入离开事件,在配置的群聊里发送用户进出提示 如:`xxx进入ts`、`xxx离开ts`
20
+ 2. 在群聊或私聊发送`人数`时,发送当前服务器内有人在的频道的人数和进入时长 如:
21
+ ```
22
+ ====服务器名====
23
+ 仅展示有人的频道
24
+ 当前频道内共有4人
25
+ ======
26
+ 聊天听歌等待区
27
+ - BOT (29005287:9)
28
+ - xxx (0:4)
29
+ ======
30
+ fps2
31
+ - xxx (0:31)
32
+ ======
33
+ fps3
34
+ - xxx (96:31)
35
+ ======
36
+ ```
37
+ 3. 可以通过调用接口 `/api/teamspeak/getAllUserList` 来获取当前服务器内所有频道内人数和进入时长包括没人在的频道,返回的数据格式为:
38
+
39
+ ```
40
+ {
41
+ name: "配置内的服务器名或host",
42
+ res: {
43
+ 频道1:[{
44
+ nickName:"xxx", //昵称
45
+ lastconnected: "YYYY-MM-DD HH:mm:ss", //上次连接进来的时间
46
+ connectTime:"", //已经连接的时间 - 单位分:秒
47
+ },{},...],
48
+ 频道2:[{}],
49
+ 频道3:[{}],
50
+ ...
51
+ },
52
+ count: "频道内总人数"
53
+ }
54
+ ```
package/lib/apps/ts3.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryProtocol, TeamSpeak } from "ts3-nodejs-library";
2
- import { config, dirPath } from "../utils/index.js";
2
+ 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";
@@ -17,8 +17,7 @@ class ts3 {
17
17
  disNotifyNameList = [TS.NICKNAME, ...TS.DIS_NOTIFY_NAME_LIST];
18
18
  logger.info(loggerHex(" ===== ts3 ===== ") + "开始连接ts3服务器...");
19
19
  if (this.teamspeak) {
20
- await this.teamspeak.quit();
21
- this.teamspeak = undefined;
20
+ await this.quitTs();
22
21
  }
23
22
  const _teamspeak = new TeamSpeak({
24
23
  host: TS.HOST,
@@ -124,7 +123,9 @@ class ts3 {
124
123
  //关闭连接
125
124
  quitTs = async () => {
126
125
  if (this.teamspeak) {
126
+ this.teamspeak.removeAllListeners();
127
127
  this.teamspeak.quit();
128
+ this.teamspeak = undefined;
128
129
  }
129
130
  };
130
131
  //重新连接
@@ -132,6 +133,9 @@ class ts3 {
132
133
  if (this.teamspeak) {
133
134
  this.teamspeak.reconnect(config().RECONNECT_TIMER, 1000);
134
135
  }
136
+ else {
137
+ this.init();
138
+ }
135
139
  };
136
140
  //重连逻辑
137
141
  async handelReconnect() {
@@ -200,10 +204,4 @@ router.get("/getAllUserList", async (req, res) => {
200
204
  });
201
205
  //将路由挂载到express实例中
202
206
  app.use("/api/teamspeak", router);
203
- //将静态资源挂载到express实例中 - 供外部单页应用网页部署时使用
204
- app.use("/teamspeak", express.static(dirPath + "/resources/static"));
205
- //供外部单页应用网页部署时使用 可用 ip:port/ts3 访问部署的网页
206
- app.get("/teamspeak", (req, res) => {
207
- res.sendFile(dirPath + "/resources/static/index.html");
208
- });
209
207
  export default teamspeak3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-teamspeak",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "karin 的 teamspeak 插件",
5
5
  "homepage": "https://github.com/jacksixth/karin-plugin-teamspeak3",
6
6
  "bugs": {