Exemple #1
0
        //password from twitchapps.com/tmi
        static void Main(string[] args)
        {
            var irc = new IrcClient("irc.twitch.tv",6667, "cogwheelbot", "oauth:ffiiryof5w501xlz43qbk75k9xcmv1");
            irc.JoinRoom("faddei");
            var stopWatch = Stopwatch.StartNew();
            while (true)
            {
                string message = irc.ReadMessage();
                if(!string.IsNullOrEmpty(message)) {
                    Console.WriteLine(message);
                    if (message.ToLower().Contains("!hallo"))
                    {
                        irc.SendChatMessage("Testing Testing");
                    }
                    if (message.ToLower().Contains("!add"))
                    {
                        string[] html = message.Split('!');
                        Console.WriteLine("open link: "+html[1].Substring(4));
                        System.Diagnostics.Process.Start(html[1].Substring(4));
                    }
                    if (message.ToLower().Contains("!uptime"))
                    {
                        DateTime time = new DateTime(stopWatch.ElapsedTicks);
                        string uptime = time.ToString("HH:mm:ss");
                        irc.SendChatMessage(time.Hour+ " hours "+ time.Minute + " mins");
                        irc.SendChatMessage(uptime);
                    }
                }

            }
        }
Exemple #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");
                }
            }
        }
        private void Initialization()
        {
            infoDisplayTimer          = new DispatcherTimer();
            infoDisplayTimer.Tick    += infoDisplayTimer_Tick;
            infoDisplayTimer.Interval = new TimeSpan(0, InfoInterval, 0);
            infoDisplayTimer.Start();

            irc  = new IrcClient("irc.twitch.tv", 6667, "hap_pybot", "oauth:" + oauth);
            bot  = new Bot(irc);
            info = bot.LoadTextFile("_info");
            scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;



            if (irc.Connected)
            {
                irc.JoinRoom(ChannelToJoin);
                StartThread();
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
Exemple #4
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");
                    }
                }
            }
        }