public static async void roll(int size, Random rnd, IrcClient irc) { int die = rnd.Next(1, size); irc.sendChatMessage("Rolling d" + (size - 1) + "... "); await Task.Delay(3000); irc.sendChatMessage("Rolled " + die); }
static void Main(string[] args) { IrcClient irc = new IrcClient("irc.twitch.tv", 6667, "hawaiiansnowbot", ""); Random rnd = new Random(); irc.joinRoom("misstakaii"); bool alive = true; string chatUser = ""; string command = ""; string param1 = ""; string param2 = ""; while (alive) { string message = irc.readMessage(); try { string[] msgarr = message.Split(' '); chatUser = (msgarr[0].Substring(1)).Split('!')[0]; command = msgarr[3].Substring(1); param1 = msgarr[4]; param2 = msgarr[5]; } catch (Exception ex) when (ex is IndexOutOfRangeException || ex is NullReferenceException){} if (command == "!roll") { int size; try { if (Int32.TryParse(param1, out size)) { if (size >= 3) { roll((size + 1), rnd, irc); } } else { roll(7, rnd, irc); } } catch (IndexOutOfRangeException ex) { roll(7, rnd, irc); } } if (command == "!keyboard65") { irc.sendChatMessage("LIES! Takaii uses a Crayola USB EZ Type Keyboard"); } if (chatUser == "hawaiiansnowman" && command == "!die") { irc.sendChatMessage("Boom!"); alive = false; } } }