fix: dalle cooldown time

This commit is contained in:
ikechan8370 2023-02-25 11:51:54 +08:00
parent 8c9c098e25
commit 3073ca91cf
3 changed files with 25 additions and 15 deletions

View file

@ -21,6 +21,11 @@ export class dalle extends plugin {
}
async draw (e) {
let ttl = await redis.ttl(`CHATGPT:DRAW:${e.sender.user_id}`)
if (ttl > 0 && !e.isMaster) {
this.reply(`冷却中,请${ttl}秒后再试`)
return false
}
let splits = _.split(e.msg, '图', 2)
if (splits.length < 2) {
this.reply('请带上绘图要求')
@ -32,6 +37,7 @@ export class dalle extends plugin {
this.reply('大小不符合要求必须是256x256/512x512/1024x1024中的一个')
return false
}
await redis.set(`CHATGPT:DRAW:${e.sender.user_id}`, 'c', {EX: 30})
let priceMap = {
'1024x1024': 0.02,
'512x512': 0.018,
@ -48,6 +54,7 @@ export class dalle extends plugin {
}
} catch (err) {
this.reply(`绘图失败: err`, true)
await redis.del(`CHATGPT:DRAW:${e.sender.user_id}`)
}