Add auto-join

This commit is contained in:
murm 2023-03-18 20:27:11 -04:00
parent b56a000a40
commit 0042656bff

14
app.js
View file

@ -182,9 +182,21 @@ esmBot ${esmBotVersion} (${process.env.GIT_REV})
// } // }
const { default: event } = await import("./events/roommessage.js"); const { default: event } = await import("./events/roommessage.js");
matrixClient.on("Room.timeline", event.bind(null,matrixClient)); matrixClient.on("Room.timeline", event.bind(null,matrixClient));
matrixClient.on("RoomMember.membership", function (event, member) {
try {
let owners = process.env.OWNER.split(",")
if (member.membership === "invite" && owners.includes(event.event.sender)) {
matrixClient.joinRoom(member.roomId).then(function () {
logger.log("info", `Auto-Joined ${member.roomId}`);
});
}
} catch {
// no-op
}
});
logger.log("info", "Finished loading events."); logger.log("info", "Finished loading events.");
matrixClient.startClient({ initialSyncLimit: 2 }).then(() => logger.log("info", "Client started!")); matrixClient.startClient({ initialSyncLimit: 0, lazyLoadMembers: true }).then(() => logger.log("info", "Client started!"));
} }
init(); init();