test
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
mol
2023-12-13 22:17:45 +08:00
parent 98e48140d3
commit 7f3af6b154
3 changed files with 27 additions and 12 deletions

23
app.js
View File

@ -3,6 +3,7 @@ import { join } from 'path';
import CreateBot from '#root/bot/index.js';
import CreateWebhookServer from '#root/http/index.js';
import logger from '#root/utils/logger.js';
import handlers from './handlers';
let retryCount = 0;
@ -37,17 +38,17 @@ let retryCount = 0;
const webhook = new CreateWebhookServer();
logger('开始引入handler函数');
const files = fs.readdirSync('./handlers');
const handlers = files
.filter((it) => /\.js$/.test(it))
.map((it) => {
let fPath = join(__dirname, './handlers', it);
return {
event: it.split('.').slice(0, -1).join('.'),
handler: require(fPath).bind(this, bot),
};
});
webhook.registerHanlder(handlers);
// const files = fs.readdirSync('./handlers');
// const handlers = files
// .filter((it) => /\.js$/.test(it))
// .map((it) => {
// let fPath = join(__dirname, './handlers', it);
// return {
// event: it.split('.').slice(0, -1).join('.'),
// handler: require(fPath).bind(this, bot),
// };
// });
webhook.registerHandler(handlers.map(i => ({ event: i.event, handler: i.handler.bind(this, bot) })));
webhook.startListen(port);
logger(`开始监听端口: ${port}`);