From caa2a456f83f63683360c6028ef75d4aada7528e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 1 May 2016 02:53:09 +0200 Subject: [PATCH] started work hs execution --- .../Programming/Commands/HaskellRepl.cs | 60 +++++++++++++++++++ .../Modules/Programming/ProgrammingModule.cs | 26 ++++++++ 2 files changed, 86 insertions(+) create mode 100644 NadekoBot/Modules/Programming/Commands/HaskellRepl.cs create mode 100644 NadekoBot/Modules/Programming/ProgrammingModule.cs diff --git a/NadekoBot/Modules/Programming/Commands/HaskellRepl.cs b/NadekoBot/Modules/Programming/Commands/HaskellRepl.cs new file mode 100644 index 00000000..567d9b84 --- /dev/null +++ b/NadekoBot/Modules/Programming/Commands/HaskellRepl.cs @@ -0,0 +1,60 @@ +using Discord; +using Discord.Commands; +using NadekoBot.Classes; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +/// +/// I have no idea what am i doing +/// +namespace NadekoBot.Modules.Programming.Commands +{ + class HaskellRepl : DiscordCommand + { + Queue> commandQueue = new Queue>(); + + Thread haskellThread; + + public HaskellRepl(DiscordModule module) : base(module) + { + //start haskell interpreter + + haskellThread = new Thread(new ThreadStart(() => + { + Process.Start(new ProcessStartInfo + { + FileName = "stack", //shouldn't use repl, but a Language.Haskell.Interpreter somehow + Arguments = "repl" + }); + + })); + + + Task.Run(() => + { + //read from queue + + //send the command to the process + + //wait 50 ms for execution + + //read everything from the output + + //send to chanenl + }); + + } + + internal override void Init(CommandGroupBuilder cgb) + { + cgb.CreateCommand(Module.Prefix + "hs") + .Description("Executes a haskell express with LAMBDABOT") + .Do(async e => + { + //send a command and a channel to the queue + }); + } + } +} diff --git a/NadekoBot/Modules/Programming/ProgrammingModule.cs b/NadekoBot/Modules/Programming/ProgrammingModule.cs new file mode 100644 index 00000000..feb3c4e2 --- /dev/null +++ b/NadekoBot/Modules/Programming/ProgrammingModule.cs @@ -0,0 +1,26 @@ +using Discord.Modules; +using NadekoBot.Extensions; +using NadekoBot.Modules.Permissions.Classes; +using NadekoBot.Modules.Programming.Commands; + +namespace NadekoBot.Modules.Programming +{ + class ProgrammingModule : DiscordModule + { + public override string Prefix => NadekoBot.Config.CommandPrefixes.Programming; + + public ProgrammingModule() + { + commands.Add(new HaskellRepl(this)); + } + + public override void Install(ModuleManager manager) + { + manager.CreateCommands("", cgb => + { + cgb.AddCheck(PermissionChecker.Instance); + commands.ForEach(c => c.Init(cgb)); + }); + } + } +}