private void TryExecute(ircmsg msg) { if (!_entertain) { return; } string text = msg.FullTail; string origin = msg.Origin; if (msg.Tail.Count >= 1 && msg.Tail[0].Length >= 2 && msg.Tail[0].Substring(1) == "bb") { } else { Console.WriteLine(msg); } if (msg.Tail.Count >= 1) { for (int i = 0; i < msg.Tail.Count; i++) { if (msg.Tail[i] == "Kappa" || msg.Tail[i] == "KappaClaus" || msg.Tail[i] == "KappaPride" || msg.Tail[i] == "KappaRoss" || msg.Tail[i] == "KappaWealth" || msg.Tail[i] == "Keepo") { _numkappa++; Virilib.WriteFile("kappacount.txt", new string[] { _numkappa.ToString() }); } } } StringBuilder sb = new StringBuilder(); if (!string.IsNullOrWhiteSpace(msg.Origin)) { sb.AppendFormat("{0}: ", msg.Origin); } if (text[0] == '!' && text.Length > 1) { _ap.Origin = msg.Origin; object[] message; // await Task.Run<Lieutenant.executereturn>(() => _lt.Execute(text.Substring(1), msg.Origin)); _lt.Execute(text.Substring(1), _ap, out message); if (message.Length >= 1 && message[0] != null && (!string.IsNullOrWhiteSpace(message[0].ToString()))) { sb.Append(message[0]); viribot.Say(sb.ToString()); } _ap.Origin = ""; } }
void _viribot_OnPrivMsg(ircmsg themsg) { //Console.WriteLine(themsg.Function + " " + themsg.Origin + " " + themsg.FullTail); this.Invoke((MethodInvoker)(() => { if (themsg.Function == "PRIVMSG") { if (string.IsNullOrWhiteSpace(themsg.FullTail)) { return; } TryExecute(themsg); } else if (themsg.Function == "JOIN") { if (_entertain) { //Console.WriteLine(themsg.Origin + " joined"); if (Virilib.SecRandom(2) == 1) { Console.Error.WriteLine("Ugh, it's " + themsg.Origin); } else { Console.Error.WriteLine("<3 <3 <3 It's " + themsg.Origin); } _lblviewercount.Text = "Viewers: " + viribot.ViewerCount; } } else if (themsg.Function == "PART") { if (_entertain) { Console.WriteLine(themsg.Origin + " left"); _lblviewercount.Text = "Viewers: " + viribot.ViewerCount; } } })); }