forked from ikechan8370/chatgpt-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
180 lines (173 loc) · 5.09 KB
/
index.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
import fs from "node:fs";
import chalk from "chalk";
import { Config } from "./utils/config.js";
import { checkPackage } from "./utils/DependenciesChecker.js";
if (!global.segment) {
global.segment = (await import("oicq")).segment;
}
const files = fs
.readdirSync("./plugins/chatgpt-plugin/apps")
.filter((file) => file.endsWith(".js"));
let ret = [];
files.forEach((file) => {
ret.push(import(`./apps/${file}`));
});
ret = await Promise.allSettled(ret);
let apps = {};
for (let i in files) {
let name = files[i].replace(".js", "");
if (ret[i].status !== "fulfilled") {
if (Config.debug) {
logger.error(`加载插件:${logger.red(name)} 错误`);
logger.error(
logger.cyan("[ChatGPT-plugin]"),
logger.yellow(`[启动]`),
logger.red(`[DEBUG]`),
ret[i].reason
);
} else {
logger.error(
`加载插件:${logger.red(
name
)} 错误,请尝试发送指令#chatgpt安装依赖,或者把Yunzai-bot/plugins/chatgpt-plugin/config/config.json 里面的debug后面的值改成true 查看详细信息并联系作者`
);
logger.error(
logger.cyan("[ChatGPT-plugin]"),
logger.yellow(`[启动]`),
logger.red(`[DEBUG]`),
ret[i].reason
);
}
continue;
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]];
}
//自检借鉴了渔火的ap-plugin
let tealist = ["🍵", "🧉", "🧋", "🫖", "☕", "🥑"];
logger.info("---------------");
logger.mark(
logger.cyan(
`[${
tealist[Math.floor(Math.random() * tealist.length)]
}] chatgpt-plugin插件自检中......`
)
);
let passed = await checkPackage();
if (!passed) {
logger.info(
logger.red("[ChatGPT-plugin]"),
logger.yellow(`[加载]`),
logger.red(`[依赖]`),
"依赖错误"
);
}
try {
await import("keyv");
logger.info(logger.red("------------- ٩(๑˃̵ᴗ˂̵)و / / /-------------"));
logger.info(
logger.cyan.bold(
" ________ ___ ___ ________ _________ ________ ________ _________"
)
);
logger.info(
logger.cyan.bold(
"|\\ ____\\|\\ \\|\\ \\|\\ __ \\|\\___ ___\\\\ ____\\|\\ __ \\|\\___ ___\\"
)
);
logger.info(
logger.cyan.bold(
"\\ \\ \\___|\\ \\ \\\\\\ \\ \\ \\|\\ \\|___ \\ \\_\\ \\ \\___|\\ \\ \\|\\ \\|___ \\ \\_|"
)
);
logger.info(
logger.cyan.bold(
" \\ \\ \\ \\ \\ __ \\ \\ __ \\ \\ \\ \\ \\ \\ \\ __\\ \\ ____\\ \\ \\ \\"
)
);
logger.info(
logger.cyan.bold(
" \\ \\ \\____\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\|\\ \\ \\ \\___| \\ \\ \\"
)
);
logger.info(
logger.cyan.bold(
" \\ \\_______\\ \\__\\ \\__\\ \\__\\ \\__\\ \\ \\__\\ \\ \\_______\\ \\__\\ \\ \\__\\"
)
);
logger.info(
logger.cyan.bold(
" \\|_______|\\|__|\\|__|\\|__|\\|__| \\|__| \\|_______|\\|__| \\|__|"
)
);
logger.info(
`${chalk.red.bold("ChatGPT")}${chalk.yellow.bold("-")}${chalk.blue.bold(
"Plugin"
)}${chalk.cyan.bold("加载")}${chalk.green.bold("成功!")}`
);
logger.info(`当前插件版本 ${chalk.green.bold(Config.version)}`);
logger.info(
chalk.yellow.bold("仓库地址 https://github.com/ikechan8370/chatgpt-plugin")
);
logger.info(chalk.cyan.bold("ChatGPT-Plugin交流群号 559567232"));
logger.info(logger.red("------------- ٩(๑˃̵ᴗ˂̵)و / / /-------------"));
} catch (err) {
logger.info(
logger.red.bold(
" ________ ___ ___ ________ _________ ________ ________ _________"
)
);
logger.info(
logger.red.bold(
"|\\ ____\\|\\ \\|\\ \\|\\ __ \\|\\___ ___\\\\ ____\\|\\ __ \\|\\___ ___\\"
)
);
logger.info(
logger.red.bold(
"\\ \\ \\___|\\ \\ \\\\\\ \\ \\ \\|\\ \\|___ \\ \\_\\ \\ \\___|\\ \\ \\|\\ \\|___ \\ \\_|"
)
);
logger.info(
logger.red.bold(
" \\ \\ \\ \\ \\ __ \\ \\ __ \\ \\ \\ \\ \\ \\ \\ __\\ \\ ____\\ \\ \\ \\"
)
);
logger.info(
logger.red.bold(
" \\ \\ \\____\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\|\\ \\ \\ \\___| \\ \\ \\"
)
);
logger.info(
logger.red.bold(
" \\ \\_______\\ \\__\\ \\__\\ \\__\\ \\__\\ \\ \\__\\ \\ \\_______\\ \\__\\ \\ \\__\\"
)
);
logger.info(
logger.red.bold(
" \\|_______|\\|__|\\|__|\\|__|\\|__| \\|__| \\|_______|\\|__| \\|__|"
)
);
logger.info(
`${chalk.red("ChatGPT")}${chalk.yellow("-")}${chalk.gray(
"Plugin"
)}${chalk.cyan("加载")}${chalk.red.bold("失败!")}`
);
logger.info(
logger.red("[ChatGPT-plugin]"),
logger.yellow(`[加载]`),
logger.red(`[依赖]`),
"插件未检测到依赖!!!!请发送指令#chatgpt安装依赖"
);
}
let createServer;
try {
({ createServer } = await import("./server/index.js"));
await createServer();
} catch (error) {
logger.info(
logger.red("[ChatGPT-plugin]"),
logger.yellow(`[加载]`),
logger.red(`[依赖]`),
"插件未检测到依赖!!!!请发送指令#chatgpt安装依赖"
);
}
export { apps };