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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
render:
scale: 100
scale: 100 # 渲染精度
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: '请输入数字',
},
},
{
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() {
return settings.merge();

View file

@ -208,7 +208,7 @@ export default class MysZZZApi extends MysApi {
}
return {
'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',
'x-rpc-sys_version': '12',
'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';
/**
* derived from miao-yunzai