mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
移除apps插件非必要return false,拦截指令向后传递 #138
This commit is contained in:
parent
3273f256fc
commit
9d676fa70a
17 changed files with 82 additions and 173 deletions
|
|
@ -32,8 +32,7 @@ export class Abyss extends ZZZPlugin {
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
if (!abyssData?.has_data) {
|
if (!abyssData?.has_data) {
|
||||||
await this.reply('没有式舆防卫战数据');
|
return this.reply('没有式舆防卫战数据');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const abyss = new ZZZChallenge(abyssData);
|
const abyss = new ZZZChallenge(abyssData);
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,7 @@ export class Calendar extends ZZZPlugin {
|
||||||
)
|
)
|
||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
if (!activityList?.data) {
|
if (!activityList?.data) {
|
||||||
await this.reply('获取活动列表失败');
|
return this.reply('获取活动列表失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const t = activityList?.data?.t || new Date().getTime().toString();
|
const t = activityList?.data?.t || new Date().getTime().toString();
|
||||||
const activityContent = await request
|
const activityContent = await request
|
||||||
|
|
@ -42,8 +41,7 @@ export class Calendar extends ZZZPlugin {
|
||||||
|
|
||||||
const htmlContent = calendarContent?.content || '';
|
const htmlContent = calendarContent?.content || '';
|
||||||
if (!htmlContent) {
|
if (!htmlContent) {
|
||||||
await this.reply('未找到活动日历');
|
return this.reply('未找到活动日历');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const imgReg = /<img.*?src="(.*?)".*?>/g;
|
const imgReg = /<img.*?src="(.*?)".*?>/g;
|
||||||
const imgSrc = imgReg.exec(htmlContent)?.[1];
|
const imgSrc = imgReg.exec(htmlContent)?.[1];
|
||||||
|
|
@ -52,6 +50,5 @@ export class Calendar extends ZZZPlugin {
|
||||||
} else {
|
} else {
|
||||||
await this.reply('未找到活动日历图片');
|
await this.reply('未找到活动日历图片');
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ export class Code extends ZZZPlugin {
|
||||||
}
|
}
|
||||||
async code() {
|
async code() {
|
||||||
const msg = await getCodeMsg();
|
const msg = await getCodeMsg();
|
||||||
await this.reply(msg);
|
return this.reply(msg);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ export class deadly extends ZZZPlugin {
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
if (!deadlyData?.has_data) {
|
if (!deadlyData?.has_data) {
|
||||||
await this.reply('没有危局强袭战数据');
|
return this.reply('没有危局强袭战数据');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const deadly = new Deadly(deadlyData);
|
const deadly = new Deadly(deadlyData);
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -61,15 +61,14 @@ export class GachaLog extends ZZZPlugin {
|
||||||
if (!this.e.isPrivate) {
|
if (!this.e.isPrivate) {
|
||||||
const currentGroup = this.e?.group_id;
|
const currentGroup = this.e?.group_id;
|
||||||
if (!currentGroup) {
|
if (!currentGroup) {
|
||||||
await this.reply('获取群聊ID失败,请尝试私聊发送抽卡链接', false, {
|
return this.reply('获取群聊ID失败,请尝试私聊发送抽卡链接', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!allowGroup) {
|
if (!allowGroup) {
|
||||||
if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) {
|
if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) {
|
||||||
await this.reply(
|
return this.reply(
|
||||||
'当前群聊未开启链接刷新抽卡记录功能,请私聊发送',
|
'当前群聊未开启链接刷新抽卡记录功能,请私聊发送',
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
|
|
@ -77,11 +76,10 @@ export class GachaLog extends ZZZPlugin {
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (blackList.length > 0 && blackList?.includes(currentGroup)) {
|
if (blackList.length > 0 && blackList?.includes(currentGroup)) {
|
||||||
await this.reply(
|
return this.reply(
|
||||||
'当前群聊未开启链接刷新抽卡记录功能,请私聊发送',
|
'当前群聊未开启链接刷新抽卡记录功能,请私聊发送',
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +87,6 @@ export class GachaLog extends ZZZPlugin {
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.reply(
|
await this.reply(
|
||||||
|
|
@ -108,20 +105,18 @@ export class GachaLog extends ZZZPlugin {
|
||||||
async gachaLog() {
|
async gachaLog() {
|
||||||
const msg = this.e.msg.trim();
|
const msg = this.e.msg.trim();
|
||||||
if (msg.includes('取消')) {
|
if (msg.includes('取消')) {
|
||||||
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
|
||||||
this.finish('gachaLog');
|
this.finish('gachaLog');
|
||||||
return false;
|
return this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||||
}
|
}
|
||||||
const key = getQueryVariable(msg, 'authkey');
|
const key = getQueryVariable(msg, 'authkey');
|
||||||
const region = getQueryVariable(msg, 'region');
|
const region = getQueryVariable(msg, 'region');
|
||||||
const game_biz = getQueryVariable(msg, 'game_biz');
|
const game_biz = getQueryVariable(msg, 'game_biz');
|
||||||
if (!key && !region && !game_biz) {
|
if (!key && !region && !game_biz) {
|
||||||
await this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, {
|
this.finish('gachaLog');
|
||||||
|
return this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
this.finish('gachaLog');
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
this.finish('gachaLog');
|
this.finish('gachaLog');
|
||||||
this.getLogWithOutUID(key, region, game_biz);
|
this.getLogWithOutUID(key, region, game_biz);
|
||||||
|
|
@ -129,8 +124,7 @@ export class GachaLog extends ZZZPlugin {
|
||||||
async refreshGachaLog() {
|
async refreshGachaLog() {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||||
await this.reply('国际服不支持此功能');
|
return this.reply('国际服不支持此功能');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!uid) return false;
|
if (!uid) return false;
|
||||||
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
|
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
|
||||||
|
|
@ -139,12 +133,10 @@ export class GachaLog extends ZZZPlugin {
|
||||||
try {
|
try {
|
||||||
const key = await getAuthKey(this.e, this.User, uid);
|
const key = await getAuthKey(this.e, this.User, uid);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
await this.reply('authKey获取失败,请检查cookie是否过期');
|
return this.reply('authKey获取失败,请检查cookie是否过期');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
||||||
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
|
return this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
|
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
|
||||||
this.getLog(key);
|
this.getLog(key);
|
||||||
|
|
@ -164,10 +156,9 @@ export class GachaLog extends ZZZPlugin {
|
||||||
`${name}新增${count[name] || 0}条记录,一共${data[name].length}条记录`
|
`${name}新增${count[name] || 0}条记录,一共${data[name].length}条记录`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.reply(
|
return this.reply(
|
||||||
await common.makeForwardMsg(this.e, msg.join('\n'), '抽卡记录更新成功')
|
await common.makeForwardMsg(this.e, msg.join('\n'), '抽卡记录更新成功')
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
async getLogWithOutUID(key, region, game_biz) {
|
async getLogWithOutUID(key, region, game_biz) {
|
||||||
await this.reply(
|
await this.reply(
|
||||||
|
|
@ -195,11 +186,10 @@ export class GachaLog extends ZZZPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
await this.reply('未查询到uid,请检查链接是否正确', false, {
|
return this.reply('未查询到uid,请检查链接是否正确', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const { data, count } = await updateGachaLog(key, uid, region, game_biz);
|
const { data, count } = await updateGachaLog(key, uid, region, game_biz);
|
||||||
let msg = [];
|
let msg = [];
|
||||||
|
|
@ -209,10 +199,9 @@ export class GachaLog extends ZZZPlugin {
|
||||||
`${name}新增${count[name] || 0}条记录,一共${data[name].length}条记录`
|
`${name}新增${count[name] || 0}条记录,一共${data[name].length}条记录`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.reply(
|
return this.reply(
|
||||||
await common.makeForwardMsg(this.e, msg, '抽卡记录更新成功')
|
await common.makeForwardMsg(this.e, msg, '抽卡记录更新成功')
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async gachaLogAnalysis() {
|
async gachaLogAnalysis() {
|
||||||
|
|
@ -225,7 +214,7 @@ export class GachaLog extends ZZZPlugin {
|
||||||
});
|
});
|
||||||
const data = await anaylizeGachaLog(uid);
|
const data = await anaylizeGachaLog(uid);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await this.reply(
|
return this.reply(
|
||||||
'未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录',
|
'未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录',
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +222,6 @@ export class GachaLog extends ZZZPlugin {
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
data,
|
data,
|
||||||
|
|
@ -243,18 +231,15 @@ export class GachaLog extends ZZZPlugin {
|
||||||
async getGachaLink() {
|
async getGachaLink() {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||||
await this.reply('国际服不支持此功能');
|
return this.reply('国际服不支持此功能');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!uid) return false;
|
if (!uid) return false;
|
||||||
if (!this.e.isPrivate || this.e.isGroup) {
|
if (!this.e.isPrivate || this.e.isGroup) {
|
||||||
await this.reply('请私聊获取抽卡链接', false, { at: true });
|
return this.reply('请私聊获取抽卡链接', false, { at: true });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const key = await getAuthKey(this.e, this.User, uid);
|
const key = await getAuthKey(this.e, this.User, uid);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
await this.reply('authKey获取失败,请检查cookie是否过期');
|
return this.reply('authKey获取失败,请检查cookie是否过期');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const link = await getZZZGachaLink(key);
|
const link = await getZZZGachaLink(key);
|
||||||
await this.reply(link);
|
await this.reply(link);
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,7 @@ export class Guide extends ZZZPlugin {
|
||||||
}
|
}
|
||||||
group = Number(group);
|
group = Number(group);
|
||||||
if (group > guides.guideMaxNum) {
|
if (group > guides.guideMaxNum) {
|
||||||
await this.reply(`超过攻略数量(${guides.guideMaxNum})`);
|
return this.reply(`超过攻略数量(${guides.guideMaxNum})`);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (alias === '设置默认' || alias === '设置所有') {
|
if (alias === '设置默认' || alias === '设置所有') {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -79,8 +78,7 @@ export class Guide extends ZZZPlugin {
|
||||||
const name = char.aliasToName(alias);
|
const name = char.aliasToName(alias);
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
await this.reply('该角色不存在');
|
return this.reply('该角色不存在');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group === 0) {
|
if (group === 0) {
|
||||||
|
|
@ -102,20 +100,17 @@ export class Guide extends ZZZPlugin {
|
||||||
if (msg.length) {
|
if (msg.length) {
|
||||||
await this.reply(await common.makeForwardMsg(this.e, msg));
|
await this.reply(await common.makeForwardMsg(this.e, msg));
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const guidePath = await this.getGuidePath(group, name, !!isUpdate);
|
const guidePath = await this.getGuidePath(group, name, !!isUpdate);
|
||||||
if (!guidePath) {
|
if (!guidePath) {
|
||||||
this.e.reply(
|
return this.e.reply(
|
||||||
`暂无${name}攻略 (${
|
`暂无${name}攻略 (${
|
||||||
guides.guideSources[group - 1]
|
guides.guideSources[group - 1]
|
||||||
})\n请尝试其他的攻略来源查询`
|
})\n请尝试其他的攻略来源查询`
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await this.e.reply(segment.image(guidePath));
|
await this.e.reply(segment.image(guidePath));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 下载攻略图 */
|
/** 下载攻略图 */
|
||||||
|
|
@ -128,9 +123,8 @@ export class Guide extends ZZZPlugin {
|
||||||
try {
|
try {
|
||||||
mysRes = await Promise.all(mysRes);
|
mysRes = await Promise.all(mysRes);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.e.reply('暂无攻略数据,请稍后再试');
|
|
||||||
console.log(`米游社接口报错:${error}}`);
|
console.log(`米游社接口报错:${error}}`);
|
||||||
return false;
|
return this.e.reply('暂无攻略数据,请稍后再试');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索时过滤特殊符号,譬如「11号」
|
// 搜索时过滤特殊符号,譬如「11号」
|
||||||
|
|
|
||||||
|
|
@ -481,11 +481,9 @@ export class Help extends ZZZPlugin {
|
||||||
await this.render('help/index.html', {
|
await this.render('help/index.html', {
|
||||||
helpData: _helpData,
|
helpData: _helpData,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await this.render('help/index.html', {
|
await this.render('help/index.html', {
|
||||||
helpData,
|
helpData,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import settings from '../../lib/settings.js';
|
||||||
|
|
||||||
export async function addAlias() {
|
export async function addAlias() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg);
|
const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg);
|
||||||
const key = match[1];
|
const key = match[1];
|
||||||
|
|
@ -34,8 +33,7 @@ export async function addAlias() {
|
||||||
|
|
||||||
export async function deleteAlias() {
|
export async function deleteAlias() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /删除别名(\S+)$/g.exec(this.e.msg);
|
const match = /删除别名(\S+)$/g.exec(this.e.msg);
|
||||||
const key = match[1];
|
const key = match[1];
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,21 @@ import settings from '../../lib/settings.js';
|
||||||
/** 设置渲染精度 */
|
/** 设置渲染精度 */
|
||||||
export async function setRenderPrecision() {
|
export async function setRenderPrecision() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /渲染精度(\d+)$/g.exec(this.e.msg);
|
const match = /渲染精度(\d+)$/g.exec(this.e.msg);
|
||||||
const render_precision = Number(match[1]);
|
const render_precision = Number(match[1]);
|
||||||
if (render_precision < 50) {
|
if (render_precision < 50) {
|
||||||
await this.e.reply('渲染精度不能小于50', false, {
|
return this.e.reply('渲染精度不能小于50', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (render_precision > 200) {
|
if (render_precision > 200) {
|
||||||
await this.e.reply('渲染精度不能大于200', false, {
|
return this.e.reply('渲染精度不能大于200', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('config', 'render', {
|
settings.setSingleConfig('config', 'render', {
|
||||||
scale: render_precision,
|
scale: render_precision,
|
||||||
|
|
@ -31,24 +28,21 @@ export async function setRenderPrecision() {
|
||||||
/** 设置刷新抽卡间隔 */
|
/** 设置刷新抽卡间隔 */
|
||||||
export async function setRefreshGachaInterval() {
|
export async function setRefreshGachaInterval() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /刷新抽卡间隔(\d+)$/g.exec(this.e.msg);
|
const match = /刷新抽卡间隔(\d+)$/g.exec(this.e.msg);
|
||||||
const refresh_gacha_interval = Number(match[1]);
|
const refresh_gacha_interval = Number(match[1]);
|
||||||
if (refresh_gacha_interval < 0) {
|
if (refresh_gacha_interval < 0) {
|
||||||
await this.e.reply('刷新抽卡间隔不能小于0秒', false, {
|
return this.e.reply('刷新抽卡间隔不能小于0秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (refresh_gacha_interval > 1000) {
|
if (refresh_gacha_interval > 1000) {
|
||||||
await this.e.reply('刷新抽卡间隔不能大于1000秒', false, {
|
return this.e.reply('刷新抽卡间隔不能大于1000秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('gacha', 'interval', refresh_gacha_interval);
|
settings.setSingleConfig('gacha', 'interval', refresh_gacha_interval);
|
||||||
await this.e.reply(`绝区零刷新抽卡间隔已设置为: ${refresh_gacha_interval}`);
|
await this.e.reply(`绝区零刷新抽卡间隔已设置为: ${refresh_gacha_interval}`);
|
||||||
|
|
@ -57,24 +51,21 @@ export async function setRefreshGachaInterval() {
|
||||||
/** 设置刷新面板间隔 */
|
/** 设置刷新面板间隔 */
|
||||||
export async function setRefreshPanelInterval() {
|
export async function setRefreshPanelInterval() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /刷新面板间隔(\d+)$/g.exec(this.e.msg);
|
const match = /刷新面板间隔(\d+)$/g.exec(this.e.msg);
|
||||||
const refresh_panel_interval = Number(match[1]);
|
const refresh_panel_interval = Number(match[1]);
|
||||||
if (refresh_panel_interval < 0) {
|
if (refresh_panel_interval < 0) {
|
||||||
await this.e.reply('刷新面板间隔不能小于0秒', false, {
|
return this.e.reply('刷新面板间隔不能小于0秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (refresh_panel_interval > 1000) {
|
if (refresh_panel_interval > 1000) {
|
||||||
await this.e.reply('刷新面板间隔不能大于1000秒', false, {
|
return this.e.reply('刷新面板间隔不能大于1000秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('panel', 'interval', refresh_panel_interval);
|
settings.setSingleConfig('panel', 'interval', refresh_panel_interval);
|
||||||
await this.e.reply(
|
await this.e.reply(
|
||||||
|
|
@ -87,24 +78,21 @@ export async function setRefreshPanelInterval() {
|
||||||
/** 设置角色刷新间隔 */
|
/** 设置角色刷新间隔 */
|
||||||
export async function setRefreshCharInterval() {
|
export async function setRefreshCharInterval() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /刷新角色间隔(\d+)$/g.exec(this.e.msg);
|
const match = /刷新角色间隔(\d+)$/g.exec(this.e.msg);
|
||||||
const refresh_char_interval = Number(match[1]);
|
const refresh_char_interval = Number(match[1]);
|
||||||
if (refresh_char_interval < 0) {
|
if (refresh_char_interval < 0) {
|
||||||
await this.e.reply('刷新角色间隔不能小于0秒', false, {
|
return this.e.reply('刷新角色间隔不能小于0秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (refresh_char_interval > 1000) {
|
if (refresh_char_interval > 1000) {
|
||||||
await this.e.reply('刷新角色间隔不能大于1000秒', false, {
|
return this.e.reply('刷新角色间隔不能大于1000秒', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('panel', 'roleInterval', refresh_char_interval);
|
settings.setSingleConfig('panel', 'roleInterval', refresh_char_interval);
|
||||||
await this.e.reply(`绝区零刷新角色间隔已设置为: ${refresh_char_interval}秒`);
|
await this.e.reply(`绝区零刷新角色间隔已设置为: ${refresh_char_interval}秒`);
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ import settings from '../../lib/settings.js';
|
||||||
|
|
||||||
export async function setDefaultDevice() {
|
export async function setDefaultDevice() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
this.setContext('toSetDefaultDevice');
|
this.setContext('toSetDefaultDevice');
|
||||||
await this.reply(
|
await this.reply(
|
||||||
|
|
@ -15,19 +14,16 @@ export async function setDefaultDevice() {
|
||||||
export async function toSetDefaultDevice() {
|
export async function toSetDefaultDevice() {
|
||||||
const msg = this.e.msg.trim();
|
const msg = this.e.msg.trim();
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
return this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (msg.includes('取消')) {
|
if (msg.includes('取消')) {
|
||||||
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
|
||||||
this.finish('toSetDefaultDevice');
|
this.finish('toSetDefaultDevice');
|
||||||
return false;
|
return this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const info = JSON.parse(msg);
|
const info = JSON.parse(msg);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!info?.deviceName ||
|
!info?.deviceName ||
|
||||||
|
|
@ -37,8 +33,7 @@ export async function toSetDefaultDevice() {
|
||||||
!info?.deviceFingerprint ||
|
!info?.deviceFingerprint ||
|
||||||
!info?.deviceProduct
|
!info?.deviceProduct
|
||||||
) {
|
) {
|
||||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setConfig('device', {
|
settings.setConfig('device', {
|
||||||
productName: info.deviceProduct,
|
productName: info.deviceProduct,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import settings from '../../lib/settings.js';
|
||||||
/** 设置默认攻略 */
|
/** 设置默认攻略 */
|
||||||
export async function setDefaultGuide() {
|
export async function setDefaultGuide() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg);
|
const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg);
|
||||||
let guide_id = match[1];
|
let guide_id = match[1];
|
||||||
|
|
@ -36,24 +35,21 @@ export async function setDefaultGuide() {
|
||||||
/** 设置所有攻略显示个数 */
|
/** 设置所有攻略显示个数 */
|
||||||
export async function setMaxForwardGuide() {
|
export async function setMaxForwardGuide() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg);
|
const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg);
|
||||||
const max_forward_guide = Number(match[1]);
|
const max_forward_guide = Number(match[1]);
|
||||||
if (max_forward_guide < 1) {
|
if (max_forward_guide < 1) {
|
||||||
await this.e.reply('所有攻略显示个数不能小于1', false, {
|
return this.e.reply('所有攻略显示个数不能小于1', false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (max_forward_guide > guides.guideMaxNum) {
|
if (max_forward_guide > guides.guideMaxNum) {
|
||||||
await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, {
|
return this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide);
|
settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide);
|
||||||
await this.e.reply(
|
await this.e.reply(
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
export async function uploadCharacterImg() {
|
export async function uploadCharacterImg() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('只有主人才能添加', false, { at: true, recallMsg: 100 });
|
return this.reply('只有主人才能添加', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const reg = /(上传|添加)(.+)(角色|面板)图$/;
|
const reg = /(上传|添加)(.+)(角色|面板)图$/;
|
||||||
const match = this.e.msg.match(reg);
|
const match = this.e.msg.match(reg);
|
||||||
|
|
@ -17,8 +16,7 @@ export async function uploadCharacterImg() {
|
||||||
const charName = match[2].trim();
|
const charName = match[2].trim();
|
||||||
const name = char.aliasToName(charName);
|
const name = char.aliasToName(charName);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
return this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const images = [];
|
const images = [];
|
||||||
// 下面方法来源于miao-plugin/apps/character/ImgUpload.js
|
// 下面方法来源于miao-plugin/apps/character/ImgUpload.js
|
||||||
|
|
@ -70,12 +68,11 @@ export async function uploadCharacterImg() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (images.length <= 0) {
|
if (images.length <= 0) {
|
||||||
this.reply(
|
return this.reply(
|
||||||
'消息中未找到图片,请将要发送的图片与消息一同发送或引用要添加的图像。',
|
'消息中未找到图片,请将要发送的图片与消息一同发送或引用要添加的图像。',
|
||||||
false,
|
false,
|
||||||
{ at: true, recallMsg: 100 }
|
{ at: true, recallMsg: 100 }
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const resourcesImagesPath = imageResourcesPath;
|
const resourcesImagesPath = imageResourcesPath;
|
||||||
const panelImagesPath = path.join(resourcesImagesPath, `panel/${name}`);
|
const panelImagesPath = path.join(resourcesImagesPath, `panel/${name}`);
|
||||||
|
|
@ -96,11 +93,10 @@ export async function uploadCharacterImg() {
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.reply(`成功上传${success}张图片,失败${failed}张图片。`, false, {
|
return this.reply(`成功上传${success}张图片,失败${failed}张图片。`, false, {
|
||||||
at: true,
|
at: true,
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCharacterImages() {
|
export async function getCharacterImages() {
|
||||||
|
|
@ -113,8 +109,7 @@ export async function getCharacterImages() {
|
||||||
const name = char.aliasToName(charName);
|
const name = char.aliasToName(charName);
|
||||||
let page = match[4];
|
let page = match[4];
|
||||||
if (!name) {
|
if (!name) {
|
||||||
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
return this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const pageSize = 5;
|
const pageSize = 5;
|
||||||
const resourcesImagesPath = imageResourcesPath;
|
const resourcesImagesPath = imageResourcesPath;
|
||||||
|
|
@ -131,8 +126,7 @@ export async function getCharacterImages() {
|
||||||
const start = (page - 1) * pageSize;
|
const start = (page - 1) * pageSize;
|
||||||
const end = page * pageSize;
|
const end = page * pageSize;
|
||||||
if (start >= images.length) {
|
if (start >= images.length) {
|
||||||
this.reply('哪有这么多图片', false, { at: true, recallMsg: 100 });
|
return this.reply('哪有这么多图片', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const imagePaths = images.slice(start, end);
|
const imagePaths = images.slice(start, end);
|
||||||
const imageMsg = imagePaths.map(imagePath => {
|
const imageMsg = imagePaths.map(imagePath => {
|
||||||
|
|
@ -150,14 +144,11 @@ export async function getCharacterImages() {
|
||||||
);
|
);
|
||||||
if (imageMsg.length)
|
if (imageMsg.length)
|
||||||
await this.reply(await common.makeForwardMsg(this.e, imageMsg));
|
await this.reply(await common.makeForwardMsg(this.e, imageMsg));
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteCharacterImg() {
|
export async function deleteCharacterImg() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('只有主人才能删除', false, { at: true, recallMsg: 100 });
|
return this.reply('只有主人才能删除', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const reg = /(删除)(.+)(角色|面板)图(.+)$/;
|
const reg = /(删除)(.+)(角色|面板)图(.+)$/;
|
||||||
const match = this.e.msg.match(reg);
|
const match = this.e.msg.match(reg);
|
||||||
|
|
@ -167,8 +158,7 @@ export async function deleteCharacterImg() {
|
||||||
const charName = match[2].trim();
|
const charName = match[2].trim();
|
||||||
const name = char.aliasToName(charName);
|
const name = char.aliasToName(charName);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
return this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const ids = match[4].split(/[,,、\s]+/);
|
const ids = match[4].split(/[,,、\s]+/);
|
||||||
const resourcesImagesPath = imageResourcesPath;
|
const resourcesImagesPath = imageResourcesPath;
|
||||||
|
|
@ -195,6 +185,5 @@ export async function deleteCharacterImg() {
|
||||||
failed ? `删除失败ID为${failed.join(',')}` : '无失败ID',
|
failed ? `删除失败ID为${failed.join(',')}` : '无失败ID',
|
||||||
'删除后会重新排序ID,若想要再次删除,请重新获取图片列表,否则可能会删除错误的图片。',
|
'删除后会重新排序ID,若想要再次删除,请重新获取图片列表,否则可能会删除错误的图片。',
|
||||||
];
|
];
|
||||||
this.reply(common.makeForwardMsg(this.e, msgs));
|
return this.reply(common.makeForwardMsg(this.e, msgs));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,7 @@ export async function hasUpdate() {
|
||||||
/** 开启/关闭自动更新推送 */
|
/** 开启/关闭自动更新推送 */
|
||||||
export async function enableAutoUpdatePush() {
|
export async function enableAutoUpdatePush() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
let enable = true;
|
let enable = true;
|
||||||
if (this.e.msg.includes('关闭')) {
|
if (this.e.msg.includes('关闭')) {
|
||||||
|
|
@ -72,12 +71,11 @@ export async function enableAutoUpdatePush() {
|
||||||
/** 设置自动更新时间 */
|
/** 设置自动更新时间 */
|
||||||
export async function setCheckUpdateCron() {
|
export async function setCheckUpdateCron() {
|
||||||
if (!this.e.isMaster) {
|
if (!this.e.isMaster) {
|
||||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const cron = this.e.msg.split('时间')[1];
|
const cron = this.e.msg.split('时间')[1];
|
||||||
if (!cron) {
|
if (!cron) {
|
||||||
await this.reply(
|
return this.reply(
|
||||||
`[${pluginName}]设置自动更新频率失败,无cron表达式`,
|
`[${pluginName}]设置自动更新频率失败,无cron表达式`,
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +83,6 @@ export async function setCheckUpdateCron() {
|
||||||
recallMsg: 100,
|
recallMsg: 100,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
settings.setSingleConfig('config', 'update', { cron });
|
settings.setSingleConfig('config', 'update', { cron });
|
||||||
await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, {
|
await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, {
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ export class monthly extends ZZZPlugin {
|
||||||
);
|
);
|
||||||
const match = this.e.msg.match(reg);
|
const match = this.e.msg.match(reg);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
await this.reply('参数错误,请检查输入');
|
return this.reply('参数错误,请检查输入');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
let year = match[3];
|
let year = match[3];
|
||||||
let month = match[5];
|
let month = match[5];
|
||||||
|
|
@ -46,12 +45,10 @@ export class monthly extends ZZZPlugin {
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
if (!monthlyResponse) {
|
if (!monthlyResponse) {
|
||||||
await this.reply('获取月报数据失败,请检查日期是否正确');
|
return this.reply('获取月报数据失败,请检查日期是否正确');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!monthlyResponse?.month_data) {
|
if (!monthlyResponse?.month_data) {
|
||||||
await this.reply('月报数据为空');
|
return this.reply('月报数据为空');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const monthlyData = new Monthly(monthlyResponse);
|
const monthlyData = new Monthly(monthlyResponse);
|
||||||
const finalData = {
|
const finalData = {
|
||||||
|
|
@ -72,8 +69,7 @@ export class monthly extends ZZZPlugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!collect) {
|
if (!collect) {
|
||||||
await this.reply('获取月报数据失败');
|
return this.reply('获取月报数据失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const collectData = collect.map(item => new Monthly(item));
|
const collectData = collect.map(item => new Monthly(item));
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ export class Panel extends ZZZPlugin {
|
||||||
const panelSettings = settings.getConfig('panel');
|
const panelSettings = settings.getConfig('panel');
|
||||||
const coldTime = _.get(panelSettings, 'interval', 300);
|
const coldTime = _.get(panelSettings, 'interval', 300);
|
||||||
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
||||||
await this.reply(`${coldTime}秒内只能更新一次,请稍后再试`);
|
return this.reply(`${coldTime}秒内只能更新一次,请稍后再试`);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e))
|
const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e))
|
||||||
let result
|
let result
|
||||||
|
|
@ -115,8 +114,7 @@ export class Panel extends ZZZPlugin {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
const result = getPanelList(uid);
|
const result = getPanelList(uid);
|
||||||
if (!result.length) {
|
if (!result.length) {
|
||||||
await this.reply(`UID:${uid}无本地面板数据,请先%更新面板 或 %更新展柜面板`);
|
return this.reply(`UID:${uid}无本地面板数据,请先%更新面板 或 %更新展柜面板`);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const hasCk = !!(await getCk(this.e));
|
const hasCk = !!(await getCk(this.e));
|
||||||
await this.getPlayerInfo(hasCk ? undefined : parsePlayerInfo({ uid }));
|
await this.getPlayerInfo(hasCk ? undefined : parsePlayerInfo({ uid }));
|
||||||
|
|
@ -169,7 +167,6 @@ export class Panel extends ZZZPlugin {
|
||||||
needSave: false,
|
needSave: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCharPanelTool(e, _data = {}) {
|
async getCharPanelTool(e, _data = {}) {
|
||||||
|
|
@ -184,12 +181,10 @@ export class Panel extends ZZZPlugin {
|
||||||
needImg = true
|
needImg = true
|
||||||
} = _data;
|
} = _data;
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
await this.reply('UID为空');
|
return this.reply('UID为空');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await this.reply('数据为空');
|
return this.reply('数据为空');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (needSave) {
|
if (needSave) {
|
||||||
updatePanelData(uid, [data]);
|
updatePanelData(uid, [data]);
|
||||||
|
|
@ -235,8 +230,7 @@ export class Panel extends ZZZPlugin {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
const result = getPanelList(uid);
|
const result = getPanelList(uid);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
await this.reply('未找到面板数据,请先%更新面板 或 %更新展柜面板');
|
return this.reply('未找到面板数据,请先%更新面板 或 %更新展柜面板');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await this.getPlayerInfo();
|
await this.getPlayerInfo();
|
||||||
result.sort((a, b) => {
|
result.sort((a, b) => {
|
||||||
|
|
@ -293,15 +287,12 @@ export class Panel extends ZZZPlugin {
|
||||||
}
|
}
|
||||||
const id = source?.message_id;
|
const id = source?.message_id;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
await this.reply('未找到消息源,请引用要查看的图片');
|
return this.reply('未找到消息源,请引用要查看的图片');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`);
|
const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
await this.reply('未找到原图');
|
return this.reply('未找到原图');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await this.reply(segment.image(image));
|
await this.reply(segment.image(image));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
apps/user.js
30
apps/user.js
|
|
@ -30,8 +30,7 @@ export class User extends ZZZPlugin {
|
||||||
async bindDevice() {
|
async bindDevice() {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
|
||||||
await this.reply('国际服不需要绑定设备');
|
return this.reply('国际服不需要绑定设备');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
//先throw一步(
|
//先throw一步(
|
||||||
this.setContext('toBindDevice');
|
this.setContext('toBindDevice');
|
||||||
|
|
@ -44,32 +43,27 @@ export class User extends ZZZPlugin {
|
||||||
async toBindDevice() {
|
async toBindDevice() {
|
||||||
const ltuid = await this.getLtuid();
|
const ltuid = await this.getLtuid();
|
||||||
if (!ltuid) {
|
if (!ltuid) {
|
||||||
this.reply('未绑定UID');
|
|
||||||
this.finish('toBindDevice');
|
this.finish('toBindDevice');
|
||||||
return false;
|
return this.reply('未绑定UID');
|
||||||
}
|
}
|
||||||
const msg = this.e.msg.trim();
|
const msg = this.e.msg.trim();
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
return this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (msg.includes('取消')) {
|
if (msg.includes('取消')) {
|
||||||
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
|
||||||
this.finish('toBindDevice');
|
this.finish('toBindDevice');
|
||||||
return false;
|
return this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const info = JSON.parse(msg);
|
const info = JSON.parse(msg);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!!info?.device_id && !!info.device_fp) {
|
if (!!info?.device_id && !!info.device_fp) {
|
||||||
|
this.finish('toBindDevice');
|
||||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, info.device_fp);
|
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, info.device_fp);
|
||||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:ID`, info.device_id);
|
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:ID`, info.device_id);
|
||||||
await this.reply('绑定设备成功', false, { at: true, recallMsg: 100 });
|
return this.reply('绑定设备成功', false, { at: true, recallMsg: 100 });
|
||||||
this.finish('toBindDevice');
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!info?.deviceName ||
|
!info?.deviceName ||
|
||||||
|
|
@ -80,24 +74,20 @@ export class User extends ZZZPlugin {
|
||||||
!info?.deviceFingerprint ||
|
!info?.deviceFingerprint ||
|
||||||
!info?.deviceProduct
|
!info?.deviceProduct
|
||||||
) {
|
) {
|
||||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
|
||||||
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info));
|
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info));
|
||||||
const { deviceFp } = await this.getAPI();
|
const { deviceFp } = await this.getAPI();
|
||||||
if (!deviceFp) {
|
if (!deviceFp) {
|
||||||
await this.reply('绑定设备失败');
|
return this.reply('绑定设备失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
logger.debug(`[LTUID:${ltuid}]绑定设备成功,deviceFp:${deviceFp}`);
|
logger.debug(`[LTUID:${ltuid}]绑定设备成功,deviceFp:${deviceFp}`);
|
||||||
await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 });
|
await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
return this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||||
return false;
|
|
||||||
} finally {
|
} finally {
|
||||||
this.finish('toBindDevice');
|
this.finish('toBindDevice');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async deleteBind() {
|
async deleteBind() {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ export class Wiki extends ZZZPlugin {
|
||||||
!isSkillLevelLegal('ChainLevel', ChainLevel) ||
|
!isSkillLevelLegal('ChainLevel', ChainLevel) ||
|
||||||
!isSkillLevelLegal('CoreLevel', CoreLevel)
|
!isSkillLevelLegal('CoreLevel', CoreLevel)
|
||||||
) {
|
) {
|
||||||
await this.reply(`${charname}天赋等级参数不合法`);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const charData = await getHakushCharacterData(charname);
|
const charData = await getHakushCharacterData(charname);
|
||||||
|
|
@ -108,8 +107,7 @@ export class Wiki extends ZZZPlugin {
|
||||||
const charData = await getHakushCharacterData(charname);
|
const charData = await getHakushCharacterData(charname);
|
||||||
const cinemaData = charData?.Talent;
|
const cinemaData = charData?.Talent;
|
||||||
if (!cinemaData) {
|
if (!cinemaData) {
|
||||||
await this.reply(`未找到${charname}的数据`);
|
return this.reply(`未找到${charname}的数据`);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
await charData.get_assets();
|
await charData.get_assets();
|
||||||
const finalData = {
|
const finalData = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue