Merge pull request #84 from Algoinde/master

Add User-Agent for API bot identification
This commit is contained in:
Kokomi 2022-07-30 01:33:11 +08:00 committed by GitHub
commit c35c4246cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -9,7 +9,11 @@ let Enka = {
let url = diyCfg?.enkaApi?.url || sysCfg.enkaApi.url
let profileApi = diyCfg?.enkaApi?.listApi || sysCfg.enkaApi.listApi
let api = profileApi({ url, uid, avatar })
let req = await fetch(api)
if(diyCfg?.enkaApi?.apiKey) {
api += '?key=' + diyCfg.enkaApi.apiKey
}
let headers = {headers: {'User-Agent': diyCfg?.enkaApi?.userAgent || sysCfg.enkaApi.userAgent}}
let req = await fetch(api, headers)
let data = await req.json()
if (!data.playerInfo) {
e.reply(`请求失败:${data.msg || '可能是面板服务并发过高,请稍后重试'}`)

View File

@ -13,7 +13,8 @@
* */
export const enkaApi = {
url: 'https://enka.shinshin.moe/'
url: 'https://enka.shinshin.moe/',
userAgent: 'Miao-Plugin/3.0'
}
/*