From d133a168c17d605236e967ff63728420ddb0ed98 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 31 Jan 2024 18:50:16 +0100 Subject: Repo split --- .../Bot/Commands/CreateSystemCommand.cs | 57 ---------------------- 1 file changed, 57 deletions(-) delete mode 100644 ExampleBots/PluralContactBotPoC/Bot/Commands/CreateSystemCommand.cs (limited to 'ExampleBots/PluralContactBotPoC/Bot/Commands') diff --git a/ExampleBots/PluralContactBotPoC/Bot/Commands/CreateSystemCommand.cs b/ExampleBots/PluralContactBotPoC/Bot/Commands/CreateSystemCommand.cs deleted file mode 100644 index 0bb3265..0000000 --- a/ExampleBots/PluralContactBotPoC/Bot/Commands/CreateSystemCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using LibMatrix; -using LibMatrix.EventTypes.Spec.State; -using LibMatrix.Helpers; -using LibMatrix.Services; -using LibMatrix.Utilities.Bot.Interfaces; -using PluralContactBotPoC.Bot.AccountData; -using PluralContactBotPoC.Bot.StateEventTypes; - -namespace PluralContactBotPoC.Bot.Commands; - -public class CreateSystemCommand(IServiceProvider services, HomeserverProviderService hsProvider, HomeserverResolverService hsResolver) : ICommand { - public string Name { get; } = "createsystem"; - public string Description { get; } = "Create a new system"; - - public async Task CanInvoke(CommandContext ctx) { - return true; - } - - public async Task Invoke(CommandContext ctx) { - if (ctx.Args.Length != 1) { - await ctx.Reply(MessageFormatter.FormatError("Only one argument is allowed: system name!")); - return; - } - - var sysName = ctx.Args[0]; - try { - try { - await ctx.Homeserver.GetAccountDataAsync("gay.rory.plural_contact_bot.system_data"); - await ctx.Reply(MessageFormatter.FormatError($"System {sysName} already exists!")); - } - catch (MatrixException e) { - if (e is { ErrorCode: "M_NOT_FOUND" }) { - var sysData = new SystemData() { - ControlRoom = ctx.Room.RoomId, - Members = new(), - }; - - var state = ctx.Room.GetMembersEnumerableAsync(); - await foreach (var member in state) { - sysData.Members.Add(member.StateKey); - } - - await ctx.Room.SendStateEventAsync("m.room.name", new RoomNameEventContent() { - Name = sysName + " control room" - }); - - return; - } - - throw; - } - } - catch (Exception e) { - await ctx.Reply(MessageFormatter.FormatException("Something went wrong!", e)); - } - } -} -- cgit 1.4.1