koishi-plugin-tmp-bot 1.14.0 → 1.14.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.
- package/lib/api/evmOpenApi.js +27 -0
- package/lib/command/tmpServer.js +9 -11
- package/lib/index.js +1 -2
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const BASE_API = 'https://open-api.vtcm.link'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* 查询服务器列表
|
|
6
|
+
*/
|
|
7
|
+
async serverList (http) {
|
|
8
|
+
let result = null
|
|
9
|
+
try {
|
|
10
|
+
result = await http.get(`${BASE_API}/server/list`)
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 拼接返回数据
|
|
18
|
+
let data = {
|
|
19
|
+
error: result.code !== 200
|
|
20
|
+
}
|
|
21
|
+
if (!data.error) {
|
|
22
|
+
data.data = result.data
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return data
|
|
26
|
+
}
|
|
27
|
+
}
|
package/lib/command/tmpServer.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
const truckersMpApi = require('../api/truckersMpApi')
|
|
2
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
2
3
|
|
|
3
|
-
module.exports = async (ctx
|
|
4
|
+
module.exports = async (ctx) => {
|
|
4
5
|
// 查询服务器信息
|
|
5
|
-
let serverData = await
|
|
6
|
+
let serverData = await evmOpenApi.serverList(ctx.http)
|
|
6
7
|
if (serverData.error) {
|
|
7
8
|
return '查询服务器失败,请稍后重试'
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
// 过滤服务器
|
|
11
|
-
let etsServerList = serverData.data.filter(server => server.game === game)
|
|
12
|
-
|
|
13
11
|
// 构建消息
|
|
14
12
|
let message = ''
|
|
15
|
-
for (let server of
|
|
13
|
+
for (let server of serverData.data) {
|
|
16
14
|
// 如果前面有内容,换行
|
|
17
15
|
if (message) {
|
|
18
16
|
message += '\n\n'
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
message += '服务器: ' + ( server.
|
|
22
|
-
message += `\n玩家人数: ${server.
|
|
19
|
+
message += '服务器: ' + ( server.isOnline === 1 ? '🟢' : '⚫' ) + server.serverName
|
|
20
|
+
message += `\n玩家人数: ${server.playerCount}/${server.maxPlayer}`
|
|
23
21
|
if (server.queue) {
|
|
24
|
-
message += ` (队列: ${server.
|
|
22
|
+
message += ` (队列: ${server.queueCount})`
|
|
25
23
|
}
|
|
26
24
|
// 服务器特性
|
|
27
25
|
let characteristicList = []
|
|
28
|
-
if (!server.
|
|
26
|
+
if (!(server.afkEnable === 1)) {
|
|
29
27
|
characteristicList.push('⏱挂机')
|
|
30
28
|
}
|
|
31
|
-
if (server.
|
|
29
|
+
if (server.collisionsEnable === 1) {
|
|
32
30
|
characteristicList.push('💥碰撞')
|
|
33
31
|
}
|
|
34
32
|
if (characteristicList && characteristicList.length > 0) {
|
package/lib/index.js
CHANGED
|
@@ -35,8 +35,7 @@ function apply(ctx, cfg) {
|
|
|
35
35
|
model(ctx);
|
|
36
36
|
// 注册指令
|
|
37
37
|
ctx.command('tmpquery <tmpId>').action(async ({ session }, tmpId) => await tmpQuery(ctx, cfg, session, tmpId));
|
|
38
|
-
ctx.command('
|
|
39
|
-
ctx.command('tmpserverets').action(async () => await tmpServer(ctx, cfg, 'ETS2'));
|
|
38
|
+
ctx.command('tmpserverets').action(async () => await tmpServer(ctx));
|
|
40
39
|
ctx.command('tmpbind <tmpId>').action(async ({ session }, tmpId) => await tmpBind(ctx, cfg, session, tmpId));
|
|
41
40
|
ctx.command('tmptraffic <serverName>').action(async ({ session }, serverName) => await tmpTraffic(ctx, cfg, serverName));
|
|
42
41
|
ctx.command('tmpposition <tmpId>').action(async ({ session }, tmpId) => await tmpPosition(ctx, cfg, session, tmpId));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-tmp-bot",
|
|
3
3
|
"description": "欧洲卡车模拟2 TMP查询插件,不会部署的可以直接使用此机器人->QQ:3523283907",
|
|
4
|
-
"version": "1.14.
|
|
4
|
+
"version": "1.14.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",
|