mirror of
https://github.com/williamkray/maubot-kickbot.git
synced 2024-10-01 06:05:46 -04:00
reference rooms by name for easier recognition
This commit is contained in:
parent
1499be26c1
commit
d3268bb106
@ -197,9 +197,15 @@ 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')
|
||||
if roomname:
|
||||
purge_list[user].append(roomname)
|
||||
else:
|
||||
purge_list[user].append(room)
|
||||
time.sleep(0.5)
|
||||
except MNotFound:
|
||||
@ -207,8 +213,12 @@ class KickBot(Plugin):
|
||||
except Exception as e:
|
||||
self.log.warning(e)
|
||||
error_list[user] = []
|
||||
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)
|
||||
await evt.respond(results, allow_html=True, edits=msg)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user