Browse Source

Set logo on space creation

Kumi 1 year ago
parent
commit
9f520b7340
1 changed files with 10 additions and 0 deletions
  1. 10 0
      commands/space.py

+ 10 - 0
commands/space.py

@@ -20,6 +20,11 @@ async def command_space(room: MatrixRoom, event: RoomMessageText, bot):
                 bot.logger.log(
                     f"Created space {space} for user {event.sender}")
 
+                if bot.logo_uri:
+                    await bot.matrix_client.room_put_state(space, "m.room.avatar", {
+                        "url": bot.logo_uri
+                    }, "")
+
                 with bot.database.cursor() as cursor:
                     cursor.execute(
                         "INSERT INTO user_spaces (space_id, user_id) VALUES (?, ?)", (space, event.sender))
@@ -87,6 +92,11 @@ async def command_space(room: MatrixRoom, event: RoomMessageText, bot):
 
             await bot.add_rooms_to_space(space, join_rooms)
 
+            if bot.logo_uri:
+                await bot.matrix_client.room_put_state(space, "m.room.avatar", {
+                    "url": bot.logo_uri
+                }, "")
+
             await bot.send_message(room, "Space updated.", True)
             return