2023-04-19 06:11:28 +00:00
|
|
|
from nio.events.room_events import RoomMessageText
|
|
|
|
from nio.rooms import MatrixRoom
|
|
|
|
|
2023-04-23 13:26:46 +00:00
|
|
|
|
2023-04-19 06:11:28 +00:00
|
|
|
async def command_newroom(room: MatrixRoom, event: RoomMessageText, context: dict):
|
2023-04-23 13:26:46 +00:00
|
|
|
room_name = " ".join(event.body.split()[
|
|
|
|
2:]) or context["default_room_name"]
|
2023-04-19 06:11:28 +00:00
|
|
|
|
|
|
|
context["logger"]("Creating new room...")
|
|
|
|
new_room = await context["client"].room_create(name=room_name)
|
|
|
|
|
|
|
|
context["logger"](f"Inviting {event.sender} to new room...")
|
|
|
|
await context["client"].room_invite(new_room.room_id, event.sender)
|
|
|
|
await context["client"].room_put_state(
|
|
|
|
new_room.room_id, "m.room.power_levels", {"users": {event.sender: 100}})
|
|
|
|
|
2023-04-23 13:26:46 +00:00
|
|
|
return new_room.room_id, "m.room.message", {"msgtype": "m.text", "body": "Welcome to the new room!"}
|