Bot now leaves from rooms which was left by users

This commit is contained in:
leca 2024-08-07 16:13:52 +03:00
parent 573d8ba289
commit 7bb470664d
2 changed files with 11 additions and 2 deletions

1
.gitignore vendored
View File

@ -134,6 +134,7 @@ dist
reg.js
config.json
./config.json
#Bot data
encryption_bot_sled
bot.json

View File

@ -22,6 +22,8 @@ import {
appendUserPictures,
checkForMutualLike,
eraseUser,
eraseUserLikes,
eraseUserMedia,
getAmountOfUserPictures,
getCurrentUserAction,
getUserCurrentlyViewingProfile,
@ -184,8 +186,14 @@ client.on("room.message", async (roomId, event) => {
}
});
client.on("room.leave", async (roomId, event) => {
console.log(roomId, event);
client.on("room.event", async (roomId, event) => {
if (event.type === "m.room.member" && event.content?.membership === "leave") {
await eraseUser(roomId);
await eraseUserLikes(roomId);
await eraseUserMedia(roomId);
logInfo(`Bot has left a room with ID ${roomId}`)
client.leaveRoom(roomId);
}
})
client.on("room.invite", async (roomId, event) => {