koishi-plugin-tmp-bot 1.10.0 → 1.12.0

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.
@@ -68,6 +68,48 @@ module.exports = {
68
68
  data.data = result.response
69
69
  }
70
70
 
71
+ return data
72
+ },
73
+ /**
74
+ * 游戏版本
75
+ */
76
+ async version (http) {
77
+ let result = null
78
+ try {
79
+ result = await http.get(`${BASE_API}/version`)
80
+ } catch {
81
+ return {
82
+ error: true
83
+ }
84
+ }
85
+
86
+ // 拼接返回数据
87
+ return {
88
+ error: false,
89
+ data: result
90
+ }
91
+ },
92
+ /**
93
+ * 查询车队成员信息
94
+ */
95
+ async vtcMember (http, vtcId, memberId) {
96
+ let result = null
97
+ try {
98
+ result = await http.get(`${BASE_API}/vtc/${vtcId}/member/${memberId}`)
99
+ } catch {
100
+ return {
101
+ error: true
102
+ }
103
+ }
104
+
105
+ // 拼接返回数据
106
+ let data = {
107
+ error: JSON.parse(result.error)
108
+ }
109
+ if (!data.error) {
110
+ data.data = result.response
111
+ }
112
+
71
113
  return data
72
114
  }
73
115
  }
@@ -12,8 +12,8 @@ const userGroup = {
12
12
  'Retired Legend': '退役',
13
13
  'Game Developer': '游戏开发者',
14
14
  'Retired Team Member': '退休团队成员',
15
- 'Add-On Team': 'Add-On Team',
16
- 'Game Moderator': 'Game Moderator'
15
+ 'Add-On Team': '附加组件团队',
16
+ 'Game Moderator': '游戏管理员'
17
17
  }
18
18
 
19
19
  /**
@@ -47,11 +47,22 @@ module.exports = async (ctx, cfg, session, tmpId) => {
47
47
 
48
48
  // 拼接消息模板
49
49
  let message = `<img src="${playerInfo.data.avatar}"/>`
50
+ message += '\n🆔TMP编号: ' + playerInfo.data.id
50
51
  message += '\n😀玩家名称: ' + playerInfo.data.name
51
- message += '\n📑注册日期: ' + dayjs(playerInfo.data.joinDate + 'Z').format('YYYY年MM月DD日')
52
- message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName) // 🪪💼📂🚹
52
+ message += '\n🎮SteamID: ' + playerInfo.data.steamID64
53
+ let registerDate = dayjs(playerInfo.data.joinDate + 'Z')
54
+ message += '\n📑注册日期: ' + registerDate.format('YYYY年MM月DD日') + ` (${dayjs().diff(registerDate, 'day')}天)`
55
+ message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName)
53
56
  if (playerInfo.data.vtc && playerInfo.data.vtc.inVTC) {
54
57
  message += '\n🚚所属车队: ' + playerInfo.data.vtc.name
58
+ // 补充车队信息
59
+ try {
60
+ let vtcMemberResult = await truckersMpApi.vtcMember(ctx.http, playerInfo.data.vtc.id, playerInfo.data.vtc.memberID)
61
+ console.log(vtcMemberResult)
62
+ if (!vtcMemberResult.error) {
63
+ message += '\n🚚车队角色: ' + vtcMemberResult.data.role
64
+ }
65
+ } catch (e) {}
55
66
  }
56
67
  message += '\n🚫是否封禁: ' + (playerInfo.data.banned ? '是' : '否')
57
68
  if (playerInfo.data.banned) {
@@ -0,0 +1,16 @@
1
+ const truckersMpApi = require("../api/truckersMpApi");
2
+
3
+ module.exports = async (ctx) => {
4
+ // 查询版本信息
5
+ let result = await truckersMpApi.version(ctx.http)
6
+ if (result.error) {
7
+ return '查询失败,请稍后再试'
8
+ }
9
+
10
+ // 构建消息返回
11
+ let message = ''
12
+ message += `TMP版本:${result.data.name}\n`;
13
+ message += `欧卡支持版本: ${result.data.supported_game_version}\n`;
14
+ message += `美卡支持版本: ${result.data.supported_ats_game_version}`;
15
+ return message
16
+ }
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ const tmpServer = require('./command/tmpServer');
8
8
  const tmpBind = require('./command/tmpBind');
9
9
  const tmpTraffic = require('./command/tmpTraffic/tmpTraffic');
10
10
  const tmpPosition = require('./command/tmpPosition');
11
+ const tmpVersion = require('./command/tmpVersion');
11
12
  exports.name = 'tmp-bot';
12
13
  exports.inject = {
13
14
  required: ['database'],
@@ -37,5 +38,6 @@ function apply(ctx, cfg) {
37
38
  ctx.command('tmpbind <tmpId>').action(async ({ session }, tmpId) => await tmpBind(ctx, cfg, session, tmpId));
38
39
  ctx.command('tmptraffic <serverName>').action(async ({ session }, serverName) => await tmpTraffic(ctx, cfg, serverName));
39
40
  ctx.command('tmpposition <tmpId>').action(async ({ session }, tmpId) => await tmpPosition(ctx, cfg, session, tmpId));
41
+ ctx.command('tmpversion').action(async () => await tmpVersion(ctx));
40
42
  }
41
43
  exports.apply = apply;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-tmp-bot",
3
- "description": "欧洲卡车模拟2 TMP查询插件,不会部署的可以直接使用此机器人 QQ:3523283907",
4
- "version": "1.10.0",
3
+ "description": "欧洲卡车模拟2 TMP查询插件,不会部署的可以直接使用此机器人->QQ:3523283907",
4
+ "version": "1.12.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",
package/readme.md CHANGED
@@ -13,3 +13,4 @@
13
13
  | tmptraffic | 查询服务器热门地点路况信息,仅支持使用服务器简称查询,具体支持查询的服务器和服务器简称信息如下</br>Simulation 1 (简称: s1)</br>Simulation 2 (简称: s2)</br>ProMods (简称: p)</br>Arcade (简称: a) | tmptraffic s1 |
14
14
  | tmpserverats | 查询美卡服务器信息列表 | tmpserverats |
15
15
  | tmpserverets | 查询欧卡服务器信息列表 | tmpserverets |
16
+ | tmpversion | 查询版本信息 | tmpversion |