mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: emoji缓存
This commit is contained in:
parent
d48748c0f5
commit
028a7c2c4a
1 changed files with 14 additions and 7 deletions
|
|
@ -37,14 +37,21 @@ export class Entertainment extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async combineEmoj (e) {
|
async combineEmoj (e) {
|
||||||
console.log(e.msg)
|
mkdirs('data/chatgpt/emoji')
|
||||||
logger.info('combine')
|
logger.info('combine ' + e.msg)
|
||||||
|
let left = e.msg.codePointAt(0).toString(16).toLowerCase()
|
||||||
|
let right = e.msg.codePointAt(2).toString(16).toLowerCase()
|
||||||
|
let resultFileLoc = `data/chatgpt/emoji/${left}_${right}.jpg`
|
||||||
|
if (fs.existsSync(resultFileLoc)) {
|
||||||
|
let image = segment.image(fs.createReadStream(resultFileLoc))
|
||||||
|
image.asface = true
|
||||||
|
await e.reply(image, true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
const _path = process.cwd()
|
const _path = process.cwd()
|
||||||
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/resources/emojiData.json`)
|
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/resources/emojiData.json`)
|
||||||
const data = fs.readFileSync(fullPath)
|
const data = fs.readFileSync(fullPath)
|
||||||
let emojDataJson = JSON.parse(data)
|
let emojDataJson = JSON.parse(data)
|
||||||
let left = e.msg.codePointAt(0).toString(16).toLowerCase()
|
|
||||||
let right = e.msg.codePointAt(2).toString(16).toLowerCase()
|
|
||||||
logger.mark(`合成emoji:${left} ${right}`)
|
logger.mark(`合成emoji:${left} ${right}`)
|
||||||
let url
|
let url
|
||||||
if (emojDataJson[right]) {
|
if (emojDataJson[right]) {
|
||||||
|
|
@ -64,13 +71,13 @@ export class Entertainment extends plugin {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
let response = await fetch(url)
|
let response = await fetch(url)
|
||||||
mkdirs('data/chatgpt/emoji')
|
|
||||||
let resultFileLoc = `data/chatgpt/emoji/${left}_${right}.jpg`
|
|
||||||
const resultBlob = await response.blob()
|
const resultBlob = await response.blob()
|
||||||
const resultArrayBuffer = await resultBlob.arrayBuffer()
|
const resultArrayBuffer = await resultBlob.arrayBuffer()
|
||||||
const resultBuffer = Buffer.from(resultArrayBuffer)
|
const resultBuffer = Buffer.from(resultArrayBuffer)
|
||||||
await fs.writeFileSync(resultFileLoc, resultBuffer)
|
await fs.writeFileSync(resultFileLoc, resultBuffer)
|
||||||
await e.reply(segment.image(fs.createReadStream(resultFileLoc)), true)
|
let image = segment.image(fs.createReadStream(resultFileLoc))
|
||||||
|
image.asface = true
|
||||||
|
await e.reply(image, true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue