mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-12 07:50:25 +00:00
refactor: 重构 Onebot 配置格式,增强可读性
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user