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 { try {
let { Panel } = await import('../../../StarRail-plugin/apps/panel.js') if (character) {
uid = await redis.get(`STAR_RAILWAY:UID:${qq}`) let ProfileDetail = (await import('../../../miao-plugin/apps/profile/ProfileDetail.js')).default
if (!uid) { // e.msg = `#${character}面板${uid}`
return '用户没有绑定uid无法查询。可以让用户主动提供uid进行查询' e.original_msg = `*${character}面板${uid}`
} e.user_id = parseInt(qq)
} catch (e) { e.isSr = true
// todo support miao-plugin and sruid await ProfileDetail.detail(e)
return '未安装StarRail-Plugin无法查询' return 'the character panel of star rail has been sent to group. you don\'t need text version'
} } else {
} let ProfileList = (await import('../../../miao-plugin/apps/profile/ProfileList.js')).default
try { e.msg = `*面板${uid}`
let { Panel } = await import('../../../StarRail-plugin/apps/panel.js')
e.msg = character ? `*${character}面板${uid}` : '*更新面板' + uid
e.user_id = qq e.user_id = qq
e.isSr = true e.isSr = true
let panel = new Panel(e) await ProfileList.render(e)
panel.e = e return 'the player panel of genshin impact has been sent to group. you don\'t need text version'
panel.panel(e).catch(e => logger.warn(e))
let uidRes = await fetch('https://avocado.wiki/v1/info/' + uid)
uidRes = await uidRes.json()
let { assistAvatar, displayAvatars } = uidRes.playerDetailInfo
function dealAvatar (avatar) {
delete avatar.position
delete avatar.vo_tag
delete avatar.desc
delete avatar.promption
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()}`
} }