fix: 工具调整

This commit is contained in:
ikechan8370 2025-02-16 21:43:23 +08:00
parent 08afc95f06
commit 777279e410
3 changed files with 19 additions and 54 deletions

View file

@ -557,6 +557,7 @@ class Core {
tools.push(new EditCardTool()) tools.push(new EditCardTool())
tools.push(new JinyanTool()) tools.push(new JinyanTool())
tools.push(new KickOutTool()) tools.push(new KickOutTool())
tools.push(new HandleMessageMsgTool())
} }
if (e.group.is_owner) { if (e.group.is_owner) {
tools.push(new SetTitleTool()) tools.push(new SetTitleTool())

View file

@ -24,7 +24,7 @@ export class EditCardTool extends AbstractTool {
description = 'Useful when you want to edit someone\'s card in the group(群名片)' description = 'Useful when you want to edit someone\'s card in the group(群名片)'
func = async function (opts, e) { func = async function (opts, e) {
let { qq, card, groupId, isAdmin } = opts let { qq, card, groupId, sender, isAdmin } = opts
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim()) qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim()) groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim())
@ -41,7 +41,7 @@ export class EditCardTool extends AbstractTool {
logger.error('获取群信息失败,可能使用的底层协议不完善') logger.error('获取群信息失败,可能使用的底层协议不完善')
} }
logger.info('edit card: ', groupId, qq) logger.info('edit card: ', groupId, qq)
if (isAdmin) { if (isAdmin || sender == qq) {
await group.setCard(qq, card) await group.setCard(qq, card)
} else { } else {
return 'the user is not admin, he can\'t edit card of other people.' return 'the user is not admin, he can\'t edit card of other people.'

View file

@ -22,65 +22,29 @@ export class QueryStarRailTool extends AbstractTool {
} }
func = async function (opts, e) { func = async function (opts, e) {
let { qq, uid, character } = opts let { qq, uid = '', character = '' } = opts
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim()) qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
if (e.at === e.bot.uin) { if (e.at === e.bot.uin) {
e.at = null e.at = null
} }
e.atBot = false e.atBot = false
if (!uid) {
try {
let { Panel } = await import('../../../StarRail-plugin/apps/panel.js')
uid = await redis.get(`STAR_RAILWAY:UID:${qq}`)
if (!uid) {
return '用户没有绑定uid无法查询。可以让用户主动提供uid进行查询'
}
} catch (e) {
// todo support miao-plugin and sruid
return '未安装StarRail-Plugin无法查询'
}
}
try { try {
let { Panel } = await import('../../../StarRail-plugin/apps/panel.js') if (character) {
e.msg = character ? `*${character}面板${uid}` : '*更新面板' + uid let ProfileDetail = (await import('../../../miao-plugin/apps/profile/ProfileDetail.js')).default
e.user_id = qq // e.msg = `#${character}面板${uid}`
e.isSr = true e.original_msg = `*${character}面板${uid}`
let panel = new Panel(e) e.user_id = parseInt(qq)
panel.e = e e.isSr = true
panel.panel(e).catch(e => logger.warn(e)) await ProfileDetail.detail(e)
let uidRes = await fetch('https://avocado.wiki/v1/info/' + uid) return 'the character panel of star rail has been sent to group. you don\'t need text version'
uidRes = await uidRes.json() } else {
let { assistAvatar, displayAvatars } = uidRes.playerDetailInfo let ProfileList = (await import('../../../miao-plugin/apps/profile/ProfileList.js')).default
function dealAvatar (avatar) { e.msg = `*面板${uid}`
delete avatar.position e.user_id = qq
delete avatar.vo_tag e.isSr = true
delete avatar.desc await ProfileList.render(e)
delete avatar.promption return 'the player panel of genshin impact has been sent to group. you don\'t need text version'
delete avatar.relics
delete avatar.behaviorList
delete avatar.images
delete avatar.ranks
if (avatar.equipment) {
avatar.equipment = {
level: avatar.equipment.level,
rank: avatar.equipment.rank,
name: avatar.equipment.name,
skill_desc: avatar.equipment.skill_desc
}
}
} }
dealAvatar(assistAvatar)
if (displayAvatars) {
displayAvatars.forEach(avatar => {
dealAvatar(avatar)
})
}
uidRes.playerDetailInfo.assistAvatar = assistAvatar
uidRes.playerDetailInfo.displayAvatars = displayAvatars
delete uidRes.repository
delete uidRes.version
return `the player info in json format is: \n${JSON.stringify(uidRes)}`
} catch (err) { } catch (err) {
return `failed to query, error: ${err.toString()}` return `failed to query, error: ${err.toString()}`
} }