2023-05-01 15:49:26 +00:00
|
|
|
from nio import RoomMemberEvent, MatrixRoom
|
|
|
|
|
|
|
|
async def roommember_callback(room: MatrixRoom, event: RoomMemberEvent, bot):
|
|
|
|
if event.membership == "leave":
|
|
|
|
bot.logger.log(f"User {event.state_key} left room {room.room_id} - am I alone now?")
|
|
|
|
|
|
|
|
if len(room.users) == 1:
|
|
|
|
bot.logger.log("Yes, I was abandoned - leaving...")
|
2023-05-02 06:58:49 +00:00
|
|
|
await bot.matrix_client.room_leave(room.room_id)
|
2023-05-01 15:49:26 +00:00
|
|
|
return
|