From d133a168c17d605236e967ff63728420ddb0ed98 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 31 Jan 2024 18:50:16 +0100 Subject: Repo split --- ExampleBots/ModerationBot/FirstRunTasks.cs | 83 ------------------------------ 1 file changed, 83 deletions(-) delete mode 100644 ExampleBots/ModerationBot/FirstRunTasks.cs (limited to 'ExampleBots/ModerationBot/FirstRunTasks.cs') diff --git a/ExampleBots/ModerationBot/FirstRunTasks.cs b/ExampleBots/ModerationBot/FirstRunTasks.cs deleted file mode 100644 index 9dece1d..0000000 --- a/ExampleBots/ModerationBot/FirstRunTasks.cs +++ /dev/null @@ -1,83 +0,0 @@ -using LibMatrix; -using LibMatrix.Homeservers; -using LibMatrix.Responses; -using ModerationBot.AccountData; - -namespace ModerationBot; - -public class FirstRunTasks { - public static async Task ConstructBotData(AuthenticatedHomeserverGeneric hs, ModerationBotConfiguration configuration, BotData? botdata) { - botdata ??= new BotData(); - var creationContent = CreateRoomRequest.CreatePrivate(hs, name: "Rory&::ModerationBot - Control room", roomAliasName: "moderation-bot-control-room"); - creationContent.Invite = configuration.Admins; - creationContent.CreationContent["type"] = "gay.rory.moderation_bot.control_room"; - - if (botdata.ControlRoom is null) - try { - botdata.ControlRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - catch (Exception e) { - if (e is not MatrixException { ErrorCode: "M_ROOM_IN_USE" }) { - Console.WriteLine(e); - throw; - } - - creationContent.RoomAliasName += $"-{Guid.NewGuid()}"; - botdata.ControlRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - //set access rules to allow joining via control room - // creationContent.InitialState.Add(new StateEvent { - // Type = "m.room.join_rules", - // StateKey = "", - // TypedContent = new RoomJoinRulesEventContent { - // JoinRule = "knock_restricted", - // Allow = new() { - // new RoomJoinRulesEventContent.AllowEntry { - // Type = "m.room_membership", - // RoomId = botdata.ControlRoom - // } - // } - // } - // }); - - creationContent.Name = "Rory&::ModerationBot - Log room"; - creationContent.RoomAliasName = "moderation-bot-log-room"; - creationContent.CreationContent["type"] = "gay.rory.moderation_bot.log_room"; - - if (botdata.LogRoom is null) - try { - botdata.LogRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - catch (Exception e) { - if (e is not MatrixException { ErrorCode: "M_ROOM_IN_USE" }) { - Console.WriteLine(e); - throw; - } - - creationContent.RoomAliasName += $"-{Guid.NewGuid()}"; - botdata.LogRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - - creationContent.Name = "Rory&::ModerationBot - Policy room"; - creationContent.RoomAliasName = "moderation-bot-policy-room"; - creationContent.CreationContent["type"] = "gay.rory.moderation_bot.policy_room"; - - if (botdata.DefaultPolicyRoom is null) - try { - botdata.DefaultPolicyRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - catch (Exception e) { - if (e is not MatrixException { ErrorCode: "M_ROOM_IN_USE" }) { - Console.WriteLine(e); - throw; - } - - creationContent.RoomAliasName += $"-{Guid.NewGuid()}"; - botdata.DefaultPolicyRoom = (await hs.CreateRoom(creationContent)).RoomId; - } - - await hs.SetAccountDataAsync("gay.rory.moderation_bot_data", botdata); - - return botdata; - } -} -- cgit 1.4.1