Fixes to users, better room listing in bot module.
This commit is contained in:
parent
e1e162643d
commit
2d19affee8
|
@ -525,6 +525,8 @@ Example:
|
||||||
|
|
||||||
### Gfycat
|
### Gfycat
|
||||||
|
|
||||||
|
NOTE: This module is not working at the moment - gfycat now needs API key
|
||||||
|
|
||||||
Can be used to post a picture from Gfycat given a query string.
|
Can be used to post a picture from Gfycat given a query string.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
@ -631,10 +633,11 @@ You can classify users based on MXID to get stats on where users come from.
|
||||||
#### Usage
|
#### Usage
|
||||||
|
|
||||||
* !users list [pattern] - List users matching wildcard pattern in this room (must be owner)
|
* !users list [pattern] - List users matching wildcard pattern in this room (must be owner)
|
||||||
|
* !users listall [pattern] - List users matching wildcard pattern globally (must be owner)
|
||||||
* !users kick [pattern] - Kick users matching wildcard pattern from room (must be admin in room)
|
* !users kick [pattern] - Kick users matching wildcard pattern from room (must be admin in room)
|
||||||
* !users classify add [name] [pattern] - Add a classification pattern (must be owner)
|
* !users classify add [name] [pattern] - Add a classification pattern (must be owner)
|
||||||
* !users classify list - List classifications
|
* !users classify list - List classifications
|
||||||
* !users classify del [name] - Delete classification
|
* !users classify del [name] - Delete classification (must be owner)
|
||||||
* !users roomstats - List how many users are in each class in this room
|
* !users roomstats - List how many users are in each class in this room
|
||||||
* !users stats - List how many users are in each class globally as seen by bot
|
* !users stats - List how many users are in each class globally as seen by bot
|
||||||
|
|
||||||
|
|
|
@ -301,11 +301,11 @@ class MatrixModule(BotModule):
|
||||||
|
|
||||||
async def rooms(self, bot, room, event):
|
async def rooms(self, bot, room, event):
|
||||||
bot.must_be_owner(event)
|
bot.must_be_owner(event)
|
||||||
rooms = []
|
output = f'I\'m in following {len(bot.client.rooms)} rooms:\n'
|
||||||
for croomid in bot.client.rooms:
|
for croomid in bot.client.rooms:
|
||||||
roomobj = bot.get_room_by_id(croomid)
|
roomobj = bot.get_room_by_id(croomid)
|
||||||
rooms.append(roomobj.machine_name)
|
output = output + f' - {roomobj.display_name} ( {roomobj.machine_name} )\n'
|
||||||
await bot.send_text(room, f'I\'m in following {len(rooms)} rooms: {rooms}')
|
await bot.send_text(room, output)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
raise ModuleCannotBeDisabled
|
raise ModuleCannotBeDisabled
|
||||||
|
|
|
@ -45,9 +45,13 @@ class MatrixModule(BotModule):
|
||||||
await bot.send_text(room, reply)
|
await bot.send_text(room, reply)
|
||||||
return
|
return
|
||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
if args[0] == 'list':
|
if args[0] == 'list' or args[0] == 'listall':
|
||||||
bot.must_be_owner(event)
|
bot.must_be_owner(event)
|
||||||
users = self.search_users(bot, args[1])
|
search_room = None
|
||||||
|
if args[0] == 'list':
|
||||||
|
search_room = room.room_id
|
||||||
|
allusers = self.get_users(bot, search_room)
|
||||||
|
users = fnmatch.filter(allusers, args[1])
|
||||||
if len(users):
|
if len(users):
|
||||||
await bot.send_text(room, ' '.join(users))
|
await bot.send_text(room, ' '.join(users))
|
||||||
else:
|
else:
|
||||||
|
@ -55,7 +59,8 @@ class MatrixModule(BotModule):
|
||||||
return
|
return
|
||||||
if args[0] == 'kick':
|
if args[0] == 'kick':
|
||||||
bot.must_be_admin(room, event)
|
bot.must_be_admin(room, event)
|
||||||
users = self.search_users(bot, args[1])
|
allusers = self.get_users(bot, room.room_id)
|
||||||
|
users = fnmatch.filter(allusers, args[1])
|
||||||
if len(users):
|
if len(users):
|
||||||
for user in users:
|
for user in users:
|
||||||
self.logger.debug(f"Kicking {user} from {room.room_id} as requested by {event.sender}")
|
self.logger.debug(f"Kicking {user} from {room.room_id} as requested by {event.sender}")
|
||||||
|
|
Loading…
Reference in New Issue