feat(bot): support multiple args for commands

Extended the bot to handle multiple room IDs for block and shutdown
commands, and multiple user IDs for lock and unlock commands in a single
message. This enhancement allows for more efficient bulk operations.
This commit is contained in:
Kumi 2024-09-01 09:24:02 +02:00
parent bcf63c3a11
commit edbb33bc46
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -76,9 +76,13 @@ class RoombaBot:
return
if event.body.startswith("!roomba block"):
await self.block_room(event.body.split()[2], True)
for room_id in event.body.split()[2:]:
await self.block_room(room_id, True)
elif event.body.startswith("!roomba unblock"):
await self.block_room(event.body.split()[2], False)
for room_id in event.body.split()[2:]:
await self.block_room(room_id, False)
elif event.body.startswith("!roomba shutdown"):
parts = event.body.split()
@ -88,12 +92,17 @@ class RoombaBot:
else:
purge = False
room_id = parts[2]
await self.shutdown_room(room_id, purge)
for room_id in parts[2:]:
await self.shutdown_room(room_id, purge)
elif event.body.startswith("!roomba lock"):
await self.lock_user(event.body.split()[2])
for user_id in event.body.split()[2:]:
await self.lock_user(user_id, True)
elif event.body.startswith("!roomba unlock"):
await self.unlock_user(event.body.split()[2])
for user_id in event.body.split()[2:]:
await self.lock_user(user_id, False)
elif event.body and event.body.split()[0] == "!roomba":
await self.send_message(
self.moderation_room_id,