koishi-plugin-ets2-tools-tmp 2.1.1 → 2.2.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.
- package/lib/index.js +15 -15
- package/lib/util/baiduTranslate.js +5 -11
- package/package.json +1 -1
- package/readme.md +2 -3
package/lib/index.js
CHANGED
|
@@ -174,25 +174,25 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
174
174
|
|
|
175
175
|
function logDisabledCommands(ctx, cfg) {
|
|
176
176
|
const commandFlags = cfg.commands || {};
|
|
177
|
-
const
|
|
177
|
+
const enabled = [];
|
|
178
178
|
const commandList = [
|
|
179
|
-
{ key: 'tmpQuery', label: '
|
|
180
|
-
{ key: 'tmpServer', label: '
|
|
181
|
-
{ key: 'tmpTraffic', label: '
|
|
182
|
-
{ key: 'tmpPosition', label: '
|
|
183
|
-
{ key: 'tmpVersion', label: 'tmp
|
|
184
|
-
{ key: 'tmpDlcMap', label: '
|
|
185
|
-
{ key: 'tmpMileageRanking', label: '
|
|
186
|
-
{ key: 'tmpVtc', label: 'vtc
|
|
187
|
-
{ key: 'tmpFootprint', label: '
|
|
188
|
-
{ key: 'resetPassword', label: '
|
|
189
|
-
{ key: 'mainSettings', label: '
|
|
179
|
+
{ key: 'tmpQuery', label: '查询/绑定' },
|
|
180
|
+
{ key: 'tmpServer', label: '美卡/欧卡服务器' },
|
|
181
|
+
{ key: 'tmpTraffic', label: '路况' },
|
|
182
|
+
{ key: 'tmpPosition', label: '定位' },
|
|
183
|
+
{ key: 'tmpVersion', label: 'tmp版本' },
|
|
184
|
+
{ key: 'tmpDlcMap', label: '地图dlc价格' },
|
|
185
|
+
{ key: 'tmpMileageRanking', label: '里程排行榜/今日里程排行榜' },
|
|
186
|
+
{ key: 'tmpVtc', label: 'vtc查询' },
|
|
187
|
+
{ key: 'tmpFootprint', label: '今日足迹' },
|
|
188
|
+
{ key: 'resetPassword', label: '重置密码' },
|
|
189
|
+
{ key: 'mainSettings', label: '查询积分' }
|
|
190
190
|
];
|
|
191
191
|
for (const item of commandList) {
|
|
192
|
-
if (commandFlags[item.key]
|
|
192
|
+
if (commandFlags[item.key] !== false) enabled.push(item.label);
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
195
|
-
ctx.logger.info(`[TMP-BOT]
|
|
194
|
+
if (enabled.length) {
|
|
195
|
+
ctx.logger.info(`[TMP-BOT] 已启用以下功能: ${enabled.join(', ')}`);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -2,28 +2,22 @@ const md5 = require('js-md5');
|
|
|
2
2
|
const translateCache = require('../database/translateCache');
|
|
3
3
|
const TRANSLATE_API = 'https://fanyi-api.baidu.com/api/trans/vip/translate';
|
|
4
4
|
module.exports = async (ctx, cfg, content, cache = true) => {
|
|
5
|
-
|
|
6
|
-
if (!cfg.baiduTranslateEnable) {
|
|
5
|
+
if (!cfg.baiduTranslate.enable) {
|
|
7
6
|
return content;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
if (cfg.baiduTranslateCacheEnable && cache) {
|
|
8
|
+
if (cfg.baiduTranslate.enableCache && cache) {
|
|
11
9
|
let translateContent = await translateCache.getTranslate(ctx.database, md5(content));
|
|
12
10
|
if (translateContent) {
|
|
13
11
|
return translateContent;
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
// 创建请求秘钥
|
|
17
14
|
let randomInt = Math.floor(Math.random() * 10000);
|
|
18
|
-
let sign = md5(cfg.
|
|
19
|
-
|
|
20
|
-
let result = await ctx.http.get(`${TRANSLATE_API}?q=${encodeURI(content)}&from=auto&to=zh&appid=${cfg.baiduTranslateAppId}&salt=${randomInt}&sign=${sign}`);
|
|
21
|
-
// 如果翻译失败,直接返回内容
|
|
15
|
+
let sign = md5(cfg.baiduTranslate.appId + content + randomInt + cfg.baiduTranslate.key);
|
|
16
|
+
let result = await ctx.http.get(`${TRANSLATE_API}?q=${encodeURI(content)}&from=auto&to=zh&appid=${cfg.baiduTranslate.appId}&salt=${randomInt}&sign=${sign}`);
|
|
22
17
|
if (result.error_code) {
|
|
23
18
|
return content;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
if (cfg.baiduTranslateCacheEnable && cache) {
|
|
20
|
+
if (cfg.baiduTranslate.enableCache && cache) {
|
|
27
21
|
translateCache.save(ctx.database, md5(content), content, result.trans_result[0].dst);
|
|
28
22
|
}
|
|
29
23
|
return result.trans_result[0].dst;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
- **VTC与规则**:支持指定VTC ID查询,提供TruckersMP官方规则快速链接
|
|
17
17
|
|
|
18
18
|
### 🚚 车队活动管理
|
|
19
|
-
-
|
|
19
|
+
- **双数据源支持**:同时对接车队平台和TruckersMP API获取活动数据
|
|
20
20
|
- **智能提醒机制**:活动开始前按配置时间自动发送提醒,支持多时间点精准设置
|
|
21
21
|
- **档位状态检查**:自动检测活动档上传状态,及时向管理群发送提醒
|
|
22
22
|
- **多群组适配**:区分管理群与主群,按需发送不同类型通知消息
|
|
@@ -117,7 +117,6 @@
|
|
|
117
117
|
- 活动开始前按配置时间点向主群发送提醒
|
|
118
118
|
|
|
119
119
|
### 注意事项
|
|
120
|
-
- 车队平台仅支持V1.0版本,V2.0版本适配将在后续更新
|
|
121
120
|
- 路况查询仅支持指定服务器简称,需按规则输入(s1/s2/p/a)
|
|
122
121
|
- 管理员专用功能(如重置密码)需提前配置管理员权限
|
|
123
122
|
|
|
@@ -139,4 +138,4 @@ TMP数据接口文档:https://apifox.com/apidoc/shared/38508a88-5ff4-4b29-b724
|
|
|
139
138
|
- 支持平台: Koishi
|
|
140
139
|
- 依赖: HTTP请求、定时任务、数据库
|
|
141
140
|
- 适配器: 支持主流聊天平台(除邮件适配器外)
|
|
142
|
-
- 车队平台支持: V1.0
|
|
141
|
+
- 车队平台支持: V1.0, V2.0
|