koishi-plugin-tmp-bot 1.19.4 → 1.20.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 +1 -1
- package/lib/command/tmpFootprint.d.ts +1 -1
- package/lib/command/tmpFootprint.js +28 -14
- package/lib/command/tmpPosition.d.ts +1 -1
- package/lib/command/tmpPosition.js +2 -2
- package/lib/command/tmpQuery/tmpQueryImg.d.ts +1 -1
- package/lib/command/tmpQuery/tmpQueryImg.js +2 -2
- package/lib/command/tmpQuery/tmpQueryText.js +2 -2
- package/lib/index.js +3 -1
- package/lib/util/constant.d.ts +4 -0
- package/lib/util/constant.js +8 -1
- package/package.json +1 -1
package/lib/api/evmOpenApi.js
CHANGED
|
@@ -117,7 +117,7 @@ module.exports = {
|
|
|
117
117
|
async mapPlayerHistory(http, tmpId, serverId, startTime, endTime) {
|
|
118
118
|
let result = null;
|
|
119
119
|
try {
|
|
120
|
-
result = await http.get(`${BASE_API}/map/playerHistory?tmpId=${tmpId}&serverId=${serverId}&startTime=${startTime}&endTime=${endTime}`);
|
|
120
|
+
result = await http.get(`${BASE_API}/map/playerHistory?tmpId=${tmpId || ''}&serverId=${serverId || ''}&startTime=${startTime || ''}&endTime=${endTime || ''}`);
|
|
121
121
|
}
|
|
122
122
|
catch {
|
|
123
123
|
return {
|
|
@@ -2,24 +2,24 @@ const { segment } = require('koishi');
|
|
|
2
2
|
const dayjs = require('dayjs');
|
|
3
3
|
const { resolve } = require('path');
|
|
4
4
|
const common = require('../util/common');
|
|
5
|
-
const {
|
|
5
|
+
const { PromodsIds, ServerType } = require('../util/constant');
|
|
6
6
|
const evmOpenApi = require('../api/evmOpenApi');
|
|
7
7
|
const guildBind = require('../database/guildBind');
|
|
8
|
-
module.exports = async (ctx, session,
|
|
8
|
+
module.exports = async (ctx, session, serverType, tmpId) => {
|
|
9
9
|
if (!ctx.puppeteer) {
|
|
10
10
|
return '未启用 puppeteer 服务';
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!serverId) {
|
|
15
|
-
return '请输入正确的服务器名称 (s1, s2, p, a)';
|
|
12
|
+
if (tmpId && isNaN(tmpId)) {
|
|
13
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
16
14
|
}
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
16
|
+
if (!tmpId) {
|
|
17
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
18
|
+
if (!guildBindData) {
|
|
19
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
20
|
+
}
|
|
21
|
+
tmpId = guildBindData.tmp_id;
|
|
21
22
|
}
|
|
22
|
-
let tmpId = guildBindData.tmp_id;
|
|
23
23
|
// 查询玩家信息
|
|
24
24
|
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
|
|
25
25
|
if (playerInfo.error && playerInfo.code === 10001) {
|
|
@@ -31,13 +31,27 @@ module.exports = async (ctx, session, serverName) => {
|
|
|
31
31
|
// 查询当日历史位置数据
|
|
32
32
|
const startTime = dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
|
33
33
|
const endTime = dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
|
34
|
-
let mapPlayerHistory = await evmOpenApi.mapPlayerHistory(ctx.http, tmpId,
|
|
35
|
-
if (mapPlayerHistory.
|
|
34
|
+
let mapPlayerHistory = await evmOpenApi.mapPlayerHistory(ctx.http, tmpId, null, startTime, endTime);
|
|
35
|
+
if (mapPlayerHistory.error) {
|
|
36
|
+
return '查询玩家历史位置数据失败,请稍后重试';
|
|
37
|
+
}
|
|
38
|
+
// 过滤非对应服务器数据
|
|
39
|
+
const promodsIdSet = new Set(PromodsIds);
|
|
40
|
+
const mapPlayerHistoryArr = mapPlayerHistory.data.filter(item => {
|
|
41
|
+
if (ServerType.ets === serverType) {
|
|
42
|
+
return !promodsIdSet.has(item.serverId);
|
|
43
|
+
}
|
|
44
|
+
else if (ServerType.promods === serverType) {
|
|
45
|
+
return promodsIdSet.has(item.serverId);
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
});
|
|
49
|
+
if (mapPlayerHistoryArr.length === 0) {
|
|
36
50
|
return `当日暂无数据`;
|
|
37
51
|
}
|
|
38
52
|
// 拼接数据
|
|
39
53
|
let data = {
|
|
40
|
-
mapType:
|
|
54
|
+
mapType: ServerType.promods === serverType ? 'promods' : 'ets',
|
|
41
55
|
name: playerInfo.data.name,
|
|
42
56
|
smallAvatarUrl: playerInfo.data.smallAvatarUrl,
|
|
43
57
|
todayMileage: playerInfo.data.todayMileage,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "
|
|
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";
|
|
@@ -12,13 +12,13 @@ const common = require('../util/common');
|
|
|
12
12
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
13
13
|
if (ctx.puppeteer) {
|
|
14
14
|
if (tmpId && isNaN(tmpId)) {
|
|
15
|
-
return
|
|
15
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
16
16
|
}
|
|
17
17
|
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
18
18
|
if (!tmpId) {
|
|
19
19
|
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
20
20
|
if (!guildBindData) {
|
|
21
|
-
return
|
|
21
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
22
22
|
}
|
|
23
23
|
tmpId = guildBindData.tmp_id;
|
|
24
24
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "
|
|
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";
|
|
@@ -25,13 +25,13 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
25
25
|
return '未启用 puppeteer 服务';
|
|
26
26
|
}
|
|
27
27
|
if (tmpId && isNaN(tmpId)) {
|
|
28
|
-
return
|
|
28
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
29
29
|
}
|
|
30
30
|
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
31
31
|
if (!tmpId) {
|
|
32
32
|
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
33
33
|
if (!guildBindData) {
|
|
34
|
-
return
|
|
34
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
35
35
|
}
|
|
36
36
|
tmpId = guildBindData.tmp_id;
|
|
37
37
|
}
|
|
@@ -23,13 +23,13 @@ const userGroup = {
|
|
|
23
23
|
*/
|
|
24
24
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
25
25
|
if (tmpId && isNaN(tmpId)) {
|
|
26
|
-
return
|
|
26
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
27
27
|
}
|
|
28
28
|
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
29
29
|
if (!tmpId) {
|
|
30
30
|
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
31
31
|
if (!guildBindData) {
|
|
32
|
-
return
|
|
32
|
+
return `请输入正确的玩家编号,或绑定玩家编号`;
|
|
33
33
|
}
|
|
34
34
|
tmpId = guildBindData.tmp_id;
|
|
35
35
|
}
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const tmpVersion = require('./command/tmpVersion');
|
|
|
14
14
|
const tmpDlcMap = require('./command/tmpDlcMap');
|
|
15
15
|
const tmpMileageRanking = require('./command/tmpMileageRanking');
|
|
16
16
|
const tmpFootprint = require('./command/tmpFootprint');
|
|
17
|
+
const { ServerType } = require('./util/constant');
|
|
17
18
|
exports.name = 'tmp-bot';
|
|
18
19
|
exports.inject = {
|
|
19
20
|
required: ['database'],
|
|
@@ -51,5 +52,6 @@ function apply(ctx, cfg) {
|
|
|
51
52
|
ctx.command('tmpdlcmap').action(async ({ session }) => await tmpDlcMap(ctx, session));
|
|
52
53
|
ctx.command('tmpmileageranking').action(async ({ session }) => await tmpMileageRanking(ctx, session, MileageRankingType.total));
|
|
53
54
|
ctx.command('tmptodaymileageranking').action(async ({ session }) => await tmpMileageRanking(ctx, session, MileageRankingType.today));
|
|
54
|
-
ctx.command('
|
|
55
|
+
ctx.command('tmpfootprints').action(async ({ session }, tmpId) => await tmpFootprint(ctx, session, ServerType.ets, tmpId));
|
|
56
|
+
ctx.command('tmpfootprintp').action(async ({ session }, tmpId) => await tmpFootprint(ctx, session, ServerType.promods, tmpId));
|
|
55
57
|
}
|
package/lib/util/constant.d.ts
CHANGED
package/lib/util/constant.js
CHANGED
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.
|
|
4
|
+
"version": "1.20.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",
|