add rooms mcommand
This commit is contained in:
parent
4764d8cd2a
commit
7a49169428
1 changed files with 19 additions and 0 deletions
|
@ -220,3 +220,22 @@ class EvalModule(niobot.Module):
|
|||
await ctx.respond(f"Result of runas: `{result!r}`")
|
||||
except Exception as e:
|
||||
await ctx.respond(f"Error in runas process: `{e!r}`")
|
||||
|
||||
@niobot.command()
|
||||
@niobot.is_owner()
|
||||
async def rooms(self, ctx: niobot.Context, operation: str, room: str = None):
|
||||
"""room management"""
|
||||
match operation.casefold():
|
||||
case "join":
|
||||
result = await self.bot.join(room)
|
||||
return await ctx.respond(repr(result))
|
||||
case "leave":
|
||||
if room.startswith("#"):
|
||||
resolved = await self.bot.room_resolve_alias(room)
|
||||
if not isinstance(resolved, niobot.RoomResolveAliasResponse):
|
||||
return await ctx.respond("Failed to resolve room ID for: %r", room)
|
||||
room = resolved.room_id
|
||||
response = await self.bot.room_leave(room)
|
||||
return await ctx.respond(repr(response))
|
||||
case _:
|
||||
return await ctx.respond("Unknown operation.")
|
||||
|
|
Loading…
Reference in a new issue