增加bika修改图片质量

This commit is contained in:
yeyang
2023-01-30 16:39:19 +08:00
parent 6bba959534
commit db91380d34
2 changed files with 26 additions and 1 deletions

View File

@@ -32,6 +32,10 @@ export class newBika extends plugin {
{
reg: `#?${Prefix}(详情|细节)(.*)`,
fnc: 'comicDetail'
},
{
reg: `#?${Prefix}修改图片质量(.*)`,
fnc: 'imageQuality'
}
]
@@ -77,6 +81,22 @@ export class newBika extends plugin {
common.getRecallsendMsg(e, msg, { oneMsg: true })
}
/** 图片质量 */
async imageQuality (e) {
let quality = e.msg.match(new RegExp(`#?${Prefix}修改图片质量(.*)`))[2]
let imageQualityType = {
低质量: 'low',
中等质量: 'medium',
高质量: 'high',
原图: 'original'
}
if (!imageQualityType[quality] && !Object.values(imageQualityType).includes(quality)) return e.reply(`错误参数,支持的参数为${Object.keys(imageQualityType).join('')}`)
let type = imageQualityType[quality] ?? quality
await redis.set('yenai:bika:imageQuality', type)
Bika.imageQuality = type
e.reply(`✅ 已将bika图片质量修改为${quality}(${type})`)
}
/** 权限判定 */
handlePermission () {
let { sesepro } = Config.getGroup(this.e.group_id)

View File

@@ -7,12 +7,17 @@ export default new (class {
constructor () {
this.domain = 'http://api.liaobiao.top/api/bika'
this.imgproxy = 'https://proxy.liaobiao.top/'
this.imageQuality = 'original'
this.imageQuality = 'medium'
this.hearder = {
headers: {
'x-image-quality': this.imageQuality
}
}
this.init()
}
async init () {
this.imageQuality = await redis.get('yenai:bika:imageQuality') ?? 'medium'
}
/**