Skip to content

Commit

Permalink
perf: 没有填apiKey时输出提示
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Nov 29, 2024
1 parent 12d573f commit 74df179
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

相关链接:

Expand Down Expand Up @@ -79,7 +79,7 @@ pnpm install --filter=steam-plugin
- [x] steam搜索
- [x] steam成就
- [x] steam统计
- [ ] 群友上下线通知
- [x] 群友上下线通知
- [ ] steam喜加一
- [x] 开启/关闭推送
- [x] steam特惠
Expand Down
2 changes: 1 addition & 1 deletion apps/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('只有主人才可以设置哦~')
Expand Down
7 changes: 6 additions & 1 deletion components/App.js
Original file line number Diff line number Diff line change
@@ -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 = {}

Expand Down Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion models/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const cfgSchema = {
title: '展示steam头像',
key: '展示头像',
type: 'boolean',
def: false,
def: true,
desc: '是否展示steam头像, 可能会有18+头像'
}
}
Expand Down
6 changes: 3 additions & 3 deletions models/task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// 获取现在的时间
Expand Down

0 comments on commit 74df179

Please sign in to comment.