chatgpt-plugin/utils/tools/QueryGenshinTool.js
2023-10-14 13:07:01 +08:00

54 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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如果用户提供了则传入并优先使用'
},
character: {
type: 'string',
description: '游戏角色名'
}
},
required: ['qq']
}
func = async function (opts, e) {
let { qq, uid = '', character = '' } = opts
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
if (e.at === e.bot.uin) {
e.at = null
}
e.atBot = false
try {
if (character) {
let ProfileDetail = (await import('../../../miao-plugin/apps/profile/ProfileDetail.js')).default
// e.msg = `#${character}面板${uid}`
e.original_msg = `#${character}面板${uid}`
e.user_id = parseInt(qq)
e.isSr = false
await ProfileDetail.detail(e)
return 'the character panel of genshin impact has been sent to group. you don\'t need text version'
} else {
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. you don\'t need text version'
}
} catch (err) {
return `failed to query, error: ${err.toString()}`
}
}
description = 'Useful when you want to query player information of Genshin Impact(原神). '
}