koishi-plugin-ets2-tools-tmp 2.5.2 → 2.5.4

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.
@@ -1,4 +1,5 @@
1
- const BASE_API = 'https://api.truckersmp.com/v2';
1
+ const BASE_API = 'https://tmpapi.114512.xyz';
2
+ // const BASE_API = 'https://api.truckersmp.com/v2';
2
3
  module.exports = {
3
4
  /**
4
5
  * 查询玩家信息
@@ -1,4 +1,5 @@
1
- const BASE_API = 'https://tracker.ets2map.com';
1
+ const BASE_API = 'https://tracker-ets2map-proxy.114512.xyz';
2
+ // const BASE_API = 'https://tracker.ets2map.com';
2
3
  module.exports = {
3
4
  /**
4
5
  * 区域查询玩家
@@ -1,4 +1,4 @@
1
- const BASE_API = 'https://api.codetabs.com/v1/proxy/?quest=https://api.truckyapp.com'
1
+ const BASE_API = 'https://tmp-fullmap.114512.xyz'
2
2
 
3
3
  module.exports = {
4
4
  /**
@@ -173,6 +173,54 @@ module.exports = async (ctx, cfg, session, tmpId) => {
173
173
  message += '\n📶上次在线: ' + dayjs(playerInfo.data.lastOnlineTime).fromNow(false);
174
174
  }
175
175
  }
176
+ const steamID = playerInfo.data.steamId;
177
+
178
+ // 查询Steam游戏时长
179
+ async function getSteamGameTimes(steamId) {
180
+ try {
181
+ const steamApiKey = cfg.steamApi?.key;
182
+ if (!steamApiKey) {
183
+ return { ets2: null, ats: null };
184
+ }
185
+ const url = `https://api.steampowered.com/IPlayerService/GetOwnedGames/v1?key=${steamApiKey}&steamid=${steamId}&appids_filter[0]=227300&appids_filter[1]=270880&include_played_free_games=1`;
186
+ const response = await ctx.http.get(url);
187
+ const result = { ets2: null, ats: null };
188
+
189
+ if (response.response && response.response.game_count > 0) {
190
+ for (const game of response.response.games) {
191
+ const playtimeMinutes = game.playtime_forever;
192
+ const hours = Math.floor(playtimeMinutes / 60);
193
+ const minutes = playtimeMinutes % 60;
194
+ const playtime = `${hours}小时${minutes}分钟`;
195
+
196
+ if (game.appid === 227300) {
197
+ result.ets2 = playtime;
198
+ } else if (game.appid === 270880) {
199
+ result.ats = playtime;
200
+ }
201
+ }
202
+ }
203
+
204
+ return result;
205
+ } catch (error) {
206
+ ctx.logger.error(`查询Steam游戏时长出错: ${error}`);
207
+ return { ets2: null, ats: null };
208
+ }
209
+ }
210
+
211
+ // 获取欧卡和美卡游戏时长
212
+ if (cfg.commands?.tmpQueryGameTime) {
213
+ const gameTimes = await getSteamGameTimes(steamID);
214
+
215
+ // 添加游戏时长信息
216
+ if (gameTimes.ets2) {
217
+ message += '\n🎮欧卡游戏时长: ' + gameTimes.ets2;
218
+ }
219
+ if (gameTimes.ats) {
220
+ message += '\n🎮美卡游戏时长: ' + gameTimes.ats;
221
+ }
222
+ }
223
+
176
224
  message += '\n\n🌟是否Patreon支持者: '
177
225
  if (playerInfo.data.isSponsor) {
178
226
  message += '是'
package/lib/index.js CHANGED
@@ -78,7 +78,8 @@ exports.Config = koishi_1.Schema.intersect([
78
78
  mainSettings: koishi_1.Schema.boolean().default(false).description('是否启用车队平台积分查询功能'),
79
79
  resetPassword: koishi_1.Schema.boolean().default(false).description('是否启用车队平台重置密码功能'),
80
80
  tmpActivityService: koishi_1.Schema.boolean().default(false).description('是否启用车队活动查询'),
81
- tmpVersionCheck: koishi_1.Schema.boolean().default(false).description('是否启用TMP版本更新查询')
81
+ tmpVersionCheck: koishi_1.Schema.boolean().default(false).description('是否启用TMP版本更新查询'),
82
+ tmpQueryGameTime: koishi_1.Schema.boolean().default(true).description('是否启用游戏时长查询功能')
82
83
  }).description('指令配置'),
83
84
  baiduTranslate: koishi_1.Schema.object({
84
85
  enable: koishi_1.Schema.boolean().default(false).description('是否启用百度翻译'),
@@ -103,6 +104,9 @@ exports.Config = koishi_1.Schema.intersect([
103
104
  checkInterval: koishi_1.Schema.number().description("版本检查间隔(分钟)").default(30),
104
105
  groups: koishi_1.Schema.array(koishi_1.Schema.string()).role("table").description("接收版本更新通知的群组ID列表").default([])
105
106
  }).description("TMP版本更新查询配置"),
107
+ steamApi: koishi_1.Schema.object({
108
+ key: koishi_1.Schema.string().description("Steam API Key,用于查询游戏时长")
109
+ }).description("Steam API配置"),
106
110
  mainSettings: koishi_1.Schema.object({
107
111
  settings: koishi_1.Schema.object({
108
112
  Name: koishi_1.Schema.string().description("车队名称"),
@@ -196,7 +200,8 @@ function logDisabledCommands(ctx, cfg) {
196
200
  { key: 'resetPassword', label: '重置密码' },
197
201
  { key: 'mainSettings', label: '查询积分' },
198
202
  { key: 'tmpActivityService', label: '车队活动查询' },
199
- { key: 'tmpVersionCheck', label: 'TMP版本更新查询' }
203
+ { key: 'tmpVersionCheck', label: 'TMP版本更新查询' },
204
+ { key: 'tmpQueryGameTime', label: '游戏时长查询' }
200
205
  ];
201
206
  for (const item of commandList) {
202
207
  if (commandFlags[item.key] !== false) enabled.push(item.label);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ets2-tools-tmp",
3
3
  "description": "欧卡2 TruckersMP信息查询、车队平台查询及活动提醒",
4
- "version": "2.5.2",
4
+ "version": "2.5.4",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>",
7
7
  "bot_actions <168329908@qq.com>"