diff --git a/apps/management.js b/apps/management.js index 3a574c8..0145bcc 100644 --- a/apps/management.js +++ b/apps/management.js @@ -22,22 +22,7 @@ import loader from '../../../lib/plugins/loader.js' import VoiceVoxTTS, { supportConfigurations as voxRoleList } from '../utils/tts/voicevox.js' import { supportConfigurations as azureRoleList } from '../utils/tts/microsoft-azure.js' import fetch from 'node-fetch' -import { getProxy } from '../utils/proxy.js' - -let proxy = getProxy() -const newFetch = (url, options = {}) => { - const defaultOptions = Config.proxy - ? { - agent: proxy(Config.proxy) - } - : {} - const mergedOptions = { - ...defaultOptions, - ...options - } - - return fetch(url, mergedOptions) -} +import { newFetch } from '../utils/proxy.js' export class ChatgptManagement extends plugin { constructor (e) { @@ -87,11 +72,11 @@ export class ChatgptManagement extends plugin { fnc: 'migrateBingAccessToken', permission: 'master' }, - { - reg: '^#chatgpt切换浏览器$', - fnc: 'useBrowserBasedSolution', - permission: 'master' - }, + // { + // reg: '^#chatgpt切换浏览器$', + // fnc: 'useBrowserBasedSolution', + // permission: 'master' + // }, { reg: '^#chatgpt切换API$', fnc: 'useOpenAIAPIBasedSolution', @@ -237,7 +222,7 @@ export class ChatgptManagement extends plugin { }, { /** 命令正则匹配 */ - reg: '^#(关闭|打开)群聊上下文$', + reg: '^#(chatgpt)?(关闭|打开)群聊上下文$', /** 执行方法 */ fnc: 'enableGroupContext', permission: 'master' @@ -248,16 +233,16 @@ export class ChatgptManagement extends plugin { permission: 'master' }, { - reg: '^#(设置|修改)管理密码', + reg: '^#(chatgpt)?(设置|修改)管理密码', fnc: 'setAdminPassword', permission: 'master' }, { - reg: '^#(设置|修改)用户密码', + reg: '^#(chatgpt)?(设置|修改)用户密码', fnc: 'setUserPassword' }, { - reg: '^#工具箱', + reg: '^#(chatgpt)?工具箱', fnc: 'toolsPage', permission: 'master' }, @@ -275,7 +260,7 @@ export class ChatgptManagement extends plugin { fnc: 'commandHelp' }, { - reg: '^#语音切换.*', + reg: '^#(chatgpt)?语音切换.*', fnc: 'ttsSwitch', permission: 'master' }, @@ -897,7 +882,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务, let use = await redis.get('CHATGPT:USE') if (use !== 'bing') { await redis.set('CHATGPT:USE', 'bing') - await this.reply('已切换到基于微软新必应的解决方案,如果已经对话过务必执行`#结束对话`避免引起404错误') + await this.reply('已切换到基于微软Copilot(必应)的解决方案,如果已经对话过务必执行`#结束对话`避免引起404错误') } else { await this.reply('当前已经是必应Bing模式了') } @@ -1564,7 +1549,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务, const data = await response.json() const chatdata = data.chatConfig || {} for (let [keyPath, value] of Object.entries(chatdata)) { - if (keyPath === 'blockWords' || keyPath === 'promptBlockWords' || keyPath === 'initiativeChatGroups') { value = value.toString().split(/[,,;;\|]/) } + if (keyPath === 'blockWords' || keyPath === 'promptBlockWords' || keyPath === 'initiativeChatGroups') { value = value.toString().split(/[,,;;|]/) } if (Config[keyPath] != value) { changeConfig.push({ item: keyPath, diff --git a/apps/vocal.js b/apps/vocal.js index e6ae112..d6adcb8 100644 --- a/apps/vocal.js +++ b/apps/vocal.js @@ -3,6 +3,7 @@ import { SunoClient } from '../client/SunoClient.js' import { Config } from '../utils/config.js' import { downloadFile, maskEmail } from '../utils/common.js' import common from '../../../lib/common/common.js' +import lodash from 'lodash' export class Vocal extends plugin { constructor (e) { @@ -87,10 +88,13 @@ export class Vocal extends plugin { let songs = await client.createSong(description) let messages = ['提示词:' + description] for (let song of songs) { - messages.push(`歌名:${song.title}, 风格: ${song.metadata.tags}, 长度: ${song.metadata.duration}秒\n歌词:\n${song.metadata.prompt}`) + messages.push(`歌名:${song.title}\n风格: ${song.metadata.tags}\n长度: ${lodash.round(song.metadata.duration, 0)}秒\n歌词:\n${song.metadata.prompt}\n`) + messages.push(`音频链接:${song.audio_url}\n视频链接:${song.video_url}\n封面链接:${song.image_url}\n`) messages.push(segment.image(song.image_url)) - let videoPath = await downloadFile(song.video_url, `suno/${song.title}.mp4`) - messages.push(segment.video(videoPath)) + // let videoPath = await downloadFile(song.video_url, `suno/${song.title}.mp4`, false, false, { + // 'User-Agent': '' + // }) + messages.push(segment.video(song.video_url)) } await e.reply(common.makeForwardMsg(e, messages, '音乐合成结果')) return true diff --git a/utils/common.js b/utils/common.js index 5adccbc..808be0a 100644 --- a/utils/common.js +++ b/utils/common.js @@ -1055,10 +1055,14 @@ export async function getOrDownloadFile (destPath, url, ignoreCertificateError = * @param destPath 目标路径,如received/abc.pdf. 目前如果文件名重复会覆盖。 * @param absolute 是否是绝对路径,默认为false,此时拼接在data/chatgpt下 * @param ignoreCertificateError 忽略证书错误 + * @param headers * @returns {Promise} 最终下载文件的存储位置 */ -export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true) { +export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true, headers) { let init = {} + if (headers) { + init.headers = headers + } if (ignoreCertificateError && url.startsWith('https')) { init.agent = new https.Agent({ rejectUnauthorized: !ignoreCertificateError