Skip to content

Commit 7fb2a19

Browse files
committedMar 8, 2024
适配锅巴配置
1 parent 0c870bb commit 7fb2a19

File tree

4 files changed

+206
-2
lines changed

4 files changed

+206
-2
lines changed
 

‎apps/Main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import plugin from '../../../lib/plugins/plugin.js'
2-
import { Midjourney } from 'freezer-midjourney-api'
2+
import { Midjourney } from 'midjourney'
33
import fetch from 'node-fetch'
44
import { HttpsProxyAgent } from 'https-proxy-agent'
55
import WebSocket from 'isomorphic-ws'

‎guoba.support.js

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import Config from "./components/Config.js";
2+
import lodash from "lodash";
3+
import path from "path";
4+
import { pluginRoot } from "./model/path.js";
5+
6+
export function supportGuoba() {
7+
return {
8+
pluginInfo: {
9+
name: 'mj-plugin',
10+
title: 'mj-plugin',
11+
author: ['@CikeyQi', '@erzaozi'],
12+
authorLink: ['https://github.com/CikeyQi', 'https://github.com/erzaozi'],
13+
link: 'https://github.com/CikeyQi/mj-plugin',
14+
isV3: true,
15+
isV2: false,
16+
description: '基于Yunzai-Bot的AI绘图插件,使用Midjourney接口',
17+
// 显示图标,此为个性化配置
18+
// 图标可在 https://icon-sets.iconify.design 这里进行搜索
19+
icon: 'mdi:stove',
20+
// 图标颜色,例:#FF0000 或 rgb(255, 0, 0)
21+
iconColor: '#d19f56',
22+
// 如果想要显示成图片,也可以填写图标路径(绝对路径)
23+
iconPath: path.join(pluginRoot, 'resources/icon.png'),
24+
},
25+
configInfo: {
26+
schemas: [
27+
{
28+
component: "Divider",
29+
label: "Discord 相关配置",
30+
componentProps: {
31+
orientation: "left",
32+
plain: true,
33+
},
34+
},
35+
{
36+
field: "server_id",
37+
label: "服务器ID",
38+
bottomHelpMessage: "Discord服务器ID",
39+
component: "Input",
40+
componentProps: {
41+
placeholder: 'Server ID',
42+
maxlength: 19,
43+
},
44+
},
45+
{
46+
field: "channel_id",
47+
label: "频道ID",
48+
bottomHelpMessage: "Discord频道ID",
49+
component: "Input",
50+
componentProps: {
51+
placeholder: 'Channel ID',
52+
maxlength: 19,
53+
},
54+
},
55+
{
56+
field: "salai_token",
57+
label: "Discord Token",
58+
bottomHelpMessage: "Discord身份验证Token",
59+
component: "Input",
60+
componentProps: {
61+
placeholder: 'Salai Token',
62+
},
63+
},
64+
{
65+
component: "Divider",
66+
label: "Bot 相关配置",
67+
componentProps: {
68+
orientation: "left",
69+
plain: true,
70+
},
71+
},
72+
{
73+
field: "bot_type",
74+
label: "Bot类型选择",
75+
component: "Select",
76+
componentProps: {
77+
options: [
78+
{ label: 'Midjourney Bot', value: 'Midjourney' },
79+
{ label: 'niji・journey Bot', value: 'Nijijourney' },
80+
],
81+
},
82+
},
83+
{
84+
component: "Divider",
85+
label: "代理 相关配置",
86+
componentProps: {
87+
orientation: "left",
88+
plain: true,
89+
},
90+
},
91+
{
92+
field: "proxy",
93+
label: "使用代理",
94+
component: "Switch",
95+
},
96+
{
97+
field: "proxy_url",
98+
label: "代理地址",
99+
component: "Input",
100+
componentProps: {
101+
placeholder: 'Proxy URL',
102+
},
103+
},
104+
{
105+
component: "Divider",
106+
label: "翻译 相关配置",
107+
componentProps: {
108+
orientation: "left",
109+
plain: true,
110+
},
111+
},
112+
{
113+
field: "translate_use",
114+
label: "使用翻译接口",
115+
component: "Select",
116+
componentProps: {
117+
options: [
118+
{ label: '椰奶有道', value: 0 },
119+
{ label: '百度翻译(需配置)', value: 1 },
120+
{ label: '有道翻译(需配置)', value: 2 },
121+
],
122+
},
123+
},
124+
{
125+
field: "baidu_translate.appid",
126+
label: "百度APP ID",
127+
component: "Input",
128+
componentProps: {
129+
placeholder: "请输入百度翻译APPID",
130+
maxlength: 17,
131+
pattern: "^[0-9]*$",
132+
visible: true,
133+
},
134+
},
135+
{
136+
field: "baidu_translate.appkey",
137+
label: "百度Secret Key",
138+
component: "InputPassword",
139+
componentProps: {
140+
placeholder: "请输入百度翻译APPKEY",
141+
maxlength: 20,
142+
visible: false,
143+
},
144+
},
145+
{
146+
field: "youdao_translate.appid",
147+
label: "有道APP ID",
148+
component: "Input",
149+
componentProps: {
150+
placeholder: "请输入有道翻译APPID",
151+
maxlength: 16,
152+
visible: true,
153+
},
154+
},
155+
{
156+
field: "youdao_translate.appkey",
157+
label: "有道Secret Key",
158+
component: "InputPassword",
159+
componentProps: {
160+
placeholder: "请输入有道翻译APPKEY",
161+
maxlength: 32,
162+
visible: false,
163+
},
164+
},
165+
{
166+
component: "Divider",
167+
label: "其他 相关配置",
168+
componentProps: {
169+
orientation: "left",
170+
plain: true,
171+
},
172+
},
173+
{
174+
field: "huggingface_token",
175+
label: "Huggingface Token",
176+
component: "Input",
177+
componentProps: {
178+
placeholder: 'HuggingFace Token',
179+
},
180+
},
181+
{
182+
field: "debug",
183+
label: "调试模式",
184+
component: "Switch",
185+
},
186+
],
187+
getConfigData() {
188+
let config = Config.getConfig()
189+
return config
190+
},
191+
192+
setConfigData(data, { Result }) {
193+
let config = {}
194+
for (let [keyPath, value] of Object.entries(data)) {
195+
lodash.set(config, keyPath, value)
196+
}
197+
config = lodash.merge({}, Config.getConfig(), config)
198+
config.proxy_url = config.proxy_url.replace(/\/$/, '')
199+
Config.setConfig(config)
200+
return Result.ok({}, '保存成功~')
201+
},
202+
},
203+
}
204+
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "module",
1010
"module": "index.js",
1111
"dependencies": {
12-
"freezer-midjourney-api": "^4.0.6",
12+
"midjourney": "^4.3.17",
1313
"https-proxy-agent": "^7.0.1",
1414
"isomorphic-ws": "^5.0.0"
1515
},

‎resources/icon.png

8.94 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.