diff --git a/apps/chat.js b/apps/chat.js index 24ae19d..0f3b9ae 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -51,9 +51,10 @@ import { KickOutTool } from '../utils/tools/KickOutTool.js' import { SendAvatarTool } from '../utils/tools/SendAvatarTool.js' import { SendDiceTool } from '../utils/tools/SendDiceTool.js' import { EditCardTool } from '../utils/tools/EditCardTool.js' -import {SearchVideoTool} from "../utils/tools/SearchBilibiliTool.js"; -import {SearchMusicTool} from "../utils/tools/SearchMusicTool.js"; -import {QueryStarRailTool} from "../utils/tools/QueryStarRailTool.js"; +import { SearchVideoTool } from '../utils/tools/SearchBilibiliTool.js' +import { SearchMusicTool } from '../utils/tools/SearchMusicTool.js' +import { QueryStarRailTool } from '../utils/tools/QueryStarRailTool.js' +import { WebsiteTool } from '../utils/tools/WebsiteTool.js' try { await import('emoji-strip') } catch (err) { @@ -1925,18 +1926,19 @@ export class chatgpt extends plugin { option = Object.assign(option, conversation) } let tools = [ - new JinyanTool(), new SearchVideoTool(), new SendVideoTool(), new SearchMusicTool(), new SendMusicTool(), - new KickOutTool(), new SendAvatarTool(), // new SendDiceTool(), - new KickOutTool(), new EditCardTool(), - new QueryStarRailTool() + new QueryStarRailTool(), + new WebsiteTool() ] + if (e.sender.role === 'admin' || e.sender.role === 'owner') { + tools.push(...[new JinyanTool(), new KickOutTool()]) + } let funcMap = {} tools.forEach(tool => { funcMap[tool.name] = { diff --git a/utils/tools/KickOutTool.js b/utils/tools/KickOutTool.js index 0e3d44e..9fd9620 100644 --- a/utils/tools/KickOutTool.js +++ b/utils/tools/KickOutTool.js @@ -27,5 +27,5 @@ export class KickOutTool extends AbstractTool { return `the user ${qq} has been kicked out from group ${groupId}` } - description = 'Useful when you want to kick someone out of the group. The input to this tool should be the group number, the qq number of the one who should be kicked out, these two number should be concated with a space. ' + description = 'Useful when you want to kick someone out of the group. ' } diff --git a/utils/tools/WebsiteTool.js b/utils/tools/WebsiteTool.js new file mode 100644 index 0000000..84b4bbc --- /dev/null +++ b/utils/tools/WebsiteTool.js @@ -0,0 +1,29 @@ +import { AbstractTool } from './AbstractTool.js' + +export class WebsiteTool extends AbstractTool { + name = 'website' + + parameters = { + properties: { + url: { + type: 'string', + description: '要访问的网站网址' + } + }, + required: ['url'] + } + + func = async function (opts) { + let { url } = opts + let res = await fetch(url, { + headers: { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36' + } + }) + let text = await res.text() + text = text.slice(0, Math.min(text.length, 4000)) + return `this is part of the content of website:\n ${text}` + } + + description = 'Useful when you want to browse a website by url' +}