Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
yysforget 2024-07-15 14:59:28 +08:00
commit 2906bb0f86
16 changed files with 242 additions and 96 deletions

View file

@ -2,6 +2,8 @@ import { ZZZPlugin } from '../lib/plugin.js';
import render from '../lib/render.js'; import render from '../lib/render.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import { ZZZIndexResp } from '../model/index.js'; import { ZZZIndexResp } from '../model/index.js';
import settings from '../lib/settings.js';
import _ from 'lodash';
export class Card extends ZZZPlugin { export class Card extends ZZZPlugin {
constructor() { constructor() {
@ -9,7 +11,7 @@ export class Card extends ZZZPlugin {
name: '[ZZZ-Plugin]Card', name: '[ZZZ-Plugin]Card',
dsc: 'zzzcard', dsc: 'zzzcard',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'card', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}(card|卡片|个人信息)$`, reg: `${rulePrefix}(card|卡片|个人信息)$`,

View file

@ -1,5 +1,7 @@
import { ZZZPlugin } from '../lib/plugin.js'; import { ZZZPlugin } from '../lib/plugin.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import settings from '../lib/settings.js';
import _ from 'lodash';
export class Challenge extends ZZZPlugin { export class Challenge extends ZZZPlugin {
constructor() { constructor() {
@ -7,7 +9,7 @@ export class Challenge extends ZZZPlugin {
name: '[ZZZ-Plugin]challenge', name: '[ZZZ-Plugin]challenge',
dsc: 'zzz式舆防卫战', dsc: 'zzz式舆防卫战',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'challenge', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}(式舆防卫战|式舆|深渊|防卫战|防卫)$`, reg: `${rulePrefix}(式舆防卫战|式舆|深渊|防卫战|防卫)$`,
@ -20,7 +22,9 @@ export class Challenge extends ZZZPlugin {
const { api, deviceFp } = await this.getAPI(); const { api, deviceFp } = await this.getAPI();
if (!api) return false; if (!api) return false;
await this.getPlayerInfo(); await this.getPlayerInfo();
const indexData = await api.getFinalData(this.e, 'zzzChallenge', { deviceFp }); const indexData = await api.getFinalData(this.e, 'zzzChallenge', {
deviceFp,
});
await this.reply('data:' + JSON.stringify(indexData)); await this.reply('data:' + JSON.stringify(indexData));
} }
} }

View file

@ -17,7 +17,7 @@ export class GachaLog extends ZZZPlugin {
name: '[ZZZ-Plugin]GachaLog', name: '[ZZZ-Plugin]GachaLog',
dsc: 'zzzGachaLog', dsc: 'zzzGachaLog',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'gachalog', 1),
rule: [ rule: [
{ {
reg: `^${rulePrefix}抽卡帮助$`, reg: `^${rulePrefix}抽卡帮助$`,

View file

@ -1,14 +1,16 @@
import path from 'path' import path from 'path';
import fs from 'fs' import fs from 'fs';
import fetch from 'node-fetch' import fetch from 'node-fetch';
import lodash from 'lodash' import lodash from 'lodash';
import common from '../../../lib/common/common.js' import common from '../../../lib/common/common.js';
import {ZZZPlugin} from '../lib/plugin.js' import { ZZZPlugin } from '../lib/plugin.js';
import {rulePrefix} from '../lib/common.js' import { rulePrefix } from '../lib/common.js';
import {atlasToName} from '../lib/convert/char.js' import { atlasToName } from '../lib/convert/char.js';
import {imageResourcesPath} from '../lib/path.js' import { imageResourcesPath } from '../lib/path.js';
import _ from 'lodash';
import settings from '../lib/settings.js';
const ZZZ_GUIDES_PATH = path.join(imageResourcesPath, 'guides') const ZZZ_GUIDES_PATH = path.join(imageResourcesPath, 'guides');
export class Guide extends ZZZPlugin { export class Guide extends ZZZPlugin {
constructor() { constructor() {
@ -16,7 +18,7 @@ export class Guide extends ZZZPlugin {
name: '[ZZZ-Plugin]Guide', name: '[ZZZ-Plugin]Guide',
dsc: '#zzz角色攻略', dsc: '#zzz角色攻略',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'guide', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}(更新)?\\S+攻略(\\d+)?$`, reg: `${rulePrefix}(更新)?\\S+攻略(\\d+)?$`,
@ -25,7 +27,8 @@ export class Guide extends ZZZPlugin {
], ],
}); });
this.url = 'https://bbs-api.mihoyo.com/post/wapi/getPostFullInCollection?&gids=8&collection_id=' this.url =
'https://bbs-api.mihoyo.com/post/wapi/getPostFullInCollection?&gids=8&collection_id=';
this.collection_id = [ this.collection_id = [
[], [],
// 来源:新艾利都快讯 // 来源:新艾利都快讯
@ -33,147 +36,156 @@ export class Guide extends ZZZPlugin {
[2727116], [2727116],
[2721968], [2721968],
[2724610], [2724610],
[2722266] [2722266],
] ];
this.source = [ this.source = [
'新艾利都快讯', '新艾利都快讯',
'清茶沐沐Kiyotya', '清茶沐沐Kiyotya',
'小橙子阿', '小橙子阿',
'猫冬', '猫冬',
'月光中心' '月光中心',
] ];
// 最大攻略数量 // 最大攻略数量
this.maxNum = this.source.length this.maxNum = this.source.length;
// 最大显示攻略数量 // 最大显示攻略数量
this.maxForwardGuides = 4 this.maxForwardGuides = 4;
} }
async init() { async init() {
for (let group = 1; group <= this.maxNum; group++) { for (let group = 1; group <= this.maxNum; group++) {
let guideFolder = this.getGuideFolder(group) let guideFolder = this.getGuideFolder(group);
if (!fs.existsSync(guideFolder)) { if (!fs.existsSync(guideFolder)) {
fs.mkdirSync(guideFolder, { recursive: true }) fs.mkdirSync(guideFolder, { recursive: true });
} }
} }
} }
getGuideFolder(groupIndex) { getGuideFolder(groupIndex) {
let guideFolder = path.join(ZZZ_GUIDES_PATH, this.source[groupIndex-1]) let guideFolder = path.join(ZZZ_GUIDES_PATH, this.source[groupIndex - 1]);
return guideFolder return guideFolder;
} }
getGuidePath(groupIndex, characterName) { getGuidePath(groupIndex, characterName) {
let filename = `role_guide_${characterName}.png` let filename = `role_guide_${characterName}.png`;
let guidePath = path.join(this.getGuideFolder(groupIndex), filename) let guidePath = path.join(this.getGuideFolder(groupIndex), filename);
return guidePath return guidePath;
} }
canGetImageFromFile(guidePath, isUpdate) { canGetImageFromFile(guidePath, isUpdate) {
return ( return fs.existsSync(guidePath) && !isUpdate;
fs.existsSync(guidePath) &&
!isUpdate
)
} }
async Guide() { async Guide() {
let reg = new RegExp(`${rulePrefix}(更新)?(\\S+)攻略(\\d+)?$`) let reg = new RegExp(`${rulePrefix}(更新)?(\\S+)攻略(\\d+)?$`);
let [,,,, isUpdate, name, let [
group = '1' // setting.getConfig('mys')?.defaultSource ,
] = this.e.msg.match(reg) ,
group = +group ,
,
isUpdate,
name,
group = '1', // setting.getConfig('mys')?.defaultSource
] = this.e.msg.match(reg);
group = +group;
if (group > this.maxNum) { if (group > this.maxNum) {
await this.reply(`超过攻略数量(${this.maxNum}`) await this.reply(`超过攻略数量(${this.maxNum}`);
return return;
} }
let id = atlasToName(name) let id = atlasToName(name);
if (!id) { if (!id) {
await this.reply('该角色不存在') await this.reply('该角色不存在');
return return;
} }
if (group === 0) { if (group === 0) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
let msg = [] let msg = [];
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
for (let i = 1; i <= this.maxNum; i++) { for (let i = 1; i <= this.maxNum; i++) {
let guidePath = this.getGuidePath(i, name) let guidePath = this.getGuidePath(i, name);
if (this.canGetImageFromFile(guidePath, isUpdate)) { if (this.canGetImageFromFile(guidePath, isUpdate)) {
msg.push(segment.image(`file://${guidePath}`)) msg.push(segment.image(`file://${guidePath}`));
continue continue;
} }
if (i < this.maxForwardGuides && await this.getImg(name, i)) { if (i < this.maxForwardGuides && (await this.getImg(name, i))) {
msg.push(segment.image(`file://${guidePath}`)) msg.push(segment.image(`file://${guidePath}`));
} }
} }
if (msg.length) { await this.reply(await common.makeForwardMsg(this.e, [msg])) } if (msg.length) {
return false await this.reply(await common.makeForwardMsg(this.e, [msg]));
}
return false;
} }
let guidePath = this.getGuidePath(group, name) let guidePath = this.getGuidePath(group, name);
if (this.canGetImageFromFile(guidePath, isUpdate)) { if (this.canGetImageFromFile(guidePath, isUpdate)) {
await this.e.reply(segment.image(`file://${guidePath}`)) await this.e.reply(segment.image(`file://${guidePath}`));
return return;
} }
if (await this.getImg(name, group)) { if (await this.getImg(name, group)) {
await this.e.reply(segment.image(`file://${guidePath}`)) await this.e.reply(segment.image(`file://${guidePath}`));
} }
} }
/** 下载攻略图 */ /** 下载攻略图 */
async getImg(name, group) { async getImg(name, group) {
let msyRes = [] let msyRes = [];
this.collection_id[group].forEach((id) => msyRes.push(this.getData(this.url + id))) this.collection_id[group].forEach(id =>
msyRes.push(this.getData(this.url + id))
);
try { try {
msyRes = await Promise.all(msyRes) msyRes = await Promise.all(msyRes);
} catch (error) { } catch (error) {
this.e.reply('暂无攻略数据,请稍后再试') this.e.reply('暂无攻略数据,请稍后再试');
console.log(`米游社接口报错:${error}}`) console.log(`米游社接口报错:${error}}`);
return false return false;
} }
let posts = lodash.flatten(lodash.map(msyRes, (item) => item.data.posts)) let posts = lodash.flatten(lodash.map(msyRes, item => item.data.posts));
let url let url;
for (let val of posts) { for (let val of posts) {
if (val.post.subject.includes(name)) { if (val.post.subject.includes(name)) {
let max = 0 let max = 0;
val.image_list.forEach((v, i) => { val.image_list.forEach((v, i) => {
if ( if (
Number(v.size) >= Number(val.image_list[max].size) && Number(v.size) >= Number(val.image_list[max].size) &&
v.format != 'gif' // 动图天生 size 会撑得很大 v.format != 'gif' // 动图天生 size 会撑得很大
) { ) {
max = i max = i;
} }
}) });
url = val.image_list[max].url url = val.image_list[max].url;
break break;
} }
} }
if (!url) { if (!url) {
this.e.reply(`暂无${name}攻略(${this.source[group - 1]}\n请尝试其他的攻略来源查询`) this.e.reply(
return false `暂无${name}攻略(${this.source[group - 1]}\n请尝试其他的攻略来源查询`
);
return false;
} }
console.log(`${this.e.logFnc} 下载${name}攻略图`) console.log(`${this.e.logFnc} 下载${name}攻略图`);
const download = await fetch(url) const download = await fetch(url);
const arrayBuffer = await download.arrayBuffer() const arrayBuffer = await download.arrayBuffer();
const buffer = Buffer.from(arrayBuffer) const buffer = Buffer.from(arrayBuffer);
let guidePath = this.getGuidePath(group, name) let guidePath = this.getGuidePath(group, name);
fs.writeFileSync(guidePath , buffer) fs.writeFileSync(guidePath, buffer);
console.log(`${this.e.logFnc} 下载${name}攻略成功`) console.log(`${this.e.logFnc} 下载${name}攻略成功`);
return true return true;
} }
/** 获取数据 */ /** 获取数据 */
async getData(url) { async getData(url) {
let response = await fetch(url, { method: 'get' }) let response = await fetch(url, { method: 'get' });
if (!response.ok) { if (!response.ok) {
return false return false;
} }
return await response.json() return await response.json();
} }
} }

View file

@ -1,5 +1,7 @@
import { ZZZPlugin } from '../lib/plugin.js'; import { ZZZPlugin } from '../lib/plugin.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import settings from '../lib/settings.js';
import _ from 'lodash';
export class Help extends ZZZPlugin { export class Help extends ZZZPlugin {
constructor() { constructor() {
@ -7,7 +9,7 @@ export class Help extends ZZZPlugin {
name: '[ZZZ-Plugin]Help', name: '[ZZZ-Plugin]Help',
dsc: 'zzzhelp', dsc: 'zzzhelp',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'help', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}(帮助|help)$`, reg: `${rulePrefix}(帮助|help)$`,

View file

@ -4,6 +4,7 @@ import { getAllCharactersID } from '../lib/convert/char.js';
import { getAllEquipID } from '../lib/convert/equip.js'; import { getAllEquipID } from '../lib/convert/equip.js';
import { getAllWeaponID } from '../lib/convert/weapon.js'; import { getAllWeaponID } from '../lib/convert/weapon.js';
import { imageResourcesPath } from '../lib/path.js'; import { imageResourcesPath } from '../lib/path.js';
import settings from '../lib/settings.js';
import fs from 'fs'; import fs from 'fs';
import { import {
getRoleImage, getRoleImage,
@ -11,6 +12,7 @@ import {
getSuitImage, getSuitImage,
getWeaponImage, getWeaponImage,
} from '../lib/download.js'; } from '../lib/download.js';
import _ from 'lodash';
export class Panel extends ZZZPlugin { export class Panel extends ZZZPlugin {
constructor() { constructor() {
@ -18,7 +20,7 @@ export class Panel extends ZZZPlugin {
name: '[ZZZ-Plugin]Manage', name: '[ZZZ-Plugin]Manage',
dsc: 'zzzmanage', dsc: 'zzzmanage',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'manage', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}下载(全部|所有)资源$`, reg: `${rulePrefix}下载(全部|所有)资源$`,

View file

@ -2,6 +2,8 @@ import { ZZZPlugin } from '../lib/plugin.js';
import render from '../lib/render.js'; import render from '../lib/render.js';
import { ZZZNoteResp } from '../model/note.js'; import { ZZZNoteResp } from '../model/note.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import settings from '../lib/settings.js';
import _ from 'lodash';
export class Note extends ZZZPlugin { export class Note extends ZZZPlugin {
constructor() { constructor() {
@ -9,7 +11,7 @@ export class Note extends ZZZPlugin {
name: '[ZZZ-Plugin]Note', name: '[ZZZ-Plugin]Note',
dsc: 'zzznote', dsc: 'zzznote',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'note', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}(note|每日|体力|便笺|便签)$`, reg: `${rulePrefix}(note|每日|体力|便笺|便签)$`,

View file

@ -3,7 +3,7 @@ import render from '../lib/render.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import { getPanelList, refreshPanel, getPanel } from '../lib/avatar.js'; import { getPanelList, refreshPanel, getPanel } from '../lib/avatar.js';
import settings from '../lib/settings.js'; import settings from '../lib/settings.js';
import _ from 'lodash' import _ from 'lodash';
export class Panel extends ZZZPlugin { export class Panel extends ZZZPlugin {
constructor() { constructor() {
@ -11,7 +11,7 @@ export class Panel extends ZZZPlugin {
name: '[ZZZ-Plugin]Panel', name: '[ZZZ-Plugin]Panel',
dsc: 'zzzpanel', dsc: 'zzzpanel',
event: 'message', event: 'message',
priority: 100, priority: _.get(settings.getConfig('priority'), 'panel', 1),
rule: [ rule: [
{ {
reg: `${rulePrefix}((刷新|更新)面板|面板(刷新|更新))$`, reg: `${rulePrefix}((刷新|更新)面板|面板(刷新|更新))$`,

View file

@ -4,6 +4,7 @@ import { exec } from 'child_process';
import { ZZZPlugin } from '../lib/plugin.js'; import { ZZZPlugin } from '../lib/plugin.js';
import { rulePrefix } from '../lib/common.js'; import { rulePrefix } from '../lib/common.js';
import { pluginPath, pluginName } from '../lib/path.js'; import { pluginPath, pluginName } from '../lib/path.js';
import settings from '../lib/settings.js';
let Restart = null; let Restart = null;
@ -26,7 +27,7 @@ export class Update extends ZZZPlugin {
name: '[ZZZ-Plugin]Update', name: '[ZZZ-Plugin]Update',
dsc: 'zzzupdate', dsc: 'zzzupdate',
event: 'message', event: 'message',
priority: 1000, priority: _.get(settings.getConfig('priority'), 'update', 1),
rule: [ rule: [
{ {
reg: `^${rulePrefix}(插件)?(强制)?更新$`, reg: `^${rulePrefix}(插件)?(强制)?更新$`,

View file

@ -1,4 +1,4 @@
render: render:
scale: 100 scale: 100 # 渲染精度
query: query:
others: true others: true # 允许查询他人信息

View file

@ -1 +1 @@
interval: 60 interval: 60 # 刷新抽卡记录的时间间隔(单位:秒)

View file

@ -1 +1 @@
interval: 60 interval: 60 # 刷新面板的时间间隔(单位:秒)

9
defSet/priority.yaml Normal file
View file

@ -0,0 +1,9 @@
card: 1 # 玩家信息(卡片)
challenge: 1 # 深渊
gachalog: 1 # 抽卡
guide: 1 # 攻略
help: 1 # 帮助
manage: 1 # 管理
note: 1 # 体力
panel: 1 # 面板
update: 1 # 更新

View file

@ -84,6 +84,118 @@ export function supportGuoba() {
placeholder: '请输入数字', placeholder: '请输入数字',
}, },
}, },
{
component: 'Divider',
label: '优先级设置(-10001000',
},
{
field: 'priority.card',
label: '卡片查询',
bottomHelpMessage: '设置玩家信息卡片查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.challenge',
label: '深渊查询',
bottomHelpMessage: '设置深渊查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.gachalog',
label: '抽卡记录查询',
bottomHelpMessage: '设置抽卡记录查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.guide',
label: '攻略查询',
bottomHelpMessage: '设置攻略查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.help',
label: '帮助查询',
bottomHelpMessage: '设置帮助指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.manage',
label: '管理',
bottomHelpMessage: '设置管理指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.note',
label: '体力查询',
bottomHelpMessage: '设置体力查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.panel',
label: '面板查询',
bottomHelpMessage: '设置面板查询指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
{
field: 'priority.update',
label: '更新插件',
bottomHelpMessage: '设置更新插件指令优先级',
component: 'InputNumber',
required: true,
componentProps: {
min: -1000,
max: 1000,
placeholder: '请输入数字',
},
},
], ],
getConfigData() { getConfigData() {
return settings.merge(); return settings.merge();

View file

@ -208,7 +208,7 @@ export default class MysZZZApi extends MysApi {
} }
return { return {
'x-rpc-app_version': client.app_version, 'x-rpc-app_version': client.app_version,
'x-rpc-client_type': client.client_type, // 'x-rpc-client_type': client.client_type,
'User-Agent': 'okhttp/4.8.0', 'User-Agent': 'okhttp/4.8.0',
'x-rpc-sys_version': '12', 'x-rpc-sys_version': '12',
'x-rpc-client_type': '2', 'x-rpc-client_type': '2',

View file

@ -1,4 +1,4 @@
import { generateSeed } from '../mysapi.js'; import { generateSeed } from '../../utils/data.js';
import crypto from 'crypto'; import crypto from 'crypto';
/** /**
* derived from miao-yunzai * derived from miao-yunzai