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 reg.js
config.json config.json
./config.json
#Bot data #Bot data
encryption_bot_sled encryption_bot_sled
bot.json bot.json

View File

@ -22,6 +22,8 @@ import {
appendUserPictures, appendUserPictures,
checkForMutualLike, checkForMutualLike,
eraseUser, eraseUser,
eraseUserLikes,
eraseUserMedia,
getAmountOfUserPictures, getAmountOfUserPictures,
getCurrentUserAction, getCurrentUserAction,
getUserCurrentlyViewingProfile, getUserCurrentlyViewingProfile,
@ -184,8 +186,14 @@ client.on("room.message", async (roomId, event) => {
} }
}); });
client.on("room.leave", async (roomId, event) => { client.on("room.event", async (roomId, event) => {
console.log(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) => { client.on("room.invite", async (roomId, event) => {