-
Notifications
You must be signed in to change notification settings - Fork 13
/
guoba.support.js
548 lines (545 loc) · 17.8 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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
import Config from "./components/ai_painting/config.js";
import lodash from "lodash";
import path from "path";
import { pluginRoot } from "./model/path.js";
export function supportGuoba() {
return {
pluginInfo: {
name: "ap-plugin",
title: "AI绘图插件",
author: ['@yhArcadia', '@CikeyQi'],
authorLink: ['https://github.com/yhArcadia', 'https://github.com/CikeyQi'],
link: "https://github.com/AiPreface/ap-plugin",
isV3: true,
isV2: false,
showInMenu: true,
description: "基于 Yunzai 的 AI 绘图插件,使用 Stable Diffusion 接口",
icon: "fluent-emoji-flat:pencil",
iconColor: "#fe9451",
iconPath: path.join(pluginRoot, 'resources/readme/girl.png'),
},
configInfo: {
schemas: [
{
component: "Divider",
label: "绘图 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.APIList",
label: "绘图接口",
bottomHelpMessage: "用于生成图片等一系列功能,是本插件主要功能",
component: "GSubForm",
componentProps: {
multiple: true,
schemas: [
{
field: "url",
label: "接口地址",
component: "Input",
required: true,
},
{
field: "remark",
label: "接口备注",
component: "Input",
required: true,
},
{
field: "account_id",
label: "接口账号",
component: "Input",
},
{
field: "account_password",
label: "接口密码",
component: "InputPassword",
},
],
},
},
{
field: 'config.usingAPI',
label: '使用接口',
component: 'Select',
componentProps: {
options: Config.mergeConfig().APIList.map((item, index) => { return { label: item.remark, value: index + 1 } })
},
},
{
component: "Divider",
label: "审核 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.baidu_appid",
label: "BAIDU_APPID",
bottomHelpMessage: "用于图片审核服务,请在百度云图片审核应用列表中查看",
component: "Input",
required: false,
componentProps: {
maxlength: 8,
showCount: true,
placeholder: "请输入BAIDU_APPID",
},
},
{
field: "config.baidu_apikey",
label: "APIKEY",
bottomHelpMessage:
"用于图片审核服务,请在百度云图片审核应用列表中查看",
component: "Input",
required: false,
componentProps: {
maxlength: 24,
showCount: true,
placeholder: "请输入BAIDU_APIKEY",
},
},
{
field: "config.baidu_secretkey",
label: "SECRETKEY",
bottomHelpMessage:
"用于图片审核服务,请在百度云图片审核应用列表中查看",
component: "Input",
required: false,
componentProps: {
maxlength: 32,
showCount: true,
placeholder: "请输入BAIDU_SECRETKEY",
},
},
{
component: "Divider",
label: "翻译 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.baidu_translate.id",
label: "百度翻译APPID",
bottomHelpMessage: "用于翻译中文Prompt,请在百度翻译开放平台中查看",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入APPID,如20200727003021717",
maxlength: 17,
showCount: true,
},
},
{
field: "config.baidu_translate.key",
label: "百度翻译密钥",
bottomHelpMessage: "用于翻译中文Prompt,请在百度翻译开放平台中查看",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入密钥,如cAQVZv_BhmprwF90Al_I",
maxlength: 20,
showCount: true,
},
},
{
field: "config.youdao_translate.id",
label: "有道翻译ID",
bottomHelpMessage: "用于翻译中文Prompt,请在有道智云控制台中查看",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入APPID,如4523B39ea362ec0c",
maxlength: 16,
showCount: true,
},
},
{
field: "config.youdao_translate.key",
label: "有道翻译密钥",
bottomHelpMessage: "用于翻译中文Prompt,请在有道智云控制台中查看",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入密钥,如TplRPttI0XdF65xqMBkITM0k9vh7YFUB",
maxlength: 32,
showCount: true,
},
},
{
component: "Divider",
label: "策略 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "policy.cd",
label: "全局CD",
bottomHelpMessage: "单位:秒,默认为10",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入全局CD,如10",
addonAfter: "秒",
},
},
{
field: "policy.localNum",
label: "检索图片",
bottomHelpMessage: "单位:张,默认为50",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入本地检索图片张数,如50",
addonAfter: "张",
},
},
{
field: "policy.isDownload",
label: "存入本地",
bottomHelpMessage: "默认关闭,开启后会将图片存入本地",
component: "Switch",
},
{
field: "policy.isTellMaster",
label: "通知主人",
bottomHelpMessage: "默认关闭,开启后会将违规图片通知主人",
component: "Switch",
},
{
field: "policy.isAllowSearchLocalImg",
label: "成员检索",
bottomHelpMessage: "默认关闭,开启后会允许成员搜索本地图片",
component: "Switch",
},
{
field: "policy.prohibitedUserList",
label: "封禁用户",
bottomHelpMessage: "封禁的用户QQ号,封禁的用户无法绘图",
component: "GTags",
componentProps: {
placeholder: '请输入黑名单QQ',
allowAdd: true,
allowDel: true,
showPrompt: true,
promptProps: {
content: '请输入QQ号:',
placeholder: '请输入QQ号',
okText: '添加',
rules: [
{ required: true, message: 'QQ号得填上才行哦~' },
{ pattern: '^\\d+$', message: 'QQ号应该是纯数字的吧' },
{ min: 5, message: '真的有这么短的QQ号吗?' },
{ max: 10, message: '太…太长了……' },
],
},
valueFormatter: ((value) => Number.parseInt(value)).toString(),
},
},
{
field: "policy.apMaster",
label: "管理员QQ号",
bottomHelpMessage: "管理员QQ号,用于更改相关设置",
component: "GTags",
componentProps: {
placeholder: '请输入黑名单QQ',
allowAdd: true,
allowDel: true,
showPrompt: true,
promptProps: {
content: '请输入QQ号:',
placeholder: '请输入QQ号',
okText: '添加',
rules: [
{ required: true, message: 'QQ号得填上才行哦~' },
{ pattern: '^\\d+$', message: 'QQ号应该是纯数字的吧' },
{ min: 5, message: '真的有这么短的QQ号吗?' },
{ max: 10, message: '太…太长了……' },
],
},
valueFormatter: ((value) => Number.parseInt(value)).toString(),
},
},
{
component: "Divider",
label: "全局 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "policy.gp.global.enable",
label: "启用绘图",
bottomHelpMessage: "默认开启,关闭后所有群都无法绘图",
component: "Switch",
},
{
field: "policy.gp.global.JH",
label: "图片审核",
bottomHelpMessage: "默认开启,关闭后图片将不会被审核",
component: "Switch",
},
{
field: "policy.gp.global.gcd",
label: "群聊CD",
bottomHelpMessage: "单位:秒,默认为20",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入全局群聊CD,如20",
addonAfter: "秒",
},
},
{
field: "policy.gp.global.pcd",
label: "个人CD",
bottomHelpMessage: "单位:秒,默认为40",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入全局个人CD,如40",
addonAfter: "秒",
},
},
{
field: "policy.gp.global.isRecall",
label: "全局撤回",
bottomHelpMessage: "默认关闭,开启后会在发送图片后撤回",
component: "Switch",
},
{
field: "policy.gp.global.recallDelay",
label: "撤回时间",
bottomHelpMessage: "单位:秒,默认为60",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入全局撤回延迟时间,如60",
addonAfter: "秒",
},
},
{
field: "policy.gp.global.isBan",
label: "封禁用户",
bottomHelpMessage: "默认关闭,开启后会封禁违禁词用户",
component: "Switch",
},
{
field: "policy.gp.global.usageLimit",
label: "次数限制",
bottomHelpMessage: "单位:次,默认为30",
component: "InputNumber",
required: true,
componentProps: {
placeholder: "请输入全局每日使用次数限制,如30",
addonAfter: "次",
},
},
{
component: "Divider",
label: "私聊 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "policy.gp.private.enable",
label: "启用绘图",
bottomHelpMessage: "默认开启,关闭后所有私聊都无法绘图",
component: "Switch",
},
{
field: "policy.gp.private.JH",
label: "图片审核",
bottomHelpMessage: "默认开启,关闭后图片将不会被审核",
component: "Switch",
},
{
field: "policy.gp.private.gcd",
label: "群聊CD",
bottomHelpMessage: "单位:秒,默认为20",
component: "InputNumber",
componentProps: {
placeholder: "请输入私聊群聊CD,如20",
addonAfter: "秒",
},
},
{
field: "policy.gp.private.pcd",
label: "个人CD",
bottomHelpMessage: "单位:秒,默认为40",
component: "InputNumber",
componentProps: {
placeholder: "请输入私聊个人CD,如40",
addonAfter: "秒",
},
},
{
field: "policy.gp.private.isRecall",
label: "是否撤回",
bottomHelpMessage: "默认关闭,开启后会在发送图片后撤回",
component: "Switch",
},
{
field: "policy.gp.private.recallDelay",
label: "延迟时间",
bottomHelpMessage: "单位:秒,默认为60",
component: "InputNumber",
componentProps: {
placeholder: "请输入私聊撤回延迟时间,如60",
addonAfter: "秒",
},
},
{
field: "policy.gp.private.isBan",
label: "封禁用户",
bottomHelpMessage: "默认关闭,开启后会封禁违禁词用户",
component: "Switch",
},
{
field: "policy.gp.private.usageLimit",
label: "次数限制",
bottomHelpMessage: "单位:次,默认为30",
component: "InputNumber",
componentProps: {
placeholder: "请输入私聊每日使用次数限制,如30",
addonAfter: "次",
},
},
{
component: "Divider",
label: "第三方 相关设置",
componentProps: {
orientation: "left",
plain: true,
},
},
{
field: "config.Real_CUGAN",
label: "清晰术接口",
bottomHelpMessage: "用于超分,放大图片",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://dianxian-real-cugan.hf.space/api/predict",
},
},
{
field: "config.appreciate",
label: "鉴赏接口",
bottomHelpMessage: "用于鉴赏,二次元的我功能",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://nocrypt-deepdanbooru-string.hf.space/api/predict",
},
},
{
field: "config.ai_detect",
label: "鉴定接口",
bottomHelpMessage: "用于检测图片是否为AI所作,如:",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://saltacc-anime-ai-detect.hf.space/run/predict",
},
},
{
field: "config.remove_bg",
label: "去背景接口",
bottomHelpMessage: "用于去除图片背景",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://huggingface.co/spaces/skytnt/anime-remove-background",
},
},
{
field: "config.cartoonization",
label: "动漫化接口",
bottomHelpMessage: "用于图片动漫化",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://hylee-white-box-cartoonization.hf.space/api/predict/",
},
},
{
field: "config.img_to_music",
label: "转音乐接口",
bottomHelpMessage: "用于图片转音乐",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://fffiloni-img-to-music.hf.space/run/i2m",
},
},
{
field: "config.anime_aesthetic_predict",
label: "评分接口",
bottomHelpMessage: "用于图片美学评分",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入接口地址,如https://skytnt-anime-aesthetic-predict.hf.space/run/predict",
},
},
{
field: "config.openai_key",
label: "OpenAI密钥",
bottomHelpMessage: "用于自然语言处理",
component: "InputPassword",
required: false,
componentProps: {
placeholder: "请输入密钥,如sk-tZgIILD1th6DqMiBM3VZH3BlbkFJnyEYu9t9kfQEzC6ocBOS",
maxlength: 51,
showCount: true,
},
},
],
getConfigData() {
let config = Config.mergeConfig();
let policy = Config.mergePolicy();
return {
config: config,
policy: policy,
};
},
setConfigData(data, { Result }) {
let config = {};
let policy = {};
for (let [keyPath, value] of Object.entries(data)) {
if (keyPath.startsWith("config.")) {
lodash.merge(
config,
lodash.set({}, keyPath.replace("config.", ""), value)
);
} else if (keyPath.startsWith("policy.")) {
lodash.merge(
policy,
lodash.set({}, keyPath.replace("policy.", ""), value)
);
}
}
config = lodash.merge(Config.mergeConfig(), config);
config.baidu_appid = parseInt(config.baidu_appid);
config.APIList = data['config.APIList'];
Config.setcfg(config);
policy = lodash.merge(Config.mergePolicy(), policy);
policy.prohibitedUserList = data['policy.prohibitedUserList'];
policy.apMaster = data['policy.apMaster'];
Config.setPolicy(policy);
return Result.ok({}, "保存成功~");
},
},
};
}