From 9dcce18cda5317ea1150eed06d6589b6285577e6 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 4 Sep 2023 06:29:00 +0200 Subject: Add start of Media Moderator PoC bot --- LibMatrix/Responses/CreateRoomRequest.cs | 50 +++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'LibMatrix/Responses') diff --git a/LibMatrix/Responses/CreateRoomRequest.cs b/LibMatrix/Responses/CreateRoomRequest.cs index c1c1697..2c05088 100644 --- a/LibMatrix/Responses/CreateRoomRequest.cs +++ b/LibMatrix/Responses/CreateRoomRequest.cs @@ -7,6 +7,7 @@ using System.Text.Json.Serialization; using System.Text.RegularExpressions; using LibMatrix.Extensions; using LibMatrix.Helpers; +using LibMatrix.Homeservers; using LibMatrix.StateEventTypes.Spec; namespace LibMatrix.Responses; @@ -29,6 +30,9 @@ public class CreateRoomRequest { [JsonPropertyName("initial_state")] public List InitialState { get; set; } = null!; + /// + /// One of: ["public", "private"] + /// [JsonPropertyName("visibility")] public string Visibility { get; set; } = null!; @@ -38,6 +42,9 @@ public class CreateRoomRequest { [JsonPropertyName("creation_content")] public JsonObject CreationContent { get; set; } = new(); + [JsonPropertyName("invite")] + public List Invite { get; set; } + /// /// For use only when you can't use the CreationContent property /// @@ -53,9 +60,10 @@ public class CreateRoomRequest { StateEvent.KnownStateEventTypes.FirstOrDefault(x => x.GetCustomAttributes()? .Any(y => y.EventName == event_type) ?? false) ?? typeof(object) - ) + ) }); } + return stateEvent; } set { @@ -75,4 +83,44 @@ public class CreateRoomRequest { return errors; } + + public static CreateRoomRequest CreatePrivate(AuthenticatedHomeserverGeneric hs, string? name = null, string? roomAliasName = null) { + var request = new CreateRoomRequest() { + Name = name ?? "Private Room", + Visibility = "private", + CreationContent = new(), + PowerLevelContentOverride = new() { + EventsDefault = 0, + UsersDefault = 0, + Kick = 50, + Ban = 50, + Invite = 25, + StateDefault = 10, + Redact = 50, + NotificationsPl = new() { + Room = 10 + }, + Events = new() { + { "m.room.avatar", 50 }, + { "m.room.canonical_alias", 50 }, + { "m.room.encryption", 100 }, + { "m.room.history_visibility", 100 }, + { "m.room.name", 50 }, + { "m.room.power_levels", 100 }, + { "m.room.server_acl", 100 }, + { "m.room.tombstone", 100 } + }, + Users = new() { + { + hs.UserId, + 101 + } + } + }, + RoomAliasName = roomAliasName, + InitialState = new() + }; + + return request; + } } -- cgit 1.4.1