forked from erzaozi/waves-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
guoba.support.js
440 lines (434 loc) · 13.9 KB
/
guoba.support.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
import Config from "./components/Config.js";
import lodash from "lodash";
import path from "path";
import { pluginRoot } from "./model/path.js";
export function supportGuoba() {
return {
pluginInfo: {
name: 'waves-plugin',
title: '鸣潮插件',
author: ['@CikeyQi', '@erzaozi'],
authorLink: ['https://github.com/CikeyQi', 'https://github.com/erzaozi'],
link: 'https://github.com/erzaozi/waves-plugin',
isV3: true,
isV2: false,
showInMenu: true,
description: '基于 Yunzai 的鸣潮游戏数据查询插件',
// 显示图标,此为个性化配置
// 图标可在 https://icon-sets.iconify.design 这里进行搜索
icon: 'icon-park:game-ps',
// 图标颜色,例:#FF0000 或 rgb(255, 0, 0)
iconColor: '#d19f56',
// 如果想要显示成图片,也可以填写图标路径(绝对路径)
iconPath: path.join(pluginRoot, 'resources/readme/girl.png'),
},
configInfo: {
schemas: [
{
component: "Divider",
label: "Waves 推送配置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "user_config.waves_auto_signin_list",
label: "自动签到配置",
bottomHelpMessage: "自动签到列表",
component: "GSubForm",
componentProps: {
multiple: true,
schemas: [
{
field: "botId",
label: "签到使用的机器人",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入机器人账号ID',
},
},
{
field: "groupId",
label: "签到失败通知群",
component: "Input",
required: false,
componentProps: {
placeholder: '请输入群号,不填默认私聊',
},
},
{
field: "userId",
label: "自动签到用户",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入用户账号ID',
},
},
],
},
},
{
field: 'config.signin_time',
label: '定时表达式配置',
bottomHelpMessage: '定时签到',
component: 'EasyCron',
componentProps: {
placeholder: '请输入或选择Cron表达式',
},
},
{
field: "user_config.waves_auto_task_list",
label: "自动任务配置",
bottomHelpMessage: "自动任务列表",
component: "GSubForm",
componentProps: {
multiple: true,
schemas: [
{
field: "botId",
label: "任务使用的机器人",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入机器人账号ID',
},
},
{
field: "groupId",
label: "任务失败通知群",
component: "Input",
required: false,
componentProps: {
placeholder: '请输入群号,不填默认私聊',
},
},
{
field: "userId",
label: "自动任务用户",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入用户账号ID',
},
},
],
},
},
{
field: 'config.task_time',
label: '定时表达式配置',
bottomHelpMessage: '定时任务',
component: 'EasyCron',
componentProps: {
placeholder: '请输入或选择Cron表达式',
},
},
{
field: "user_config.waves_auto_push_list",
label: "体力推送配置",
bottomHelpMessage: "体力推送列表",
component: "GSubForm",
componentProps: {
multiple: true,
schemas: [
{
field: "botId",
label: "推送使用的机器人",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入机器人账号ID',
},
},
{
field: "groupId",
label: "体力值推送群",
component: "Input",
required: false,
componentProps: {
placeholder: '请输入群号,不填默认私聊',
},
},
{
field: "userId",
label: "体力值推送用户",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入用户账号ID',
},
},
],
},
},
{
field: 'config.sanity_push_time',
label: '定时表达式配置',
bottomHelpMessage: '体力检查频率',
component: 'EasyCron',
componentProps: {
placeholder: '请输入或选择Cron表达式',
},
},
{
field: "user_config.waves_auto_news_lists",
label: "公告推送配置",
bottomHelpMessage: "公告推送列表",
component: "GSubForm",
componentProps: {
multiple: true,
schemas: [
{
field: "botId",
label: "推送使用的机器人",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入机器人账号ID',
},
},
{
field: "isGroup",
label: "是否为群号",
bottomHelpMessage: "打开后请在下方输入群号,关闭请在下方输入用户账号",
component: "Switch",
},
{
field: "pushId",
label: "公告推送ID",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入ID',
},
},
],
},
},
{
field: 'config.news_push_time',
label: '定时表达式配置',
bottomHelpMessage: '公告检查频率',
component: 'EasyCron',
componentProps: {
placeholder: '请输入或选择Cron表达式',
},
},
{
component: "Divider",
label: "Waves 登录服务器配置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.allow_login",
label: "允许网页登录",
bottomHelpMessage: "是否允许网页登录",
component: "Switch",
},
{
field: "config.server_port",
label: "开放端口",
bottomHelpMessage: "登录HTTP服务器开放端口",
component: "InputNumber",
required: true,
componentProps: {
placeholder: '请输入端口',
min: 1,
max: 65535,
step: 1,
},
},
{
field: "config.public_link",
label: "登录服务公开地址",
bottomHelpMessage: "展示给用户的自定义登录地址",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入服务地址,例:http://39.156.66.10:25088',
},
},
{
field: "config.background_api",
label: "登录页背景图",
bottomHelpMessage: "背景图API地址",
component: "Input",
required: true,
componentProps: {
placeholder: '请输入API地址,例:https://www.loliapi.com/acg',
},
},
{
component: "Divider",
label: "Waves 面板图配置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.allow_img_upload",
label: "上传面板图",
bottomHelpMessage: "是否允许普通用户上传面板图",
component: "Switch",
},
{
field: "config.allow_get_origin",
label: "获取原图",
bottomHelpMessage: "是否允许普通用户获取原图",
component: "Switch",
},
{
field: "config.allow_get_list",
label: "获取面板图列表",
bottomHelpMessage: "是否允许普通用户获取面板图列表",
component: "Switch",
},
{
field: "config.allow_img_delete",
label: "删除面板图",
bottomHelpMessage: "是否允许普通用户删除面板图",
component: "Switch",
},
{
component: "Divider",
label: "Waves 别名配置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.allow_set_alias",
label: "设置别名",
bottomHelpMessage: "是否允许普通用户设置别名",
component: "Switch",
},
{
component: "Divider",
label: "Waves 其他配置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.use_public_cookie",
label: "使用公共Token",
bottomHelpMessage: "允许未登录用户使用登录用户的Token进行查询",
component: "Switch",
},
{
field: "config.strategy_provide",
label: "攻略图提供方",
bottomHelpMessage: "选择角色攻略图提供方",
component: "Select",
componentProps: {
options: [
{ label: "全部", value: "all" },
{ label: "小沐XMu", value: "XMu" },
{ label: "Moealkyne", value: "moealkyne" },
{ label: "金铃子攻略组", value: "Linn" }
],
},
},
{
field: "config.allow_import",
label: "允许导入抽卡记录",
bottomHelpMessage: "无法验证导入数据真实性,可能存在虚假数据覆盖真实数据情况,请谨慎开启",
component: "Switch",
},
{
field: "config.signin_interval",
label: "签到间隔时间",
bottomHelpMessage: "单位:秒,请勿设置过短,风险自负",
component: "InputNumber",
required: true,
componentProps: {
placeholder: '请输入间隔时间',
step: 1,
},
},
{
field: "config.task_interval",
label: "任务间隔时间",
bottomHelpMessage: "单位:秒,请勿设置过短,风险自负",
component: "InputNumber",
required: true,
componentProps: {
placeholder: '请输入间隔时间',
step: 1,
},
},
{
field: "config.enable_log",
label: "输出成功日志",
bottomHelpMessage: "输出成功日志,用于调试和向开发者反馈问题",
component: "Switch",
},
{
field: "config.render_scale",
label: "图片渲染精度",
bottomHelpMessage: "图片渲染精度,建议 50-200 ,默认 100",
component: "InputNumber",
required: true,
componentProps: {
min: 50,
max: 200,
placeholder: '请输入渲染精度',
step: 1
},
},
{
field: "config.limit",
label: "接口并发量",
bottomHelpMessage: "过大的并发将会请求阻塞",
component: "InputNumber",
required: true,
componentProps: {
placeholder: '请输入并发量',
step: 1,
},
},
],
getConfigData() {
let config = Config.getConfig()
let user_config = Config.getUserConfig()
user_config["waves_auto_news_lists"] = [];
user_config["waves_auto_news_list"].forEach(user => {
const { botId, groupId, userId } = user;
let isGroup = !!groupId;
if (isGroup) {
user_config["waves_auto_news_lists"].push({ botId, isGroup, pushId: groupId });
} else {
user_config["waves_auto_news_lists"].push({ botId, isGroup, pushId: userId });
}
})
return { config, user_config }
},
setConfigData(data, { Result }) {
let last = {};
for (let [keyPath, value] of Object.entries(data)) {
lodash.set(last, keyPath, value);
}
let config = lodash.merge({}, Config.getConfig(), last.config);
let user_config = lodash.merge({}, Config.getUserConfig(), last.user_config);
config.public_link = config.public_link.replace(/\/$/, '');
user_config["waves_auto_news_list"] = [];
user_config["waves_auto_news_lists"].forEach(({ botId, isGroup, pushId }) => {
user_config["waves_auto_news_list"].push({ botId, groupId: isGroup ? pushId : "", userId: !isGroup ? pushId : "" });
});
delete user_config["waves_auto_news_lists"];
Config.setConfig(config)
Config.setUserConfig(user_config)
return Result.ok({}, '保存成功~')
},
},
}
}