refactor: 重构 Onebot 配置格式,增强可读性

This commit is contained in:
SherkeyXD committed 2024-05-15 00:17:59 +08:00
1 parent 7b5c332726
commit e91ed34b40
9 files changed
+259 -230

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ class OB11HTTPServer extends HttpServerBase {
}
protected listen(port: number, host: string) {
if (ob11Config.enableHttp) {
if (ob11Config.http.enable) {
super.listen(port, host);
}
}
+4 -4
View File
@@ -78,19 +78,19 @@ export function postOB11Event(msg: PostEventType, reportSelf = false, postWs = t
return;
}
}
if (config.enableHttpPost) {
if (config.http.enablePost) {
const msgStr = JSON.stringify(msg);
const hmac = crypto.createHmac('sha1', ob11Config.httpSecret);
const hmac = crypto.createHmac('sha1', ob11Config.http.secret);
hmac.update(msgStr);
const sig = hmac.digest('hex');
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'x-self-id': selfInfo.uin
};
if (config.httpSecret) {
if (config.http.secret) {
headers['x-signature'] = 'sha1=' + sig;
}
for (const host of config.httpPostUrls) {
for (const host of config.http.postUrls) {
fetch(host, {
method: 'POST',
headers,
+1 -1
View File
@@ -116,7 +116,7 @@ export class ReverseWebsocket {
class OB11ReverseWebsockets {
start() {
for (const url of ob11Config.wsReverseUrls) {
for (const url of ob11Config.reverseWs.urls) {
log('开始连接反向ws', url);
new Promise(() => {
try {