按钮能力支持

This commit is contained in:
xyz 2025-05-05 22:09:09 +08:00
parent 800bc15007
commit d390381a12
3 changed files with 161 additions and 12 deletions

View file

@ -289,7 +289,38 @@ export class Help extends ZZZPlugin {
});
}
async help() {
let buts = [
[
{ text: '卡片', callback: `%card` },
{ text: '体力', callback: `%体力` },
{ text: '面板', callback: `%更新面板` },
{ text: '练度', callback: `%练度统计` }
],
[
{ text: '抽卡', callback: `%抽卡记录` },
{ text: '月报', callback: `%月报` },
{ text: '深渊', callback: `%深渊` },
{ text: '强袭', callback: `%强袭` }
],
[
{ text: '刷新', callback: `%刷新面板` },
{ text: '更新抽卡', callback: `%更新抽卡记录` },
{ text: '电量', callback: `%电量` },
{ text: '兑换码', callback: `%兑换码` }
],
[
{ text: '绑UID', input: `%绑定uid` },
{ text: '扫码', callback: `#扫码登录` },
{ text: '绑定设备', callback: '%绑定设备' }
],[
{text: '项目地址',link:'https://github.com/ZZZure/ZZZeroUID'}
]
];
if (this.e?.isMaster) {
buts.push([
{ text: '插件更新', callback: `%插件更新` },
{ text: '下载资源', callback: `%下载全部资源` }
]);
const _helpData = [
...helpData,
{
@ -409,14 +440,17 @@ export class Help extends ZZZPlugin {
],
},
];
await this.render('help/index.html', {
helpData: _helpData,
});
await this.e.reply([await this.render('help/index.html', {helpData: _helpData, },{retType:'base64'}),segment.button(...buts)]);
return false;
}
await this.render('help/index.html', {
helpData,
});
return false;
await this.e.reply([await this.render('help/index.html', {helpData },{retType:'base64'})
,segment.button(...buts)]);
return false;
}
}

View file

@ -37,6 +37,8 @@ export class Panel extends ZZZPlugin {
{ key: 'zzz.tool.panelList', fn: 'getCharPanelListTool' },
],
});
global.zzzRoleList = [];
global.ifNewChar = false;
}
async handleRule() {
if (!this.e.msg) return;
@ -57,27 +59,61 @@ export class Panel extends ZZZPlugin {
const panelSettings = settings.getConfig('panel');
const coldTime = _.get(panelSettings, 'interval', 300);
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
await this.reply([
`你看,又急~${coldTime}秒内只能刷新一次,请稍后再试`,
segment.button([{ text: '再试一下', callback: '%更新面板' }])
]);
return false;
}
const { api } = await this.getAPI();
await redis.set(`ZZZ:PANEL:${uid}:LASTTIME`, Date.now());
await this.reply('正在刷新面板列表,请稍候...');
await this.reply('正在刷新面板列表,可能需要数分钟或者更长时间,请稍候...如需查看现有角色请使用%面板列表');
await this.getPlayerInfo();
const result = await refreshPanelFunction(api).catch(e => {
this.reply(e.message);
throw e;
});
if (!result) {
await this.reply('面板列表刷新失败,请稍后再试');
global.zzzRoleList = [];
global.ifNewChar = false;
await this.reply([
'面板列表刷新失败,请稍后再试,可尝试绑定设备或扫码登录后再次查询',
segment.button([{ text: '再试一下', callback: '%更新面板' }])
]);
return false;
}
const newChar = result.filter(item => item.isNew);
global.ifNewChar = newChar.length > 0;
const finalData = {
newChar: newChar.length,
list: result,
};
await this.render('panel/refresh.html', finalData);
const role_list = result.map(item => item.name_mi18n);
global.zzzRoleList = roleList;
let buttons = [[]];
const nonChineseOrDigitRegex = /[^\u4E00-\u9FFF0-9]/g;
for (const original_name of role_list) {
let currentRow = buttons[buttons.length - 1];
const cleanedName = original_name.replace(nonChineseOrDigitRegex, '');
const buttonText = cleanedName.length > 0 ? cleanedName[0] : '';
const button = { text: buttonText, callback: `%${original_name}面板` };
currentRow.push(button);
if (currentRow.length >= 6) { // 每行最多6个
buttons.push([]);
}
}
// 处理空列表或最后一个空行
if (buttons.length === 1 && buttons[0].length === 0) {
buttons[0] = [ // 默认按钮
{ text: "更新面板", callback: `%更新面板` },
{ text: "练度统计", callback: "%练度统计" }
];
} else if (buttons[buttons.length - 1].length === 0) {
buttons.pop();
}
await this.reply([await this.render('panel/refresh.html', finalData, { retType: 'base64' }), segment.button(...buttons)]);
}
async getCharPanelList() {
const uid = await this.getUID();
@ -123,6 +159,7 @@ export class Panel extends ZZZPlugin {
const name = match[4];
const data = getPanelOrigin(uid, name);
if (!data) {
global.zzzCurrentCharName = data.name_mi18n || name;
await this.reply(`未找到角色${name}的面板信息,请先刷新面板`);
return;
}
@ -154,6 +191,7 @@ export class Panel extends ZZZPlugin {
return false;
}
if (!data) {
global.zzzCurrentCharName = data.name_mi18n || name;
await this.reply('数据为空');
return false;
}
@ -180,7 +218,22 @@ export class Panel extends ZZZPlugin {
}) : needImg;
if (reply) {
const res = await this.reply(image);
let role = parsedData.name_mi18n;
let buts = [
[{ text: '看看我的面板', callback: '%更新面板' }],
[
{ text: `${role}攻略`, callback: `%${role}攻略` },
{ text: `练度统计`, callback: `%练度统计` },
{ text: `${role}图鉴`, callback: `%${role}图鉴` }
],
[
{ text: `电量`, callback: `%体力` },
{ text: `项目地址`, link: `https://github.com/ZZZure/ZZZeroUID` },
{ text: `伤害`, callback: `%${role}伤害` }
],
];
const res = await this.reply([image, segment.button(...buts)]);
if (res?.message_id && parsedData.role_icon)
await redis.set(
`ZZZ:PANEL:IMAGE:${res.message_id}`,