mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: dalle cooldown time
This commit is contained in:
parent
8c9c098e25
commit
3073ca91cf
3 changed files with 25 additions and 15 deletions
|
|
@ -21,6 +21,11 @@ export class dalle extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async draw (e) {
|
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)
|
let splits = _.split(e.msg, '图', 2)
|
||||||
if (splits.length < 2) {
|
if (splits.length < 2) {
|
||||||
this.reply('请带上绘图要求')
|
this.reply('请带上绘图要求')
|
||||||
|
|
@ -32,6 +37,7 @@ export class dalle extends plugin {
|
||||||
this.reply('大小不符合要求,必须是256x256/512x512/1024x1024中的一个')
|
this.reply('大小不符合要求,必须是256x256/512x512/1024x1024中的一个')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
await redis.set(`CHATGPT:DRAW:${e.sender.user_id}`, 'c', {EX: 30})
|
||||||
let priceMap = {
|
let priceMap = {
|
||||||
'1024x1024': 0.02,
|
'1024x1024': 0.02,
|
||||||
'512x512': 0.018,
|
'512x512': 0.018,
|
||||||
|
|
@ -48,6 +54,7 @@ export class dalle extends plugin {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.reply(`绘图失败: err`, true)
|
this.reply(`绘图失败: err`, true)
|
||||||
|
await redis.del(`CHATGPT:DRAW:${e.sender.user_id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ export default {
|
||||||
// cacheUrl: 'https://content.alcedogroup.com',
|
// cacheUrl: 'https://content.alcedogroup.com',
|
||||||
// 图片内容渲染服务器开启预制访问代码,当渲染服务器访问较慢时可以开启,但无法保证远程渲染是否成功
|
// 图片内容渲染服务器开启预制访问代码,当渲染服务器访问较慢时可以开启,但无法保证远程渲染是否成功
|
||||||
// cacheEntry: false,
|
// cacheEntry: false,
|
||||||
|
// 绘图指令的CD时间,主人不受限制
|
||||||
|
// drawCD: 30,
|
||||||
// ***********************************************************************************************************************************
|
// ***********************************************************************************************************************************
|
||||||
// 以下为API方式(默认)的配置 *
|
// 以下为API方式(默认)的配置 *
|
||||||
// ***********************************************************************************************************************************
|
// ***********************************************************************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ const defaultConfig = {
|
||||||
cacheUrl: 'https://content.alcedogroup.com',
|
cacheUrl: 'https://content.alcedogroup.com',
|
||||||
cacheEntry: false,
|
cacheEntry: false,
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
|
drawCD: 30,
|
||||||
model: '',
|
model: '',
|
||||||
api: 'https://chatgpt.duti.tech/api/conversation',
|
api: 'https://chatgpt.duti.tech/api/conversation',
|
||||||
apiBaseUrl: 'https://chatgpt.duti.tech/api',
|
apiBaseUrl: 'https://chatgpt.duti.tech/api',
|
||||||
|
|
@ -35,28 +36,28 @@ const defaultConfig = {
|
||||||
const _path = process.cwd()
|
const _path = process.cwd()
|
||||||
let config = {}
|
let config = {}
|
||||||
if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/config.js`)) {
|
if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/config.js`)) {
|
||||||
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/config.js`);
|
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/config.js`)
|
||||||
config = (await import(`file://${fullPath}`)).default;
|
config = (await import(`file://${fullPath}`)).default
|
||||||
} else if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/index.js`)) {
|
} else if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/index.js`)) {
|
||||||
// 兼容旧版本
|
// 兼容旧版本
|
||||||
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/index.js`);
|
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/index.js`)
|
||||||
config = (await import(`file://${fullPath}`)).Config;
|
config = (await import(`file://${fullPath}`)).Config
|
||||||
}
|
}
|
||||||
config = Object.assign({}, defaultConfig, config)
|
config = Object.assign({}, defaultConfig, config)
|
||||||
export const Config = new Proxy(config, {
|
export const Config = new Proxy(config, {
|
||||||
set(target, property, value) {
|
set (target, property, value) {
|
||||||
target[property] = value;
|
target[property] = value
|
||||||
const change = lodash.transform(target, function(result, value, key) {
|
const change = lodash.transform(target, function (result, value, key) {
|
||||||
if (!lodash.isEqual(value, defaultConfig[key])) {
|
if (!lodash.isEqual(value, defaultConfig[key])) {
|
||||||
result[key] = value;
|
result[key] = value
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(`${_path}/plugins/chatgpt-plugin/config/config.js`, `export default ${JSON.stringify(change, '', '\t')}`, { flag: 'w' })
|
fs.writeFileSync(`${_path}/plugins/chatgpt-plugin/config/config.js`, `export default ${JSON.stringify(change, '', '\t')}`, { flag: 'w' })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
return true;
|
return true
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue