mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
fix: 使用icqq发送视频
This commit is contained in:
parent
4cbca97c56
commit
0cdd2be29a
3 changed files with 25 additions and 32 deletions
|
|
@ -22,22 +22,7 @@ import loader from '../../../lib/plugins/loader.js'
|
||||||
import VoiceVoxTTS, { supportConfigurations as voxRoleList } from '../utils/tts/voicevox.js'
|
import VoiceVoxTTS, { supportConfigurations as voxRoleList } from '../utils/tts/voicevox.js'
|
||||||
import { supportConfigurations as azureRoleList } from '../utils/tts/microsoft-azure.js'
|
import { supportConfigurations as azureRoleList } from '../utils/tts/microsoft-azure.js'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import { getProxy } from '../utils/proxy.js'
|
import { newFetch } 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ChatgptManagement extends plugin {
|
export class ChatgptManagement extends plugin {
|
||||||
constructor (e) {
|
constructor (e) {
|
||||||
|
|
@ -87,11 +72,11 @@ export class ChatgptManagement extends plugin {
|
||||||
fnc: 'migrateBingAccessToken',
|
fnc: 'migrateBingAccessToken',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
reg: '^#chatgpt切换浏览器$',
|
// reg: '^#chatgpt切换浏览器$',
|
||||||
fnc: 'useBrowserBasedSolution',
|
// fnc: 'useBrowserBasedSolution',
|
||||||
permission: 'master'
|
// permission: 'master'
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
reg: '^#chatgpt切换API$',
|
reg: '^#chatgpt切换API$',
|
||||||
fnc: 'useOpenAIAPIBasedSolution',
|
fnc: 'useOpenAIAPIBasedSolution',
|
||||||
|
|
@ -237,7 +222,7 @@ export class ChatgptManagement extends plugin {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
/** 命令正则匹配 */
|
/** 命令正则匹配 */
|
||||||
reg: '^#(关闭|打开)群聊上下文$',
|
reg: '^#(chatgpt)?(关闭|打开)群聊上下文$',
|
||||||
/** 执行方法 */
|
/** 执行方法 */
|
||||||
fnc: 'enableGroupContext',
|
fnc: 'enableGroupContext',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
|
|
@ -248,16 +233,16 @@ export class ChatgptManagement extends plugin {
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#(设置|修改)管理密码',
|
reg: '^#(chatgpt)?(设置|修改)管理密码',
|
||||||
fnc: 'setAdminPassword',
|
fnc: 'setAdminPassword',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#(设置|修改)用户密码',
|
reg: '^#(chatgpt)?(设置|修改)用户密码',
|
||||||
fnc: 'setUserPassword'
|
fnc: 'setUserPassword'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#工具箱',
|
reg: '^#(chatgpt)?工具箱',
|
||||||
fnc: 'toolsPage',
|
fnc: 'toolsPage',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
},
|
},
|
||||||
|
|
@ -275,7 +260,7 @@ export class ChatgptManagement extends plugin {
|
||||||
fnc: 'commandHelp'
|
fnc: 'commandHelp'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#语音切换.*',
|
reg: '^#(chatgpt)?语音切换.*',
|
||||||
fnc: 'ttsSwitch',
|
fnc: 'ttsSwitch',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
},
|
},
|
||||||
|
|
@ -897,7 +882,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
||||||
let use = await redis.get('CHATGPT:USE')
|
let use = await redis.get('CHATGPT:USE')
|
||||||
if (use !== 'bing') {
|
if (use !== 'bing') {
|
||||||
await redis.set('CHATGPT:USE', 'bing')
|
await redis.set('CHATGPT:USE', 'bing')
|
||||||
await this.reply('已切换到基于微软新必应的解决方案,如果已经对话过务必执行`#结束对话`避免引起404错误')
|
await this.reply('已切换到基于微软Copilot(必应)的解决方案,如果已经对话过务必执行`#结束对话`避免引起404错误')
|
||||||
} else {
|
} else {
|
||||||
await this.reply('当前已经是必应Bing模式了')
|
await this.reply('当前已经是必应Bing模式了')
|
||||||
}
|
}
|
||||||
|
|
@ -1564,7 +1549,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
const chatdata = data.chatConfig || {}
|
const chatdata = data.chatConfig || {}
|
||||||
for (let [keyPath, value] of Object.entries(chatdata)) {
|
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) {
|
if (Config[keyPath] != value) {
|
||||||
changeConfig.push({
|
changeConfig.push({
|
||||||
item: keyPath,
|
item: keyPath,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { SunoClient } from '../client/SunoClient.js'
|
||||||
import { Config } from '../utils/config.js'
|
import { Config } from '../utils/config.js'
|
||||||
import { downloadFile, maskEmail } from '../utils/common.js'
|
import { downloadFile, maskEmail } from '../utils/common.js'
|
||||||
import common from '../../../lib/common/common.js'
|
import common from '../../../lib/common/common.js'
|
||||||
|
import lodash from 'lodash'
|
||||||
|
|
||||||
export class Vocal extends plugin {
|
export class Vocal extends plugin {
|
||||||
constructor (e) {
|
constructor (e) {
|
||||||
|
|
@ -87,10 +88,13 @@ export class Vocal extends plugin {
|
||||||
let songs = await client.createSong(description)
|
let songs = await client.createSong(description)
|
||||||
let messages = ['提示词:' + description]
|
let messages = ['提示词:' + description]
|
||||||
for (let song of songs) {
|
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))
|
messages.push(segment.image(song.image_url))
|
||||||
let videoPath = await downloadFile(song.video_url, `suno/${song.title}.mp4`)
|
// let videoPath = await downloadFile(song.video_url, `suno/${song.title}.mp4`, false, false, {
|
||||||
messages.push(segment.video(videoPath))
|
// 'User-Agent': ''
|
||||||
|
// })
|
||||||
|
messages.push(segment.video(song.video_url))
|
||||||
}
|
}
|
||||||
await e.reply(common.makeForwardMsg(e, messages, '音乐合成结果'))
|
await e.reply(common.makeForwardMsg(e, messages, '音乐合成结果'))
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -1055,10 +1055,14 @@ export async function getOrDownloadFile (destPath, url, ignoreCertificateError =
|
||||||
* @param destPath 目标路径,如received/abc.pdf. 目前如果文件名重复会覆盖。
|
* @param destPath 目标路径,如received/abc.pdf. 目前如果文件名重复会覆盖。
|
||||||
* @param absolute 是否是绝对路径,默认为false,此时拼接在data/chatgpt下
|
* @param absolute 是否是绝对路径,默认为false,此时拼接在data/chatgpt下
|
||||||
* @param ignoreCertificateError 忽略证书错误
|
* @param ignoreCertificateError 忽略证书错误
|
||||||
|
* @param headers
|
||||||
* @returns {Promise<string>} 最终下载文件的存储位置
|
* @returns {Promise<string>} 最终下载文件的存储位置
|
||||||
*/
|
*/
|
||||||
export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true) {
|
export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true, headers) {
|
||||||
let init = {}
|
let init = {}
|
||||||
|
if (headers) {
|
||||||
|
init.headers = headers
|
||||||
|
}
|
||||||
if (ignoreCertificateError && url.startsWith('https')) {
|
if (ignoreCertificateError && url.startsWith('https')) {
|
||||||
init.agent = new https.Agent({
|
init.agent = new https.Agent({
|
||||||
rejectUnauthorized: !ignoreCertificateError
|
rejectUnauthorized: !ignoreCertificateError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue