From 777279e410f4875768377e59e6b71510bcc5bbda Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sun, 16 Feb 2025 21:43:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/core.js | 1 + utils/tools/EditCardTool.js | 4 +- utils/tools/QueryStarRailTool.js | 68 ++++++++------------------------ 3 files changed, 19 insertions(+), 54 deletions(-) diff --git a/model/core.js b/model/core.js index 3c86c73..b076c59 100644 --- a/model/core.js +++ b/model/core.js @@ -557,6 +557,7 @@ class Core { tools.push(new EditCardTool()) tools.push(new JinyanTool()) tools.push(new KickOutTool()) + tools.push(new HandleMessageMsgTool()) } if (e.group.is_owner) { tools.push(new SetTitleTool()) diff --git a/utils/tools/EditCardTool.js b/utils/tools/EditCardTool.js index a8b6364..66d8158 100644 --- a/utils/tools/EditCardTool.js +++ b/utils/tools/EditCardTool.js @@ -24,7 +24,7 @@ export class EditCardTool extends AbstractTool { description = 'Useful when you want to edit someone\'s card in the group(群名片)' 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()) groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim()) @@ -41,7 +41,7 @@ export class EditCardTool extends AbstractTool { logger.error('获取群信息失败,可能使用的底层协议不完善') } logger.info('edit card: ', groupId, qq) - if (isAdmin) { + if (isAdmin || sender == qq) { await group.setCard(qq, card) } else { return 'the user is not admin, he can\'t edit card of other people.' diff --git a/utils/tools/QueryStarRailTool.js b/utils/tools/QueryStarRailTool.js index 5416dd6..49fa587 100644 --- a/utils/tools/QueryStarRailTool.js +++ b/utils/tools/QueryStarRailTool.js @@ -22,65 +22,29 @@ export class QueryStarRailTool extends AbstractTool { } 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()) if (e.at === e.bot.uin) { e.at = null } 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 { - let { Panel } = await import('../../../StarRail-plugin/apps/panel.js') - e.msg = character ? `*${character}面板${uid}` : '*更新面板' + uid - e.user_id = qq - e.isSr = true - let panel = new Panel(e) - panel.e = e - 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 - } - } + 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 = true + await ProfileDetail.detail(e) + 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 + e.msg = `*面板${uid}` + e.user_id = qq + e.isSr = true + await ProfileList.render(e) + return 'the player panel of genshin impact has been sent to group. you don\'t need text version' } - 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) { return `failed to query, error: ${err.toString()}` }