From ced2b4eeb6bfeeeb0e1533c325332fc5f1f26972 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sun, 25 Jun 2023 23:18:54 +0800 Subject: [PATCH] feat: add a tool --- apps/chat.js | 2 ++ utils/tools/QueryGenshinTool.js | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 utils/tools/QueryGenshinTool.js diff --git a/apps/chat.js b/apps/chat.js index c8b3752..f707777 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -64,6 +64,7 @@ import { ImageCaptionTool } from '../utils/tools/ImageCaptionTool.js' import { TTSTool } from '../utils/tools/TTSTool.js' import { ProcessPictureTool } from '../utils/tools/ProcessPictureTool.js' import { APTool } from '../utils/tools/APTool.js' +import {QueryGenshinTool} from "../utils/tools/QueryGenshinTool.js"; try { await import('emoji-strip') } catch (err) { @@ -1985,6 +1986,7 @@ export class chatgpt extends plugin { // new SendDiceTool(), new EditCardTool(), new QueryStarRailTool(), + new QueryGenshinTool(), new WebsiteTool(), new JinyanTool(), new KickOutTool(), diff --git a/utils/tools/QueryGenshinTool.js b/utils/tools/QueryGenshinTool.js new file mode 100644 index 0000000..db4eb0c --- /dev/null +++ b/utils/tools/QueryGenshinTool.js @@ -0,0 +1,39 @@ +import { AbstractTool } from './AbstractTool.js' + +export class QueryGenshinTool extends AbstractTool { + name = 'queryGenshin' + + parameters = { + properties: { + qq: { + type: 'string', + description: '要查询的用户的qq号,将使用该qq号绑定的uid进行查询' + }, + uid: { + type: 'string', + description: '游戏的uid,如果用户提供了则传入并优先使用' + } + }, + required: ['qq', 'groupId'] + } + + func = async function (opts, e) { + let { qq, uid } = opts + if (e.at === Bot.uin) { + e.at = null + } + e.atBot = false + try { + let ProfileList = (await import('../../../miao-plugin/apps/profile/ProfileList.js')).default + e.msg = '#面板' + uid + e.user_id = qq + e.isSr = false + await ProfileList.render(e) + return 'the player panel of genshin impact has been sent to group' + } catch (err) { + return `failed to query, error: ${err.toString()}` + } + } + + description = 'Useful when you want to query player information of Genshin Impact(原神). ' +}