diff --git a/Tools/BiblioTech/Commands/AdminCommand.cs b/Tools/BiblioTech/Commands/AdminCommand.cs index d35f937..4ad3a3c 100644 --- a/Tools/BiblioTech/Commands/AdminCommand.cs +++ b/Tools/BiblioTech/Commands/AdminCommand.cs @@ -110,15 +110,7 @@ namespace BiblioTech.Commands } var report = string.Join(Environment.NewLine, Program.UserRepo.GetInteractionReport(user)); - if (report.Length > 1900) - { - var filename = $"user-{user.Username}.log"; - await context.FollowupWithAttachement(filename, report); - } - else - { - await context.Followup(report); - } + await context.Followup(report); } } @@ -293,7 +285,8 @@ namespace BiblioTech.Commands var nl = Environment.NewLine; var content = new List { - $"{DateTime.UtcNow.ToString("o")} - {group.Count()} Codex nodes." + $"{DateTime.UtcNow.ToString("o")} - {group.Count()} Codex nodes.", + $"Deployment name: '{name}'" }; foreach (var node in group) @@ -311,8 +304,7 @@ namespace BiblioTech.Commands } } - var filename = $"netinfo-{NoWhitespaces(name)}.log"; - await context.FollowupWithAttachement(filename, string.Join(nl, content.ToArray())); + await context.Followup(string.Join(nl, content)); }); } } @@ -336,29 +328,32 @@ namespace BiblioTech.Commands await OnDeployment(context, async (group, name) => { - await context.Followup($"Calling debug/peer for '{peerId}' on {group.Count()} Codex nodes."); + var nl = Environment.NewLine; + var content = new List + { + $"{DateTime.UtcNow.ToString("o")} - {group.Count()} Codex nodes.", + $"Deployment name: '{name}'" + }; + + content.Add($"Calling debug/peer for '{peerId}' on {group.Count()} Codex nodes."); foreach (var node in group) { try { var info = node.GetDebugPeer(peerId); - var nl = Environment.NewLine; var json = JsonConvert.SerializeObject(info, Formatting.Indented); var jsonInsert = $"{nl}```{nl}{json}{nl}```{nl}"; - await context.Followup($"Node '{node.GetName()}' responded with {jsonInsert}"); + content.Add($"Node '{node.GetName()}' responded with {jsonInsert}"); } catch (Exception ex) { - await context.Followup($"Node '{node.GetName()}' failed to respond with exception: " + ex); + content.Add($"Node '{node.GetName()}' failed to respond with exception: " + ex); } } + + await context.Followup(string.Join(nl, content)); }); } } - - private static string NoWhitespaces(string s) - { - return s.Replace(" ", "-"); - } } } diff --git a/Tools/BiblioTech/Commands/SprCommand.cs b/Tools/BiblioTech/Commands/SprCommand.cs index 6d52b3d..ed19c7f 100644 --- a/Tools/BiblioTech/Commands/SprCommand.cs +++ b/Tools/BiblioTech/Commands/SprCommand.cs @@ -50,7 +50,7 @@ namespace BiblioTech.Commands var i = random.Next(0, sprCache.Count); var spr = sprCache[i]; - await context.Followup($"Your SPR: '{spr}'"); + await context.Followup($"Your SPR: `{spr}`"); } private bool ShouldUpdate() diff --git a/Tools/BiblioTech/Options/CommandContext.cs b/Tools/BiblioTech/Options/CommandContext.cs index 01567ce..d3293e1 100644 --- a/Tools/BiblioTech/Options/CommandContext.cs +++ b/Tools/BiblioTech/Options/CommandContext.cs @@ -15,13 +15,19 @@ namespace BiblioTech.Options public async Task Followup(string message) { + if (message.Length > 1900) + { + await FollowupWithAttachement("codexdiscordbot_file.txt", message); + return; + } + await Command.ModifyOriginalResponseAsync(m => { m.Content = message; }); } - public async Task FollowupWithAttachement(string filename, string content) + private async Task FollowupWithAttachement(string filename, string content) { using var fileStream = new MemoryStream(); using var streamWriter = new StreamWriter(fileStream);