koishi-plugin-tmp-bot 1.17.1 → 1.17.3

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.
@@ -14,6 +14,9 @@ export function mapPlayerList(http: any, serverId: any, ax: any, ay: any, bx: an
14
14
  * 查询玩家信息
15
15
  */
16
16
  export function playerInfo(http: any, tmpId: any): Promise<{
17
+ code: any;
18
+ error: boolean;
19
+ } | {
17
20
  error: boolean;
18
21
  }>;
19
22
  /**
@@ -59,6 +59,7 @@ module.exports = {
59
59
  }
60
60
  // 拼接返回数据
61
61
  let data = {
62
+ code: result.code,
62
63
  error: result.code !== 200
63
64
  };
64
65
  if (!data.error) {
@@ -1,3 +1,3 @@
1
- declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "请输入正确的玩家编号" | "渲染异常,请重试" | "查询玩家信息失败,请重试" | "未启用 puppeteer 服务">;
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "请输入正确的玩家编号" | "渲染异常,请重试" | "查询玩家信息失败,请重试" | "未启用 puppeteer 服务" | "玩家不存在">;
2
2
  export = _exports;
3
3
  import { segment } from "@koishijs/core";
@@ -37,7 +37,10 @@ module.exports = async (ctx, cfg, session, tmpId) => {
37
37
  }
38
38
  // 查询玩家信息
39
39
  let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
40
- if (playerInfo.error) {
40
+ if (playerInfo.error && playerInfo.code === 10001) {
41
+ return '玩家不存在';
42
+ }
43
+ else if (playerInfo.error) {
41
44
  return '查询玩家信息失败,请重试';
42
45
  }
43
46
  // 查询线上信息
@@ -31,7 +31,10 @@ module.exports = async (ctx, cfg, session, tmpId) => {
31
31
  }
32
32
  // 查询玩家信息
33
33
  let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
34
- if (playerInfo.error) {
34
+ if (playerInfo.error && playerInfo.code === 10001) {
35
+ return '玩家不存在';
36
+ }
37
+ else if (playerInfo.error) {
35
38
  return '查询玩家信息失败,请重试';
36
39
  }
37
40
  // 查询线上信息
@@ -67,7 +70,16 @@ module.exports = async (ctx, cfg, session, tmpId) => {
67
70
  message += "\n🚫封禁原因: " + (playerInfo.data.banReasonZh || playerInfo.data.banReason);
68
71
  }
69
72
  }
70
- message += '\n🚫封禁次数: ' + playerInfo.data.banCount || 0;
73
+ message += '\n🚫封禁次数: ' + (playerInfo.data.banCount || 0);
74
+ if (playerInfo.data.todayMileage) {
75
+ let todayMileage = playerInfo.data.todayMileage;
76
+ let mileageUnit = '米';
77
+ if (todayMileage > 1000) {
78
+ todayMileage = (todayMileage / 1000).toFixed(1);
79
+ mileageUnit = '公里';
80
+ }
81
+ message += '\n🚩今日里程: ' + todayMileage + mileageUnit;
82
+ }
71
83
  if (playerMapInfo && !playerMapInfo.error) {
72
84
  message += '\n📶在线状态: ' + (playerMapInfo.data.online ? `在线🟢 (${playerMapInfo.data.serverDetails.name})` : '离线⚫');
73
85
  if (playerMapInfo.data.online) {
Binary file
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.17.1",
4
+ "version": "1.17.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",