reference rooms by name for easier recognition

This commit is contained in:
William Kray 2023-06-12 12:12:41 -07:00
parent 1499be26c1
commit d3268bb106
2 changed files with 13 additions and 3 deletions

View File

@ -197,17 +197,27 @@ class KickBot(Plugin):
for user in purgeable:
purge_list[user] = []
for room in roomlist:
roomnamestate = await self.client.get_state_event(room, 'm.room.name')
roomname = roomnamestate['name']
try:
await self.client.get_state_event(room, EventType.ROOM_MEMBER, user)
await self.client.kick_user(room, user, reason='inactivity')
purge_list[user].append(room)
if roomname:
purge_list[user].append(roomname)
else:
purge_list[user].append(room)
time.sleep(0.5)
except MNotFound:
pass
except Exception as e:
self.log.warning(e)
error_list[user] = []
error_list[user].append(room)
if roomname:
error_list[user].append(roomname)
else:
error_list[user].append(room)
results = "the following users were purged:<p><code>{purge_list}</code></p>the following errors were \
recorded:<p><code>{error_list}</code></p>".format(purge_list=purge_list, error_list=error_list)

View File

@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.jobmachine.kickbot
version: 0.0.8
version: 0.0.9
modules:
- kickbot
main_class: KickBot