From 74df179857158f86734210d1683a9116589bfb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Fri, 29 Nov 2024 13:38:14 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B2=A1=E6=9C=89=E5=A1=ABapiKey?= =?UTF-8?q?=E6=97=B6=E8=BE=93=E5=87=BA=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- apps/inventory.js | 2 +- apps/setting.js | 2 +- components/App.js | 7 ++++++- models/setting/index.js | 2 +- models/task/index.js | 6 +++--- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ab79054..682c7b3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ ## **注意** -一定要填**Steam Web API Key**,否则无法使用绝大部分功能,请前往[Steam API](https://steamcommunity.com/dev/apikey)申请API Key +一定要填**Steam Web API Key**,否则无法使用绝大部分功能,通常会返回 401 或 403 错误,请前往[Steam API](https://steamcommunity.com/dev/apikey)申请API Key 相关链接: @@ -79,7 +79,7 @@ pnpm install --filter=steam-plugin - [x] steam搜索 - [x] steam成就 - [x] steam统计 -- [ ] 群友上下线通知 +- [x] 群友上下线通知 - [ ] steam喜加一 - [x] 开启/关闭推送 - [x] steam特惠 diff --git a/apps/inventory.js b/apps/inventory.js index c288705..5dbe8a3 100644 --- a/apps/inventory.js +++ b/apps/inventory.js @@ -46,7 +46,7 @@ export const rule = { wishlist.length = Config.other.hiddenLength } // 愿望单没有给name, 尝试获取一下, 顺便也可以获取一下价格 获取失败超过3次就不再获取了 - // 2024年11月27日 已更新 有个api可以获取多个appid + // 2024年11月27日 已更新 有个api可以获取多个appid 不知道一次最多能获取多少 const appidsInfo = await api.IStoreBrowseService.GetItems(wishlist.map(i => i.appid)) for (const i in wishlist) { const appid = wishlist[i].appid diff --git a/apps/setting.js b/apps/setting.js index 011d73b..2304ef8 100644 --- a/apps/setting.js +++ b/apps/setting.js @@ -14,7 +14,7 @@ const app = { export const rule = { setting: { - reg: new RegExp(`^#steam设置\\s*(${keys.join('|')})?\\s*(.*)$`), + reg: new RegExp(`^#steam设置\\s*(${keys.join('|')})?[\\s+]*(.*)$`), fnc: async e => { if (!e.isMaster) { await e.reply('只有主人才可以设置哦~') diff --git a/components/App.js b/components/App.js index eb1af87..f0ac0ba 100644 --- a/components/App.js +++ b/components/App.js @@ -1,6 +1,7 @@ import lodash from 'lodash' import Version from './Version.js' import { plugin, logger } from '#lib' +import Config from './Config.js' const throttle = {} @@ -54,9 +55,13 @@ export default class { ...cfg }) cls.prototype[name] = async (e) => { + if (!Config.steam.apiKey && !/帮助|设置/.test(e.msg)) { + await e.reply('没有配置apiKey不能调用Steam Web API哦\n先到https://steamcommunity.com/dev/apikey 申请一下apiKey\n然后使用 #steam设置apiKey + 申请到的apiKey\n之后再使用吧') + return true + } const key = `${name}:${e.user_id}` if (throttle[key]) { - e.reply('太快辣! 要受不了了🥵') + await e.reply('太快辣! 要受不了了🥵') return true } else { throttle[key] = setTimeout(() => { diff --git a/models/setting/index.js b/models/setting/index.js index 8733218..4a8d9fe 100644 --- a/models/setting/index.js +++ b/models/setting/index.js @@ -179,7 +179,7 @@ export const cfgSchema = { title: '展示steam头像', key: '展示头像', type: 'boolean', - def: false, + def: true, desc: '是否展示steam头像, 可能会有18+头像' } } diff --git a/models/task/index.js b/models/task/index.js index 863ef8f..dd65392 100644 --- a/models/task/index.js +++ b/models/task/index.js @@ -9,14 +9,14 @@ let timer = null const redisKey = 'steam-plugin:user-play:' export function startTimer () { - if (!Config.steam.apiKey) { - return - } if (!Config.push.enable && !Config.push.stateChange) { return } clearInterval(timer) timer = setInterval(async () => { + if (!Config.steam.apiKey) { + return + } logger.info('开始检查Steam游戏信息') try { // 获取现在的时间