Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            bool.TryParse(ConfigurationManager.AppSettings["testmode"], out _testMode);
            string password = ConfigurationManager.AppSettings["oauth"];

            //password from www.twitchapps.com/tmi
            //include the "oauth:" portion
            irc = new IrcClient("irc.twitch.tv", 6667, "mrsheila", password);

            //join channel
            irc.JoinRoom("voxdavis");

            CommandManager.AddCommand("!hype", "Used to generate hype!", (message) => { return "HYPE HYPE HYPE!!!!"; });
            CommandManager.AddCommand("!name", "Used to generate a random name.  Give a username afterwards to assign it to someone.", (message) =>
            {
                Regex r = new Regex(@"!name @[\w_\-]+");
                NameGenerator ng = new NameGenerator();

                if (r.IsMatch(message))
                {
                    string u = message.Substring(7);
                    return u + "'s new name is " + ng.GetName();
                }
                else
                {
                    return ng.GetName();
                }

            });
            CommandManager.AddCommand("!source", "Gets a link to the source code!", (message) => { return @"https://github.com/AronDavis/TwitchBot"; });

            if (_testMode)
            {
                while (true)
                {
                    string message = irc.readMessage();
                    if (message == null || message.Length == 0) continue;

                    if (message[0] == '!')
                    {
                        handleCommand("TestUser", message);
                    }
                }
            }
            else
            {
                while (true)
                {
                    string message = irc.readMessage();
                    if (message == null || message.Length == 0) continue;

                    Console.WriteLine(message);

                    if (message.IndexOf("!") >= 0) handleChatMessage(message);
                    else if (message.StartsWith("PING")) irc.sendIrcMessage("PONG");
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            bool.TryParse(ConfigurationManager.AppSettings["testmode"], out _testMode);
            string password = ConfigurationManager.AppSettings["oauth"];

            //password from www.twitchapps.com/tmi
            //include the "oauth:" portion
            irc = new IrcClient("irc.twitch.tv", 6667, "mrsheila", password);

            //join channel
            irc.JoinRoom("voxdavis");

            CommandManager.AddCommand("!hype", "Used to generate hype!", (message) => { return("HYPE HYPE HYPE!!!!"); });
            CommandManager.AddCommand("!name", "Used to generate a random name.  Give a username afterwards to assign it to someone.", (message) =>
            {
                Regex r          = new Regex(@"!name @[\w_\-]+");
                NameGenerator ng = new NameGenerator();

                if (r.IsMatch(message))
                {
                    string u = message.Substring(7);
                    return(u + "'s new name is " + ng.GetName());
                }
                else
                {
                    return(ng.GetName());
                }
            });
            CommandManager.AddCommand("!source", "Gets a link to the source code!", (message) => { return(@"https://github.com/AronDavis/TwitchBot"); });


            if (_testMode)
            {
                while (true)
                {
                    string message = irc.readMessage();
                    if (message == null || message.Length == 0)
                    {
                        continue;
                    }

                    if (message[0] == '!')
                    {
                        handleCommand("TestUser", message);
                    }
                }
            }
            else
            {
                while (true)
                {
                    string message = irc.readMessage();
                    if (message == null || message.Length == 0)
                    {
                        continue;
                    }

                    Console.WriteLine(message);

                    if (message.IndexOf("!") >= 0)
                    {
                        handleChatMessage(message);
                    }
                    else if (message.StartsWith("PING"))
                    {
                        irc.sendIrcMessage("PONG");
                    }
                }
            }
        }