Baphomet is the dedicated bot for nulloctet matrix
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
let { logger } = require('./logging'); let { modules } = require('./module/index')
class Engine { constructor(bot, modules) { this.bot = bot; this.modules = modules; }
init() { logger.info("Initializing modules"); this.initModules(); this.bot.init(); this.bot.client.on("sync", (state, previousState, data) => { switch (state) { case "PREPARED": this.bot.connected = true; this.bot.sendStatusStartup(); break; } }); this.bot.client.on("RoomMember.membership", (event, member) => { if (member.membership === "invite" && this.bot.config.admin.indexOf(ember.userId) >= 0) { this.bot.client.joinRoom(member.roomId).done(() => { logger.info("Auto-joined %s", member.roomId); }); } }); /* Capture Exit Conditions */ ["SIGINT", "SIGTERM"].forEach((signature) => { process.on(signature, async () => { await this.bot.sendStatusShutdown() .then(() => { logger.info("Gracefully stopping Matrix SDK Client") this.bot.client.stopClient(); }); process.exit(0); }); }); process.on('exit', () => { logger.info("Shutting Down"); }); return this; }
initModules() { this.modules.forEach((module) => { logger.info("Loading module: %s", module.name); }); }
run() { // logger.info("Initializing Crypto");
// await bot.client.initCrypto();
logger.info("Starting Matrix SDK Client"); this.bot.client.startClient(); return this; } }
function create(bot) { return new Engine(bot, modules) }
exports.create = create;
|