Added some power level checks

This commit is contained in:
Ville Ranki 2021-05-20 10:03:19 +03:00
parent c4eeae2e7b
commit 0361814459
2 changed files with 5 additions and 3 deletions

View File

@ -190,7 +190,7 @@ This module is for interacting with the room that the commands are being execute
* !room banned Lists the banned users and their provided reason * !room banned Lists the banned users and their provided reason
* !room kicked Lists the kicked users and their provided reason * !room kicked Lists the kicked users and their provided reason
* !room state [event type] [optional state key] Gets a state event with given event type and optional state key * !room state [event type] [optional state key] Gets a state event with given event type and optional state key
* !room tombstone [target] Creates a tombstone event pointing to target room. Target room can be alias (starting with #) or id (starting with !). * !room tombstone [target] Creates a tombstone event pointing to target room. Target room can be alias (starting with #) or id (starting with !). User must be admin in the room.
Note on tombstone: If using alias, bot must be present in target room. This is the preferred way. If using id, make sure it's correct, as it's not validated! Note on tombstone: If using alias, bot must be present in target room. This is the preferred way. If using id, make sure it's correct, as it's not validated!
Tombstoning requires power level for room upgrade. Make sure bot has it in the room. Tombstoning requires power level for room upgrade. Make sure bot has it in the room.
@ -614,8 +614,8 @@ Admin commands to manage users.
#### Usage #### Usage
* !users list [pattern] - List users matching wildcard pattern * !users list [pattern] - List users matching wildcard pattern (must be owner)
* !users kick [pattern] - Kick users matching wildcard pattern from room * !users kick [pattern] - Kick users matching wildcard pattern from room (must be admin in room)
## Bot setup ## Bot setup

View File

@ -8,6 +8,7 @@ class MatrixModule(BotModule):
if len(args) == 2: if len(args) == 2:
if args[0] == 'list': if args[0] == 'list':
bot.must_be_owner(event)
users = self.search_users(bot, args[1]) users = self.search_users(bot, args[1])
if len(users): if len(users):
await bot.send_text(room, ' '.join(users)) await bot.send_text(room, ' '.join(users))
@ -15,6 +16,7 @@ class MatrixModule(BotModule):
await bot.send_text(room, 'No matching users found!') await bot.send_text(room, 'No matching users found!')
return return
if args[0] == 'kick': if args[0] == 'kick':
bot.must_be_admin(room, event)
users = self.search_users(bot, args[1]) users = self.search_users(bot, args[1])
if len(users): if len(users):
for user in users: for user in users: