diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2024-02-09 16:33:14 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2024-02-09 16:33:14 +0100 |
commit | 163e2a94f600ffe0f982e3f605264ff2f2fe312b (patch) | |
tree | af8fb4c8c468dde726a4773b1304aa22c59186ac /Utilities/LibMatrix.DevTestBot/Bot/Commands | |
parent | Apply syntax style to LibMatrix (diff) | |
download | LibMatrix-163e2a94f600ffe0f982e3f605264ff2f2fe312b.tar.xz |
Apply syntax style to LibMatrix side projects
Diffstat (limited to 'Utilities/LibMatrix.DevTestBot/Bot/Commands')
4 files changed, 12 insertions, 22 deletions
diff --git a/Utilities/LibMatrix.DevTestBot/Bot/Commands/CmdCommand.cs b/Utilities/LibMatrix.DevTestBot/Bot/Commands/CmdCommand.cs index e690890..89a9033 100644 --- a/Utilities/LibMatrix.DevTestBot/Bot/Commands/CmdCommand.cs +++ b/Utilities/LibMatrix.DevTestBot/Bot/Commands/CmdCommand.cs @@ -8,9 +8,7 @@ public class CmdCommand : ICommand { public string Name => "cmd"; public string Description => "Runs a command on the host system"; - public Task<bool> CanInvoke(CommandContext ctx) { - return Task.FromResult(ctx.MessageEvent.Sender.EndsWith(":rory.gay") || ctx.MessageEvent.Sender.EndsWith(":conduit.rory.gay")); - } + public Task<bool> CanInvoke(CommandContext ctx) => Task.FromResult(ctx.MessageEvent.Sender.EndsWith(":rory.gay") || ctx.MessageEvent.Sender.EndsWith(":conduit.rory.gay")); public async Task Invoke(CommandContext ctx) { var cmd = ctx.Args.Aggregate("\"", (current, arg) => current + arg + " "); @@ -27,7 +25,7 @@ public class CmdCommand : ICommand { // .Split("\n").ToList(); var msg = ""; - EventIdResponse? msgId = await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent { + var msgId = await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent { FormattedBody = $"Waiting for command output...", Body = msg.RemoveAnsi(), Format = "m.notice" @@ -69,4 +67,4 @@ public class CmdCommand : ICommand { // } // } } -} +} \ No newline at end of file diff --git a/Utilities/LibMatrix.DevTestBot/Bot/Commands/DbgAniRainbowTest.cs b/Utilities/LibMatrix.DevTestBot/Bot/Commands/DbgAniRainbowTest.cs index c526847..f75c863 100644 --- a/Utilities/LibMatrix.DevTestBot/Bot/Commands/DbgAniRainbowTest.cs +++ b/Utilities/LibMatrix.DevTestBot/Bot/Commands/DbgAniRainbowTest.cs @@ -11,26 +11,22 @@ public class DbgAniRainbowTest(IServiceProvider services, HomeserverProviderServ public string Name { get; } = "ani-rainbow"; public string Description { get; } = "[Debug] animated rainbow :)"; - public async Task<bool> CanInvoke(CommandContext ctx) { - return ctx.Room.RoomId == "!hLEefBaYvNfJwcTjmt:rory.gay"; - } + public async Task<bool> CanInvoke(CommandContext ctx) => ctx.Room.RoomId == "!hLEefBaYvNfJwcTjmt:rory.gay"; public async Task Invoke(CommandContext ctx) { //255 long string // var rainbow = "🟥🟧🟨🟩🟦🟪"; var rainbow = "M"; var chars = rainbow; - for (var i = 0; i < 76; i++) { - chars += rainbow[i % rainbow.Length]; - } + for (var i = 0; i < 76; i++) chars += rainbow[i % rainbow.Length]; Task.Run(async () => { - int i = 0; - var msg = new MessageBuilder(msgType: "m.notice").WithRainbowString(chars).Build(); + var i = 0; + var msg = new MessageBuilder("m.notice").WithRainbowString(chars).Build(); var msgEvent = await ctx.Room.SendMessageEventAsync(msg); while (true) { - msg = new MessageBuilder(msgType: "m.notice").WithRainbowString(chars, offset: i * 5).Build(); + msg = new MessageBuilder("m.notice").WithRainbowString(chars, offset: i * 5).Build(); if (i % 50 == 0) { msg.NewContent = null; msg.RelatesTo = null; diff --git a/Utilities/LibMatrix.DevTestBot/Bot/Commands/HelpCommand.cs b/Utilities/LibMatrix.DevTestBot/Bot/Commands/HelpCommand.cs index 23c4fe2..7ecbeb3 100644 --- a/Utilities/LibMatrix.DevTestBot/Bot/Commands/HelpCommand.cs +++ b/Utilities/LibMatrix.DevTestBot/Bot/Commands/HelpCommand.cs @@ -13,10 +13,8 @@ public class HelpCommand(IServiceProvider services) : ICommand { var sb = new StringBuilder(); sb.AppendLine("Available commands:"); var commands = services.GetServices<ICommand>().ToList(); - foreach (var command in commands) { - sb.AppendLine($"- {command.Name}: {command.Description}"); - } + foreach (var command in commands) sb.AppendLine($"- {command.Name}: {command.Description}"); await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: sb.ToString())); } -} +} \ No newline at end of file diff --git a/Utilities/LibMatrix.DevTestBot/Bot/Commands/PingCommand.cs b/Utilities/LibMatrix.DevTestBot/Bot/Commands/PingCommand.cs index ba242fe..85c86a3 100644 --- a/Utilities/LibMatrix.DevTestBot/Bot/Commands/PingCommand.cs +++ b/Utilities/LibMatrix.DevTestBot/Bot/Commands/PingCommand.cs @@ -7,7 +7,5 @@ public class PingCommand : ICommand { public string Name { get; } = "ping"; public string Description { get; } = "Pong!"; - public async Task Invoke(CommandContext ctx) { - await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: "pong!")); - } -} + public async Task Invoke(CommandContext ctx) => await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: "pong!")); +} \ No newline at end of file |