Add auto-join
This commit is contained in:
parent
b56a000a40
commit
0042656bff
1 changed files with 13 additions and 1 deletions
14
app.js
14
app.js
|
@ -182,9 +182,21 @@ esmBot ${esmBotVersion} (${process.env.GIT_REV})
|
|||
// }
|
||||
const { default: event } = await import("./events/roommessage.js");
|
||||
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.");
|
||||
|
||||
matrixClient.startClient({ initialSyncLimit: 2 }).then(() => logger.log("info", "Client started!"));
|
||||
matrixClient.startClient({ initialSyncLimit: 0, lazyLoadMembers: true }).then(() => logger.log("info", "Client started!"));
|
||||
}
|
||||
|
||||
init();
|
Loading…
Reference in a new issue