mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
feat: test button
This commit is contained in:
parent
58e6201e6e
commit
a4fc2bb492
6 changed files with 460 additions and 106 deletions
|
|
@ -82,6 +82,20 @@ export class Entertainment extends plugin {
|
|||
fnc: this.sendRandomMessage.bind(this)
|
||||
}
|
||||
]
|
||||
this.reply = async (msg, quote, data) => {
|
||||
let handler = e.runtime?.handler || {}
|
||||
const btns = await handler.call('chatgpt.button.post', this.e)
|
||||
const btnElement = {
|
||||
type: 'button',
|
||||
content: btns
|
||||
}
|
||||
if (Array.isArray(msg)) {
|
||||
msg.push(btnElement)
|
||||
} else {
|
||||
msg = [msg, btnElement]
|
||||
}
|
||||
return e.reply(msg, data)
|
||||
}
|
||||
}
|
||||
|
||||
async ocr (e) {
|
||||
|
|
@ -116,7 +130,7 @@ ${translateLangLabels}
|
|||
let result = []
|
||||
let multiText = false
|
||||
if (languageCode !== 'auto' && !translateLangLabelAbbrS.includes(languageCode)) {
|
||||
e.reply(`输入格式有误或暂不支持该语言,\n当前支持${translateLangLabels}`, e.isGroup)
|
||||
this.reply(`输入格式有误或暂不支持该语言,\n当前支持${translateLangLabels}`, e.isGroup)
|
||||
return false
|
||||
}
|
||||
// 引用回复
|
||||
|
|
@ -206,9 +220,9 @@ ${translateLangLabels}
|
|||
} else if (command.includes('qwen')) {
|
||||
Config.translateSource = 'qwen'
|
||||
} else {
|
||||
e.reply('暂不支持该翻译源')
|
||||
this.reply('暂不支持该翻译源')
|
||||
}
|
||||
e.reply('√成功设置翻译源为' + Config.translateSource)
|
||||
this.reply('√成功设置翻译源为' + Config.translateSource)
|
||||
}
|
||||
|
||||
async wordcloud (e) {
|
||||
|
|
@ -216,20 +230,21 @@ ${translateLangLabels}
|
|||
let groupId = e.group_id
|
||||
let lock = await redis.get(`CHATGPT:WORDCLOUD:${groupId}`)
|
||||
if (lock) {
|
||||
await e.reply('别着急,上次统计还没完呢')
|
||||
await this.reply('别着急,上次统计还没完呢')
|
||||
return true
|
||||
}
|
||||
await e.reply('在统计啦,请稍等...')
|
||||
await this.reply('在统计啦,请稍等...')
|
||||
await redis.set(`CHATGPT:WORDCLOUD:${groupId}`, '1', { EX: 600 })
|
||||
try {
|
||||
await makeWordcloud(e, e.group_id)
|
||||
let img = await makeWordcloud(e, e.group_id)
|
||||
this.reply(img, true)
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await e.reply(err)
|
||||
await this.reply(err)
|
||||
}
|
||||
await redis.del(`CHATGPT:WORDCLOUD:${groupId}`)
|
||||
} else {
|
||||
await e.reply('请在群里发送此命令')
|
||||
await this.reply('请在群里发送此命令')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +253,7 @@ ${translateLangLabels}
|
|||
let groupId = e.group_id
|
||||
let lock = await redis.get(`CHATGPT:WORDCLOUD:${groupId}`)
|
||||
if (lock) {
|
||||
await e.reply('别着急,上次统计还没完呢')
|
||||
await this.reply('别着急,上次统计还没完呢')
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -247,21 +262,21 @@ ${translateLangLabels}
|
|||
const duration = !match[1] ? 12 : parseInt(match[1]) // default 12h
|
||||
|
||||
if (duration > 24) {
|
||||
await e.reply('最多只能统计24小时内的记录哦,你可以使用#本周词云和#本月词云获取更长时间的统计~')
|
||||
await this.reply('最多只能统计24小时内的记录哦,你可以使用#本周词云和#本月词云获取更长时间的统计~')
|
||||
return false
|
||||
}
|
||||
await e.reply('在统计啦,请稍等...')
|
||||
await this.reply('在统计啦,请稍等...')
|
||||
|
||||
await redis.set(`CHATGPT:WORDCLOUD:${groupId}`, '1', { EX: 600 })
|
||||
try {
|
||||
await makeWordcloud(e, e.group_id, duration)
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await e.reply(err)
|
||||
await this.reply(err)
|
||||
}
|
||||
await redis.del(`CHATGPT:WORDCLOUD:${groupId}`)
|
||||
} else {
|
||||
await e.reply('请在群里发送此命令')
|
||||
await this.reply('请在群里发送此命令')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,10 +293,10 @@ ${translateLangLabels}
|
|||
}
|
||||
let lock = await redis.get(`CHATGPT:WORDCLOUD_NEW:${groupId}_${userId}`)
|
||||
if (lock) {
|
||||
await e.reply('别着急,上次统计还没完呢')
|
||||
await this.reply('别着急,上次统计还没完呢')
|
||||
return true
|
||||
}
|
||||
await e.reply('在统计啦,请稍等...')
|
||||
await this.reply('在统计啦,请稍等...')
|
||||
let duration = 24
|
||||
if (e.msg.includes('本周')) {
|
||||
const now = new Date() // Get the current date and time
|
||||
|
|
@ -307,11 +322,11 @@ ${translateLangLabels}
|
|||
await makeWordcloud(e, e.group_id, duration, userId)
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await e.reply(err)
|
||||
await this.reply(err)
|
||||
}
|
||||
await redis.del(`CHATGPT:WORDCLOUD_NEW:${groupId}_${userId}`)
|
||||
} else {
|
||||
await e.reply('请在群里发送此命令')
|
||||
await this.reply('请在群里发送此命令')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +342,7 @@ ${translateLangLabels}
|
|||
if (fs.existsSync(resultFileLoc)) {
|
||||
let image = segment.image(fs.createReadStream(resultFileLoc))
|
||||
image.asface = true
|
||||
await e.reply(image, true)
|
||||
await this.reply(image, true)
|
||||
return true
|
||||
}
|
||||
const _path = process.cwd()
|
||||
|
|
@ -349,7 +364,7 @@ ${translateLangLabels}
|
|||
}
|
||||
}
|
||||
if (!url) {
|
||||
await e.reply('不支持合成', true)
|
||||
await this.reply('不支持合成', true)
|
||||
return false
|
||||
}
|
||||
let response = await fetch(url)
|
||||
|
|
@ -359,7 +374,7 @@ ${translateLangLabels}
|
|||
await fs.writeFileSync(resultFileLoc, resultBuffer)
|
||||
let image = segment.image(fs.createReadStream(resultFileLoc))
|
||||
image.asface = true
|
||||
await e.reply(image, true)
|
||||
await this.reply(image, true)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +391,7 @@ ${translateLangLabels}
|
|||
logger.info(groupId)
|
||||
groupId = parseInt(groupId)
|
||||
if (groupId && !e.bot.gl.get(groupId)) {
|
||||
await e.reply('机器人不在这个群里!')
|
||||
await this.reply('机器人不在这个群里!')
|
||||
return
|
||||
}
|
||||
let message = await generateHello()
|
||||
|
|
@ -387,10 +402,10 @@ ${translateLangLabels}
|
|||
sendable = segment.record(audio)
|
||||
}
|
||||
if (!groupId) {
|
||||
await e.reply(sendable)
|
||||
await this.reply(sendable)
|
||||
} else {
|
||||
await e.bot.sendGroupMsg(groupId, sendable)
|
||||
await e.reply('发送成功!')
|
||||
await this.reply('发送成功!')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +578,7 @@ ${translateLangLabels}
|
|||
url = 'http://' + url
|
||||
}
|
||||
let urlLink = new URL(url)
|
||||
await e.reply(
|
||||
await this.reply(
|
||||
await renderUrl(
|
||||
e, urlLink.href,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue