private static void IrcClient_Channel_MessageReceived(object sender, IrcMessageEventArgs e) { var channel = (IrcChannel)sender; if (e.Source is IrcUser) { IrcUser user = (IrcUser)e.Source; string command = e.Text; //Twitch notify will let you know if you have a new sub or are hosted. if (user.NickName == "twitchnotify") { Console.WriteLine(""); Console.WriteLine(command); Console.WriteLine(""); } else if (command.StartsWith("!") && command.Length > 1) { command = command.Remove(0, 1); //SUB and Operator only commands if (user.IsOperator || twitchAPI.Subscribers.Contains(user.NickName)) { switch (command) { case "bfb": PlaySound("sounds\\bfb.mp3"); break; case "speed": PlaySound("sounds\\speed.mp3"); break; case "yeah": PlaySound("sounds\\yeah.mp3"); break; case "dik": PlaySound("sounds\\dik.mp3"); break; case "uptime": Random m = new Random(); string hr = m.Next(2, 999).ToString(); channel.Client.SendPrivateMessage(MAINCHANNEL, "Uptime: " + hr + " hours."); break; default: break; } } //Any other commands: if (command.StartsWith("submit ")) { //People trying to submit when the QUEUE is closed, get warned - to avoid spam. if (!levels.Open) { InvalidSubmission(channel); return; } command = command.Remove(0, 6).Trim(); if (LevelSubmitter.IsValidLevelCode(ref command)) { if (user.IsOperator || twitchAPI.Subscribers.Contains(user.NickName)) { levels.AddLevel(command.ToUpper(), user.NickName, 5); } else { levels.AddLevel(command.ToUpper(), user.NickName, 1); } } } } } }
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(); }