fix: update forward

This commit is contained in:
ikechan8370 2023-09-12 11:14:08 +08:00
parent f620e10abb
commit a91e2c25b3

View file

@ -4,7 +4,7 @@ import { createRequire } from 'module'
import _ from 'lodash' import _ from 'lodash'
import { Restart } from '../../other/restart.js' import { Restart } from '../../other/restart.js'
import fs from 'fs' import fs from 'fs'
import {} from "../utils/common.js"; import {} from '../utils/common.js'
const _path = process.cwd() const _path = process.cwd()
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)
@ -12,7 +12,7 @@ const { exec, execSync } = require('child_process')
const checkAuth = async function (e) { const checkAuth = async function (e) {
if (!e.isMaster) { if (!e.isMaster) {
e.reply(`只有主人才能命令ChatGPT哦~(*/ω\*)`) e.reply('只有主人才能命令ChatGPT哦~(*/ω\*)')
return false return false
} }
return true return true
@ -39,9 +39,6 @@ export class Update extends plugin {
}) })
} }
/** /**
* rule - 更新chatgpt插件 * rule - 更新chatgpt插件
* @returns * @returns
@ -228,17 +225,27 @@ export class Update extends plugin {
} }
/** 制作转发内容 */ /** 制作转发内容 */
if (this.e.isGroup) { if (this.e.group?.makeForwardMsg) {
forwardMsg = await this.e.group.makeForwardMsg(forwardMsg) forwardMsg = await this.e.group.makeForwardMsg(forwardMsg)
} else { } else if (this.e?.friend?.makeForwardMsg) {
forwardMsg = await this.e.friend.makeForwardMsg(forwardMsg) forwardMsg = await this.e.friend.makeForwardMsg(forwardMsg)
} else {
return msg.join('\n')
} }
let dec = 'chatgpt-plugin 更新日志'
/** 处理描述 */ /** 处理描述 */
forwardMsg.data = forwardMsg.data if (typeof (forwardMsg.data) === 'object') {
.replace(/\n/g, '') let detail = forwardMsg.data?.meta?.detail
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___') if (detail) {
.replace(/___+/, `<title color="#777777" size="26">${title}</title>`) detail.news = [{ text: dec }]
}
} else {
forwardMsg.data = forwardMsg.data
.replace(/\n/g, '')
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
.replace(/___+/, `<title color="#777777" size="26">${dec}</title>`)
}
return forwardMsg return forwardMsg
} }