private void HandleEventLoop(IrcDotNet.IrcClient client) { logger.Debug("In HandleEventLoop"); IsExit = false; while (!IsExit) { Console.Write("> "); var command = Console.ReadLine(); switch (command) { case "exit": case "quit": IsExit = true; break; default: if (!string.IsNullOrEmpty(command)) { if (command.StartsWith("limit")) { short tempLimit; if (Int16.TryParse(command.Substring(6).Trim(), out tempLimit)) levels.LevelLimit = tempLimit; } else if (command == "o") { if (!levels.Open) { levels.OpenQueue(); client.SendPrivateMessage(MAINCHANNEL, "/me Submissions Open"); client.SendPrivateMessage(MAINCHANNEL, "/me Submit levels with !submit"); } } else if (command == "c") { if (levels.Open) { levels.CloseQueue(); client.SendPrivateMessage(MAINCHANNEL, "/me Submissions Closed"); if (levels.FinalLevels.Count >= 0) { string plural = (levels.FinalLevels.Count != 1) ? " levels " : " level "; client.SendPrivateMessage(MAINCHANNEL, "/me " + levels.FinalLevels.Count + plural + "will be randomly picked."); client.SendPrivateMessage(MAINCHANNEL, "/me Now Playing: " + levels.CurrentLevel); Console.WriteLine(); Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")"); Console.WriteLine(); PostToWebsite(); } else client.SendPrivateMessage(MAINCHANNEL, "/me No Levels submitted."); } } else if (command.StartsWith("s ")) { command = command.Remove(0, 2).Trim(); SaveLevel(command); } else if (command == "settings") { OpenSettingsWindow(); } else if (command == "restart") { this.Restart = true; return; } else if (command.StartsWith("v ")) { command = command.Remove(0, 2).Trim(); short vol; if(Int16.TryParse(command,out vol)) { soundPlayerVolume = vol; } } else if (command.StartsWith("max ")) { command = command.Remove(0, 4).Trim(); int amt; if (Int32.TryParse(command, out amt)) { if (amt<=0) break; BotSettings.MaxSubmissionsForSingleUser = amt; Console.WriteLine("User can only submit " + amt + " level(s) per round."); Console.WriteLine(); } } else if (command.StartsWith("cool ")) { command = command.Remove(0, 5).Trim(); int tempCooldown; if (int.TryParse(command, out tempCooldown)) { cooldownSeconds = tempCooldown; } } else if (command == "q") { foreach (var level in levels.FinalLevels) { Console.WriteLine(level.Item2 + " " + level.Item1); } } else if (command.StartsWith("add ")) { string[]args = command.Split(' '); if (args.Length > 2) { if (LevelSubmitter.IsValidLevelCode(ref args[2])) { levels.ForceAddLevel(args[2].ToUpper(), args[1]); PostToWebsite(); if (levels.Remaining==0) Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")"); } } } else if (command == "prev") { if (levels.Remaining == levels.FinalLevels.Count) break; levels.PreviousLevel(); PostToWebsite(); Console.WriteLine(); Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")"); Console.WriteLine(); } else if (command == "h" || command == "help") { DisplayMainMenu(); } } //ELSE - command IsNullOrEmpty - (Enter Key pressed) else { if (levels.Remaining > 0) { levels.NextLevel(); PostToWebsite(); client.SendPrivateMessage(MAINCHANNEL, "/me Now Playing: " + levels.CurrentLevel); Console.WriteLine(); Console.WriteLine(levels.CurrentLevel + " ("+ levels.Remaining + ")"); Console.WriteLine(); } } break; } } client.Disconnect(); }
private static void HandleEventLoop(IrcDotNet.IrcClient client) { bool isExit = false; while (!isExit) { Console.Write ("> "); var command = Console.ReadLine(); switch (command) { case "exit": isExit = true; break; default: if (!string.IsNullOrEmpty(command)) { if (command.StartsWith("/") && command.Length > 1) { client.SendRawMessage(command.Substring(1)); } else { Console.WriteLine("unknown command '{0}'", command); } } break; } } client.Disconnect(); }
private void HandleEventLoop(IrcDotNet.IrcClient client,string sChannel) { var channel = discordclient.Servers.First().TextChannels.Where(x => x.Name.ToLower() == sTargetChannel.ToLower()); bDisconnected = false; if (channel != null) { channel.First().SendMessage("Twitch Relay Activated"); } while (!isExit) { if (client.Channels.Where(x => x.Name.ToLower().Contains(sChannel.ToLower())).Count() == 0) { client.Channels.Join("#"+sChannel); } Thread.Sleep(5000); } discordclient.Servers.First().TextChannels.Where(x => x.Name.ToLower() == sTargetChannel.ToLower()).First().SendMessage("Twitch Relay Terminated"); client.Disconnect(); }