diff --git a/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs index 1e1988f..b3831b5 100644 --- a/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs +++ b/ChaosBot/Services/ProgrammingLanguageInterpreter/ProgrammingLanguageInterpreterFacade.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using System.Text; using System.Threading; using System.Threading.Tasks; using ChaosBot.Models; @@ -39,8 +41,17 @@ namespace ChaosBot.Services.ProgrammingLanguageInterpreter } string output = task.Result; - - if (output.Length > 0) + + if (output.Length > 2000) + { + context.Channel.SendMessageAsync($"Command '{customCommand.Command}' has {output.Length} characters of output. That is more than the 2000 limit. Packaging into file...").GetAwaiter().GetResult(); + Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(output)); + if (stream.Length > 8 * 1024 * 1024) + context.Channel.SendMessageAsync($"Packaged filesize of {stream.Length / 1024 / 1024} MB is too big."); + else + context.Channel.SendFileAsync(stream, "command-output.txt"); + } + else if (output.Length > 0) context.Channel.SendMessageAsync(output); else context.Channel.SendMessageAsync($"Command '{customCommand.Command}' had no output.");