fix: remove useless thing

This commit is contained in:
ikechan8370 2024-03-09 23:37:47 +08:00
parent 5c544a5ca7
commit bd7aac0517
53 changed files with 350 additions and 2639 deletions

View file

@ -1,5 +1,5 @@
import plugin from '../../../lib/plugins/plugin.js'
import {Config} from "../utils/config.js";
import { Config } from '../utils/config.js'
const PLUGIN_CHAT = 'ChatGpt 对话'
const PLUGIN_MANAGEMENT = 'ChatGPT-Plugin 管理'

View file

@ -5,7 +5,6 @@ import { Config, defaultOpenAIAPI } from '../utils/config.js'
import { v4 as uuid } from 'uuid'
import { ChatGPTAPI } from '../utils/openai/chatgpt-api.js'
import SydneyAIClient from '../utils/SydneyAIClient.js'
import { PoeClient } from '../utils/poe/index.js'
import AzureTTS from '../utils/tts/microsoft-azure.js'
import VoiceVoxTTS from '../utils/tts/voicevox.js'
import {
@ -31,7 +30,6 @@ import {
renderUrl
} from '../utils/common.js'
import { ChatGPTPuppeteer } from '../utils/browser.js'
import { KeyvFile } from 'keyv-file'
import { OfficialChatGPTClient } from '../utils/message.js'
import fetch from 'node-fetch'
@ -39,7 +37,7 @@ import { deleteConversation, getConversations, getLatestMessageIdByConversationI
import { convertSpeaker, speakers } from '../utils/tts.js'
import ChatGLMClient from '../utils/chatglm.js'
import { convertFaces } from '../utils/face.js'
import { originalValues, ConversationManager } from '../model/conversation.js'
import { ConversationManager, originalValues } from '../model/conversation.js'
import BingDrawClient from '../utils/BingDraw.js'
import XinghuoClient from '../utils/xinghuo/xinghuo.js'
import Bard from '../utils/bard.js'
@ -795,10 +793,6 @@ export class chatgpt extends plugin {
key = `CHATGPT:CONVERSATIONS_CHATGLM:${(e.isGroup && Config.groupMerge) ? e.group_id.toString() : e.sender.user_id}`
break
}
case 'browser': {
key = `CHATGPT:CONVERSATIONS_BROWSER:${(e.isGroup && Config.groupMerge) ? e.group_id.toString() : e.sender.user_id}`
break
}
case 'claude2': {
key = `CHATGPT:CLAUDE2_CONVERSATION:${e.sender.user_id}`
break
@ -877,7 +871,7 @@ export class chatgpt extends plugin {
// 字数超限直接返回
return false
}
if (use !== 'api3' && use !== 'poe') {
if (use !== 'api3') {
previousConversation.conversation = {
conversationId: chatMessage.conversationId
}
@ -1534,49 +1528,9 @@ export class chatgpt extends plugin {
user: e.sender.user_id,
cache: cacheOptions
})
let sendMessageResult = await this.chatGPTApi.sendMessage(prompt, conversation)
return sendMessageResult
} else if (use === 'poe') {
const cookie = await redis.get('CHATGPT:POE_TOKEN')
if (!cookie) {
throw new Error('未绑定Poe Cookie请使用#chatgpt设置Poe token命令绑定cookie')
}
let client = new PoeClient({
quora_cookie: cookie,
proxy: Config.proxy
})
await client.setCredentials()
await client.getChatId()
let ai = 'a2' // todo
await client.sendMsg(ai, prompt)
const response = await client.getResponse(ai)
return {
text: response.data
}
return await this.chatGPTApi.sendMessage(prompt, conversation)
} else if (use === 'claude') {
// slack已经不可用移除
// let client = new SlackClaudeClient({
// slackUserToken: Config.slackUserToken,
// slackChannelId: Config.slackChannelId
// })
// let conversationId = await redis.get(`CHATGPT:SLACK_CONVERSATION:${e.sender.user_id}`)
// if (!conversationId) {
// // 如果是新对话
// if (Config.slackClaudeEnableGlobalPreset && (useCast?.slack || Config.slackClaudeGlobalPreset)) {
// // 先发送设定
// let prompt = (useCast?.slack || Config.slackClaudeGlobalPreset)
// let emotion = await AzureTTS.getEmotionPrompt(e)
// if (emotion) {
// prompt = prompt + '\n' + emotion
// }
// await client.sendMessage(prompt, e)
// logger.info('claudeFirst:', prompt)
// }
// }
// let text = await client.sendMessage(prompt, e)
// return {
// text
// }
const client = new ClaudeAPIClient({
key: Config.claudeApiKey,
model: Config.claudeApiModel || 'claude-3-sonnet-20240229',
@ -2408,30 +2362,6 @@ export class chatgpt extends plugin {
this.reply('总额度:$' + hardLimit + '\n已经使用额度$' + totalUsage / 100 + '\n当前剩余额度$' + left + '\n到期日期(UTC)' + expiresAt)
}
/**
* #chatgpt
* @param prompt 问题
* @param conversation 对话
*/
async chatgptBrowserBased (prompt, conversation) {
let option = { markdown: true }
if (Config['2captchaToken']) {
option.captchaToken = Config['2captchaToken']
}
// option.debug = true
option.email = Config.username
option.password = Config.password
this.chatGPTApi = new ChatGPTPuppeteer(option)
logger.info(`chatgpt prompt: ${prompt}`)
let sendMessageOption = {
timeoutMs: 120000
}
if (conversation) {
sendMessageOption = Object.assign(sendMessageOption, conversation)
}
return await this.chatGPTApi.sendMessage(prompt, sendMessageOption)
}
/**
* 其他模式
* @param e

View file

@ -4,7 +4,6 @@ import { generateHello } from '../utils/randomMessage.js'
import { generateVitsAudio } from '../utils/tts.js'
import fs from 'fs'
import { emojiRegex, googleRequestUrl } from '../utils/emoj/index.js'
import fetch from 'node-fetch'
import { getImageOcrText, getImg, makeForwardMsg, mkdirs, renderUrl } from '../utils/common.js'
import uploadRecord from '../utils/uploadRecord.js'
import { makeWordcloud } from '../utils/wordcloud/wordcloud.js'

View file

@ -99,13 +99,8 @@ export class ChatgptManagement extends plugin {
permission: 'master'
},
{
reg: '^#chatgpt切换(Poe|poe)$',
fnc: 'useClaudeBasedSolution',
permission: 'master'
},
{
reg: '^#chatgpt切换(Claude|claude|slack)$',
fnc: 'useSlackClaudeBasedSolution',
reg: '^#chatgpt切换(Claude|claude)$',
fnc: 'useClaudeAPIBasedSolution',
permission: 'master'
},
{
@ -923,23 +918,13 @@ azure语音Azure 语音是微软 Azure 平台提供的一项语音服务,
}
}
async useClaudeBasedSolution (e) {
let use = await redis.get('CHATGPT:USE')
if (use !== 'poe') {
await redis.set('CHATGPT:USE', 'poe')
await this.reply('已切换到基于Quora\'s POE的解决方案')
} else {
await this.reply('当前已经是POE模式了')
}
}
async useSlackClaudeBasedSolution () {
async useClaudeAPIBasedSolution () {
let use = await redis.get('CHATGPT:USE')
if (use !== 'claude') {
await redis.set('CHATGPT:USE', 'claude')
await this.reply('已切换到基于slack claude机器人的解决方案')
await this.reply('已切换到基于ClaudeAPI的解决方案')
} else {
await this.reply('当前已经是claude模式了')
await this.reply('当前已经是Claude模式了')
}
}
@ -949,7 +934,7 @@ azure语音Azure 语音是微软 Azure 平台提供的一项语音服务,
await redis.set('CHATGPT:USE', 'claude2')
await this.reply('已切换到基于claude.ai的解决方案')
} else {
await this.reply('当前已经是claude2模式了')
await this.reply('当前已经是claude.ai模式了')
}
}

View file

@ -1,10 +1,8 @@
import plugin from '../../../lib/plugins/plugin.js'
import fs from 'fs'
import _ from 'lodash'
import { Config } from '../utils/config.js'
import { getMasterQQ, limitString, makeForwardMsg, maskQQ, getUin } from '../utils/common.js'
import { deleteOnePrompt, getPromptByName, readPrompts, saveOnePrompt } from '../utils/prompts.js'
import AzureTTS from "../utils/tts/microsoft-azure.js";
import AzureTTS from '../utils/tts/microsoft-azure.js'
export class help extends plugin {
constructor (e) {
super({

View file

@ -3,21 +3,11 @@ import plugin from '../../../lib/plugins/plugin.js'
import { createRequire } from 'module'
import _ from 'lodash'
import { Restart } from '../../other/restart.js'
import fs from 'fs'
import {} from '../utils/common.js'
const _path = process.cwd()
const require = createRequire(import.meta.url)
const { exec, execSync } = require('child_process')
const checkAuth = async function (e) {
if (!e.isMaster) {
e.reply('只有主人才能命令ChatGPT哦~(*/ω\*)')
return false
}
return true
}
// 是否在更新中
let uping = false

View file

@ -1,7 +1,7 @@
import plugin from '../../../lib/plugins/plugin.js'
import { SunoClient } from '../client/SunoClient.js'
import { Config } from '../utils/config.js'
import { downloadFile, maskEmail } from '../utils/common.js'
import { maskEmail } from '../utils/common.js'
import common from '../../../lib/common/common.js'
import lodash from 'lodash'