started work hs execution
This commit is contained in:
		
							
								
								
									
										60
									
								
								NadekoBot/Modules/Programming/Commands/HaskellRepl.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								NadekoBot/Modules/Programming/Commands/HaskellRepl.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -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; | ||||
|  | ||||
| /// <summary> | ||||
| /// I have no idea what am i doing | ||||
| /// </summary> | ||||
| namespace NadekoBot.Modules.Programming.Commands | ||||
| { | ||||
|     class HaskellRepl : DiscordCommand | ||||
|     { | ||||
|         Queue<KeyValuePair<string, Channel>> commandQueue = new Queue<KeyValuePair<string, Channel>>(); | ||||
|  | ||||
|         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 | ||||
|                 }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										26
									
								
								NadekoBot/Modules/Programming/ProgrammingModule.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								NadekoBot/Modules/Programming/ProgrammingModule.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -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)); | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user