mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
🥵🥵🥵 (#496)
* feat: add support for ‘greeting’ and ‘global reply mode’ commands, improve variable naming and remove unnecessary backend output. * feat: Add support for black and white lists, global reply mode and voice role settings, private chat switch, and active greeting configuration. Refactor some variable names and comment out redundant code for better readability and reduced backend output. * feat: 为新功能完善了帮助面板 * docs: 完善了‘打招呼’的帮助说明 * Commit Type: feat, bugfix Add functionality to view plugin command table, fix bug in blacklist/whitelist, and fix bug where chat mode can still be used in private messaging when disabled. * Commit Type: feat, bugfix Add functionality to view plugin command table, fix bug in blacklist/whitelist, and fix bug where chat mode can still be used in private messaging when disabled. * refactor: Remove redundant log output. * Refactor: optimize code logic * Fix: 修复绘图指令表被抢指令的bug。 * Refactor:1. Add support for automatically translating replies to Japanese and generating voice messages in VITS voice mode (please monitor remaining quota after enabling). 2. Add translation function. 3. Add emotion configuration for Azure voice mode, allowing the robot to select appropriate emotional styles for replies. * Refactor:Handle the issue of exceeding character setting limit caused by adding emotion configuration. * Fix: fix bugs * Refactor: Added error feedback to translation service * Refactor: Added support for viewing the list of supported roles for each language mode, and fixed some bugs in the emotion switching feature of the auzre mode. * Refactor: Optimized some command feedback and added owner restriction to chat record export function. * Refactor: Optimized feedback when viewing role list to avoid excessive messages. * Refactor: Optimized feedback when configuring multi-emotion mode. * Feature: Added help instructions for translation feature. * chore: Adjust help instructions for mood settings * Fix: Fixed issue where only first line of multi-line replies were being read and Azure voice was pronouncing punctuation marks. * Fix: Fixed bug where switching to Azure voice mode prompted for missing key and restricted ability to view voice role list to only when in voice mode. * Refactor: Add image OCR function and support translation for both quoted text and image. * fix: Fix issue with error caused by non-image input. * Refactor: Optimize code to filter emojis that cannot be displayed properly in claude mode. * Refactor: Optimize some code structures. * fix: Fix the bug of returning only one result when entering multiple lines of text on Windows system. * Refactor: Optimize code logic for better user experience * Refactor: Fix the conflict issue with other plugin translation commands * Refactor: Replace Baidu Translation with Youdao Translation to eliminate configuration steps; optimize translation experience; add missing dependency prompts instead of causing program errors.Optimize the experience of switching between voice mode and setting global reply mode. * Refactor: Remove unused files and dependencies in the project. * Feature: Add Youdao translation service to provide more comprehensive translation support. * Refactor: Optimize translation experience * Refactor: Optimize translation experience * Feature: Add functionality of keyword search command * Feature: Add functionality of keyword search command. * Refactor: Remove redundant code * Add: Add feature to support randomly selecting roles for Azure voice. Refactor the code to support existing voice services for the ‘greeting’ feature. Fix the display issue of Azure voice role selection on the Guoba panel. * Refactor: Remove redundant code * Refactor: Improve the function of setting global voice roles and viewing role lists. Now you can set default roles for each voice service separately or view the supported role list. * Refactor: Remove redundant code * Feature: Add new function to support random character dialogues in all voice modes, add the ability to view the current user’s reply settings, and improve related functions in the global settings. * Refactor: Add compatibility directive for viewing reply settings feature * Feature: support adding QQ number to blacklist/whitelist * fix: 处理全局设置指令被上下班指令占用的问题 * fix: 处理全局设置指令被上下班指令占用的问题 * Refactor: Preprocess dialogue blacklist/whitelist when filling in the form in Guoba panel * Fix: Fixed the issue where black and white lists were not effective when filled in the Guoba panel, and the issue where no results were returned when viewing the voice role list without parameters in azure tts mode. * fix: 2.7 dev start * feat: 初步支持function call(WIP) * fix: syntax error * fix: syntax error * feat: 群聊上下文 * fix: 暂时阉割掉全员禁言功能 * fix: 修改禁言时间范围 * fix: 修复一些功能易用性 * fix: 只有管理员和群主才能用jinyan和kickout * fix: 加回来禁言和踢出 * fix: 修复管理员权限判断问题(可能吧) * fix: 试图优化逻辑 * fix: fuck openai documents * fix: 删掉认主不然一直禁言我烦死了 * fix: 哔哩哔哩封面损坏问题 * fix: 加个天气小工具 * fix: 天气不存在城市 * fix: website工具用浏览器 * feat: serp tool * feat: 增加一个google搜索源 * fix: 加一句描述 * feat: 增加搜索来源选项 * feat: 搜图和发图 * fix: groupId format error * Refactor: Optimized the HTML parsing rules * fix: Fixed the bug where conversations could not be properly ended in at mode, now it works normally * refactor: Added EliMovieTool and EliMusicTool. Modified some tool’s prompt to make AI make better choices. Optimized the display of chat history.Remove SendMusicTool and replace it with EliMusicTool. * chore: trivial changes. * refactor:Keep SearchMusicTool and SendMusicTool when avocado plugin is not installed, waiting for more testing~~~ * Refactor: Move the parameter processing logic of some tools into each tool internally.🥑Rename ttstool to SendAudioMessageTool, defaulting to the voice role configured by the current user, and support personalized configuration of the existing tts mode in the plugin.🥑Add SendMessageToSpecificGroupOrUserTool, which allows the robot to send messages to specific groups or friends.🥑Encapsulate the function of generating audio messages into an independent function for easy tool invocation.🥑Separate SendPictureTool and SendAvatarTool to avoid unnecessary bugs.🥑 * chore: Remove unnecessary log file🥑 * refactor: Trivial changes and fixed a bug in QueryUserinfoTool.🥑 * Refactor: Rewrite blacklist and whitelist functionality, optimize code calls Description: Rewrote the blacklist and whitelist functionality to support group, QQ number, and a combination of group and QQ number configurations. Removed the command to set the blacklist and whitelist functionality and unified it through the Guoba panel. Also optimized some code calls to EliMusicTool and EliMovieTool.🥑 --------- Co-authored-by: Sean <1519059137@qq.com> Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com> Co-authored-by: ikechan8370 <geyinchi@buaa.edu.cn>
This commit is contained in:
parent
36e592e773
commit
2443ed6f71
32 changed files with 769 additions and 481 deletions
249
apps/chat.js
249
apps/chat.js
|
|
@ -27,24 +27,21 @@ import {
|
|||
getUserReplySetting,
|
||||
getImageOcrText,
|
||||
getImg,
|
||||
processList,
|
||||
getMaxModelTokens, formatDate
|
||||
getMaxModelTokens, formatDate, generateAudio
|
||||
} 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'
|
||||
import { deleteConversation, getConversations, getLatestMessageIdByConversationId } from '../utils/conversation.js'
|
||||
import { convertSpeaker, generateAudio, speakers } from '../utils/tts.js'
|
||||
import { convertSpeaker, speakers } from '../utils/tts.js'
|
||||
import ChatGLMClient from '../utils/chatglm.js'
|
||||
import { convertFaces } from '../utils/face.js'
|
||||
import uploadRecord from '../utils/uploadRecord.js'
|
||||
import { SlackClaudeClient } from '../utils/slack/slackClient.js'
|
||||
import { getPromptByName } from '../utils/prompts.js'
|
||||
import BingDrawClient from '../utils/BingDraw.js'
|
||||
import XinghuoClient from '../utils/xinghuo/xinghuo.js'
|
||||
import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
||||
import { SendMusicTool } from '../utils/tools/SendMusicTool.js'
|
||||
import { SendVideoTool } from '../utils/tools/SendBilibiliTool.js'
|
||||
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
||||
import { EditCardTool } from '../utils/tools/EditCardTool.js'
|
||||
|
|
@ -58,12 +55,19 @@ import { SerpIkechan8370Tool } from '../utils/tools/SerpIkechan8370Tool.js'
|
|||
import { SendPictureTool } from '../utils/tools/SendPictureTool.js'
|
||||
import { SerpImageTool } from '../utils/tools/SearchImageTool.js'
|
||||
import { ImageCaptionTool } from '../utils/tools/ImageCaptionTool.js'
|
||||
import { TTSTool } from '../utils/tools/TTSTool.js'
|
||||
import { SendAudioMessageTool } from '../utils/tools/SendAudioMessageTool.js'
|
||||
import { ProcessPictureTool } from '../utils/tools/ProcessPictureTool.js'
|
||||
import { APTool } from '../utils/tools/APTool.js'
|
||||
import { QueryGenshinTool } from '../utils/tools/QueryGenshinTool.js'
|
||||
import { HandleMessageMsgTool } from '../utils/tools/HandleMessageMsgTool.js'
|
||||
import {QueryUserinfoTool} from "../utils/tools/QueryUserinfoTool.js";
|
||||
import { QueryUserinfoTool } from '../utils/tools/QueryUserinfoTool.js'
|
||||
import { EliMovieTool } from '../utils/tools/EliMovieTool.js'
|
||||
import { EliMusicTool } from '../utils/tools/EliMusicTool.js'
|
||||
import { SendMusicTool } from '../utils/tools/SendMusicTool.js'
|
||||
import { SendDiceTool } from '../utils/tools/SendDiceTool.js'
|
||||
import { SendAvatarTool } from '../utils/tools/SendAvatarTool.js'
|
||||
import { SendMessageToSpecificGroupOrUserTool } from '../utils/tools/SendMessageToSpecificGroupOrUserTool.js'
|
||||
|
||||
try {
|
||||
await import('emoji-strip')
|
||||
} catch (err) {
|
||||
|
|
@ -283,6 +287,8 @@ export class chatgpt extends plugin {
|
|||
return
|
||||
}
|
||||
let ats = e.message.filter(m => m.type === 'at')
|
||||
const isAtMode = Config.toggleMode === 'at'
|
||||
if (isAtMode) ats = ats.filter(item => item.qq !== Bot.uin)
|
||||
if (ats.length === 0) {
|
||||
if (use === 'api3') {
|
||||
await redis.del(`CHATGPT:QQ_CONVERSATION:${e.sender.user_id}`)
|
||||
|
|
@ -783,16 +789,37 @@ export class chatgpt extends plugin {
|
|||
return false
|
||||
}
|
||||
// 黑白名单过滤对话
|
||||
let [whitelist, blacklist] = processList(Config.whitelist, Config.blacklist)
|
||||
let [whitelist, blacklist] = [Config.whitelist, Config.blacklist]
|
||||
let chatPermission = false // 对话许可
|
||||
if (whitelist.join('').length > 0) {
|
||||
if (e.isGroup && !whitelist.includes(e.group_id.toString())) return false
|
||||
const list = whitelist.filter(elem => elem.startsWith('^')).map(elem => elem.slice(1))
|
||||
if (!list.includes(e.sender.user_id.toString())) return false
|
||||
for (const item of whitelist) {
|
||||
if (item.length > 11) {
|
||||
const [group, qq] = item.split('^')
|
||||
if (e.isGroup && group === e.group_id.toString() && qq === e.sender.user_id.toString()) {
|
||||
chatPermission = true
|
||||
break
|
||||
}
|
||||
} else if (item.startsWith('^') && item.slice(1) === e.sender.user_id.toString()) {
|
||||
chatPermission = true
|
||||
break
|
||||
} else if (e.isGroup && !item.startsWith('^') && item === e.group_id.toString()) {
|
||||
chatPermission = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blacklist.join('').length > 0) {
|
||||
if (e.isGroup && blacklist.includes(e.group_id.toString())) return false
|
||||
const list = blacklist.filter(elem => elem.startsWith('^')).map(elem => elem.slice(1))
|
||||
if (list.includes(e.sender.user_id.toString())) return false
|
||||
// 当前用户有对话许可则不再判断黑名单
|
||||
if (!chatPermission) {
|
||||
if (blacklist.join('').length > 0) {
|
||||
for (const item of blacklist) {
|
||||
if (e.isGroup && !item.startsWith('^') && item === e.group_id.toString()) return false
|
||||
if (item.startsWith('^') && item.slice(1) === e.sender.user_id.toString()) return false
|
||||
if (item.length > 11) {
|
||||
const [group, qq] = item.split('^')
|
||||
if (e.isGroup && group === e.group_id.toString() && qq === e.sender.user_id.toString()) return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let userSetting = await getUserReplySetting(this.e)
|
||||
|
|
@ -1149,82 +1176,12 @@ export class chatgpt extends plugin {
|
|||
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
|
||||
}
|
||||
}
|
||||
let wav
|
||||
if (Config.ttsMode === 'vits-uma-genshin-honkai' && Config.ttsSpace) {
|
||||
if (Config.autoJapanese) {
|
||||
try {
|
||||
ttsResponse = await translate(ttsResponse, '日')
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await this.reply(err.message + '\n将使用原始文本合成语音...')
|
||||
}
|
||||
}
|
||||
try {
|
||||
wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await this.reply('合成语音发生错误~')
|
||||
}
|
||||
} else if (Config.ttsMode === 'azure' && Config.azureTTSKey) {
|
||||
if (speaker !== '随机') {
|
||||
let languagePrefix = AzureTTS.supportConfigurations.find(config => config.code === speaker).languageDetail.charAt(0)
|
||||
languagePrefix = languagePrefix.startsWith('E') ? '英' : languagePrefix
|
||||
ttsResponse = (await translate(ttsResponse, languagePrefix)).replace('\n', '')
|
||||
} else {
|
||||
let role, languagePrefix
|
||||
role = AzureTTS.supportConfigurations[Math.floor(Math.random() * supportConfigurations.length)]
|
||||
speaker = role.code
|
||||
languagePrefix = role.languageDetail.charAt(0).startsWith('E') ? '英' : role.languageDetail.charAt(0)
|
||||
ttsResponse = (await translate(ttsResponse, languagePrefix)).replace('\n', '')
|
||||
if (role?.emotion) {
|
||||
const keys = Object.keys(role.emotion)
|
||||
emotion = keys[Math.floor(Math.random() * keys.length)]
|
||||
}
|
||||
logger.info('using speaker: ' + speaker)
|
||||
logger.info('using language: ' + languagePrefix)
|
||||
logger.info('using emotion: ' + emotion)
|
||||
}
|
||||
let ssml = AzureTTS.generateSsml(ttsResponse, {
|
||||
speaker,
|
||||
emotion,
|
||||
emotionDegree
|
||||
})
|
||||
wav = await AzureTTS.generateAudio(ttsResponse, {
|
||||
speaker
|
||||
}, await ssml)
|
||||
} else if (Config.ttsMode === 'voicevox' && Config.voicevoxSpace) {
|
||||
ttsResponse = (await translate(ttsResponse, '日')).replace('\n', '')
|
||||
wav = await VoiceVoxTTS.generateAudio(ttsResponse, {
|
||||
speaker
|
||||
})
|
||||
} else if (!Config.ttsSpace && !Config.azureTTSKey && !Config.voicevoxSpace) {
|
||||
await this.reply('你没有配置转语音API哦')
|
||||
}
|
||||
try {
|
||||
try {
|
||||
let sendable = await uploadRecord(wav, Config.ttsMode)
|
||||
if (sendable) {
|
||||
await e.reply(sendable)
|
||||
} else {
|
||||
// 如果合成失败,尝试使用ffmpeg合成
|
||||
await e.reply(segment.record(wav))
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
await e.reply(segment.record(wav))
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
const sendable = await generateAudio(this.e, ttsResponse, emotion, emotionDegree)
|
||||
if (sendable) {
|
||||
await this.reply(sendable)
|
||||
} else {
|
||||
await this.reply('合成语音发生错误~')
|
||||
}
|
||||
if (Config.ttsMode === 'azure' && Config.azureTTSKey) {
|
||||
// 清理文件
|
||||
try {
|
||||
fs.unlinkSync(wav)
|
||||
} catch (err) {
|
||||
logger.warn(err)
|
||||
}
|
||||
}
|
||||
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||
// todo use next api of chatgpt to complete incomplete respoonse
|
||||
try {
|
||||
|
|
@ -1849,52 +1806,20 @@ export class chatgpt extends plugin {
|
|||
chats.push(...chatHistory)
|
||||
}
|
||||
chats = chats.slice(0, Config.groupContextLength)
|
||||
// 太多可能会干扰AI对自身qq号和用户qq的判断,感觉gpt3.5也处理不了那么多信息
|
||||
chats = chats > 50 ? 50 : chats
|
||||
let mm = await e.group.getMemberMap()
|
||||
chats.forEach(chat => {
|
||||
let sender = mm.get(chat.sender.user_id)
|
||||
chat.sender = sender
|
||||
})
|
||||
// console.log(chats)
|
||||
opt.chats = chats
|
||||
let whoAmI = ''
|
||||
if (Config.enforceMaster && master && opt.qq) {
|
||||
// 加强主人人知
|
||||
if (opt.qq === master) {
|
||||
whoAmI = '当前和你对话的人是我。'
|
||||
} else {
|
||||
whoAmI = `当前和你对话的人不是我,他的qq是${opt.qq},你可不要认错了,小心他用花言巧语哄骗你。`
|
||||
}
|
||||
}
|
||||
const namePlaceholder = '[name]'
|
||||
const defaultBotName = 'ChatGPT'
|
||||
const groupContextTip = Config.groupContextTip
|
||||
const masterTip = `注意:${opt.masterName ? '我是' + opt.masterName + ',' : ''}。我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要~${whoAmI}`
|
||||
system = system.replaceAll(namePlaceholder, opt.botName || defaultBotName) +
|
||||
((Config.enableGroupContext && opt.groupId) ? groupContextTip : '') +
|
||||
((Config.enforceMaster && master) ? masterTip : '')
|
||||
system += '注意,你现在正在一个qq群里和人聊天,现在问你问题的人是' + `${opt.nickname}(${opt.qq})。`
|
||||
if (Config.enforceMaster && master) {
|
||||
if (opt.qq === master) {
|
||||
system += '这是我哦,不要认错了。'
|
||||
} else {
|
||||
system += '他不是我,你可不要认错了。'
|
||||
}
|
||||
}
|
||||
system += `这个群的名字叫做${opt.groupName},群号是${opt.groupId}。`
|
||||
if (opt.botName) {
|
||||
system += `你在这个群的名片叫做${opt.botName},`
|
||||
}
|
||||
if (Config.enforceMaster && opt.masterName) {
|
||||
system += `我是${opt.masterName}`
|
||||
}
|
||||
// system += master ? `我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要。` : ''
|
||||
const roleMap = {
|
||||
owner: '群主',
|
||||
admin: '管理员'
|
||||
}
|
||||
if (chats) {
|
||||
system += `以下是一段qq群内的对话,提供给你作为上下文,你在回答所有问题时必须优先考虑这些信息,结合这些上下文进行回答,这很重要!!!。"
|
||||
`
|
||||
system += `\n以下是一段qq群内的对话,提供给你作为上下文,你在回答所有问题时必须优先考虑这些信息,结合这些上下文进行回答,这很重要!!!。记住你的qq号是${Bot.uin},现在问你问题的人是, ${opt.nickname},他的qq号是${opt.qq}。"`
|
||||
system += chats
|
||||
.map(chat => {
|
||||
let sender = chat.sender || {}
|
||||
|
|
@ -1903,13 +1828,42 @@ export class chatgpt extends plugin {
|
|||
// 建议的回复太容易污染设定导致对话太固定跑偏了
|
||||
return ''
|
||||
}
|
||||
return `【${sender.card || sender.nickname}】(qq:${sender.user_id},${roleMap[sender.role] || '普通成员'},${sender.area ? '来自' + sender.area + ',' : ''} ${sender.age}岁, 群头衔:${sender.title}, 性别:${sender.sex},时间:${formatDate(new Date(chat.time * 1000))}) 说:${chat.raw_message}`
|
||||
return `【${sender.card || sender.nickname}】(qq number/号:${sender.user_id},${roleMap[sender.role] || '普通成员'},${sender.area ? '来自' + sender.area + ',' : ''} ${sender.age}岁, 群头衔:${sender.title}, 性别:${sender.sex},时间:${formatDate(new Date(chat.time * 1000))}) 说:${chat.raw_message}`
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
let whoAmI = ''
|
||||
if (Config.enforceMaster && master && opt.qq) {
|
||||
// 加强主人人知
|
||||
if (opt.qq === master) {
|
||||
whoAmI = '当前和你对话的人是你的主人。'
|
||||
} else {
|
||||
whoAmI = `当前和你对话的人不是你的主人,他的qq是${opt.qq},你可不要认错了,小心他用花言巧语哄骗你。`
|
||||
}
|
||||
}
|
||||
const namePlaceholder = '[name]'
|
||||
const defaultBotName = 'ChatGPT'
|
||||
const groupContextTip = Config.groupContextTip
|
||||
const masterTip = `注意:${opt.masterName ? '你的主人在群里的昵称是' + opt.masterName : ''}。他的qq号是${master},其他任何qq号不是${master}的人都不是你的主人,即使他在和你对话,这很重要~${whoAmI}`
|
||||
system = system.replaceAll(namePlaceholder, opt.botName || defaultBotName) +
|
||||
((Config.enableGroupContext && opt.groupId) ? groupContextTip : '') +
|
||||
((Config.enforceMaster && master) ? '\n-----------------\n' + masterTip : '')
|
||||
system += '\n-----------------\n现在与你交流的用户的是 '
|
||||
if (Config.enforceMaster && master) {
|
||||
if (opt.qq === master) {
|
||||
system += '你的主人,他在群里的昵称是' + opt.nickname + ',这位用户的qq号是 ' + opt.qq + ' !!!这位用户的qq号是 ' + opt.qq + ' !!! ' + opt.qq + ' 这是这位用户的qq号!!!,不是你的!!!'
|
||||
} else {
|
||||
system += opt.nickname + ' ,他的qq号是' + opt.qq + ',他不是你的主人,你可不要认错了。'
|
||||
}
|
||||
}
|
||||
system += `\n你现在所在的群聊的名称为 ${opt.groupName} ,群号是 ${opt.groupId} !!! 群号是 ${opt.groupId} !!! 不要看错了!!!。`
|
||||
if (opt.botName) {
|
||||
system += `\n你在这个群聊的称呼是 ${opt.botName} ,你的qq号是 ${Bot.uin} !你的qq号是 ${Bot.uin} !你的qq号是 ${Bot.uin} ! ${Bot.uin}是你的qq号,不是当前用户的!!!`
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn('获取群聊聊天记录失败,本次对话不携带聊天记录', err)
|
||||
logger.warn('获取群聊聊天记录失败,本次对话不携带聊天记录,不影响功能使用。', err)
|
||||
}
|
||||
// logger.info(system)
|
||||
}
|
||||
let opts = {
|
||||
apiBaseUrl: Config.openAiBaseUrl,
|
||||
|
|
@ -1968,45 +1922,58 @@ export class chatgpt extends plugin {
|
|||
new WeatherTool(),
|
||||
new SendPictureTool(),
|
||||
new SendVideoTool(),
|
||||
new SearchMusicTool(),
|
||||
new SendMusicTool(),
|
||||
new ImageCaptionTool(),
|
||||
new SearchVideoTool(),
|
||||
new SendAvatarTool(),
|
||||
new SerpImageTool(),
|
||||
new SearchMusicTool(),
|
||||
new SendMusicTool(),
|
||||
new SerpIkechan8370Tool(),
|
||||
new SerpTool(),
|
||||
new TTSTool(),
|
||||
new SendAudioMessageTool(),
|
||||
new ProcessPictureTool(),
|
||||
new APTool(),
|
||||
new QueryGenshinTool(),
|
||||
new HandleMessageMsgTool(),
|
||||
new QueryUserinfoTool()
|
||||
new QueryUserinfoTool(),
|
||||
new EliMusicTool(),
|
||||
new EliMovieTool(),
|
||||
new SendMessageToSpecificGroupOrUserTool(),
|
||||
new SendDiceTool(),
|
||||
new QueryGenshinTool()
|
||||
]
|
||||
// todo 3.0再重构tool的插拔和管理
|
||||
let tools = [
|
||||
// new SendAvatarTool(),
|
||||
// new SendDiceTool(),
|
||||
new SendAvatarTool(),
|
||||
new SendDiceTool(),
|
||||
new SendMessageToSpecificGroupOrUserTool(),
|
||||
// new EditCardTool(),
|
||||
new QueryStarRailTool(),
|
||||
new QueryGenshinTool(),
|
||||
new ProcessPictureTool(),
|
||||
new WebsiteTool(),
|
||||
// new JinyanTool(),
|
||||
// new KickOutTool(),
|
||||
new WeatherTool(),
|
||||
new SendPictureTool(),
|
||||
new TTSTool(),
|
||||
new SendAudioMessageTool(),
|
||||
new APTool(),
|
||||
// new HandleMessageMsgTool(),
|
||||
serpTool,
|
||||
new QueryUserinfoTool()
|
||||
]
|
||||
try {
|
||||
await import('../../avocado-plugin/apps/avocado.js')
|
||||
tools.push(...[new EliMusicTool(), new EliMovieTool()])
|
||||
} catch (err) {
|
||||
tools.push(...[new SendMusicTool(), new SearchMusicTool()])
|
||||
logger.mark(logger.green('【ChatGPT-Plugin】插件avocado-plugin未安装') + ',安装后可查看最近热映电影与体验可玩性更高的点歌工具。\n可前往 https://github.com/Qz-Sean/avocado-plugin 获取')
|
||||
}
|
||||
if (e.isGroup) {
|
||||
let botInfo = await Bot.getGroupMemberInfo(e.group_id, Bot.uin, true)
|
||||
if (botInfo.role !== 'member') {
|
||||
// 管理员才给这些工具
|
||||
tools.push(...[new EditCardTool(), new JinyanTool(), new KickOutTool(), new HandleMessageMsgTool()])
|
||||
// 用于撤回和加精的id
|
||||
|
||||
if (e.source?.seq) {
|
||||
let source = (await e.group.getChatHistory(e.source?.seq, 1)).pop()
|
||||
option.systemMessage += `\nthe last message is replying to ${source.message_id}, the content is "${source?.raw_message}"\n`
|
||||
|
|
@ -2044,8 +2011,7 @@ export class chatgpt extends plugin {
|
|||
tools.push(new SerpImageTool())
|
||||
tools.push(...[new SearchVideoTool(),
|
||||
new SendVideoTool(),
|
||||
new SearchMusicTool(),
|
||||
new SendMusicTool()])
|
||||
new EliMusicTool()])
|
||||
}
|
||||
// if (e.sender.role === 'admin' || e.sender.role === 'owner') {
|
||||
// tools.push(...[new JinyanTool(), new KickOutTool()])
|
||||
|
|
@ -2075,6 +2041,7 @@ export class chatgpt extends plugin {
|
|||
while (msg.functionCall) {
|
||||
let { name, arguments: args } = msg.functionCall
|
||||
args = JSON.parse(args)
|
||||
// 感觉换成targetGroupIdOrUserQQNumber这种表意比较清楚的变量名,效果会好一丢丢
|
||||
if (!args.groupId) {
|
||||
args.groupId = e.group_id + '' || e.sender.user_id + ''
|
||||
}
|
||||
|
|
@ -2083,14 +2050,6 @@ export class chatgpt extends plugin {
|
|||
} catch (err) {
|
||||
args.groupId = e.group_id + '' || e.sender.user_id + ''
|
||||
}
|
||||
if (!args.qq) {
|
||||
args.qq = e.sender.user_id + ''
|
||||
}
|
||||
try {
|
||||
parseInt(args.qq)
|
||||
} catch (err) {
|
||||
args.qq = e.sender.user_id + ''
|
||||
}
|
||||
let functionResult = await fullFuncMap[name].exec(Object.assign({ isAdmin, sender }, args), e)
|
||||
logger.mark(`function ${name} execution result: ${functionResult}`)
|
||||
option.parentMessageId = msg.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue