public TwitchChatRoom(TwitchChatConnection chatConnection, TwitchChatConnection whisperConnection, Channel channel)
        {
            this.chatConnection = chatConnection;
            this.whisperConnection = whisperConnection;
            this.channel = channel;

            chatConnection.join(this);
        }
        public TwitchChatRoom(TwitchChatConnection chatConnection, TwitchChatConnection whisperConnection, Channel channel)
        {
            this.chatConnection    = chatConnection;
            this.whisperConnection = whisperConnection;
            this.channel           = channel;

            chatConnection.join(this);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // Set up the chat server and whisper server, using the authentication fields
            TwitchChatConnection chatConnection = new TwitchChatConnection(new IrcClient(IRC_SERVER, PORT, RECONNECT_TIME, BOTNAME, OAUTH_TOKEN), false);
            TwitchChatConnection whisperConnection = new TwitchChatConnection(new IrcClient(WHISPER_SERVER, PORT, RECONNECT_TIME, BOTNAME, OAUTH_TOKEN), true);

            // Create a list of channels from all the rows in the CHANNELS table, as well as the bot itself,
            // then create a connection to the chat server and whisper connection
            channels = new List<Channel>();
            channels.Add(new Channel(BOTNAME));
            channels.AddRange(Database.GetChannelList());
            foreach (Channel channel in channels)
            {
                new TwitchChatRoom(chatConnection, whisperConnection, channel);
            }

            // Start the pulling in data from the chat server and whisper server streams
            // (if you want to added a second, third, fourth etc. bot, double up on these threads)
            new Thread(new ThreadStart(chatConnection.Run)).Start();
            new Thread(new ThreadStart(whisperConnection.Run)).Start();
        }
        static void Main(string[] args)
        {
            // Set up the chat server and whisper server, using the authentication fields
            // TwitchChatConnection oldServerConnection = new TwitchChatConnection(new IrcClient(IRC_SERVER, PORT, RECONNECT_TIME, BOTNAME, OAUTH_TOKEN), false);
            TwitchChatConnection ircServerConnection = new TwitchChatConnection(new IrcClient(IRC_SERVER, PORT, RECONNECT_TIME, BOTNAME, OAUTH_TOKEN), false);
            TwitchChatConnection whisperConnection   = new TwitchChatConnection(new IrcClient(WHISPER_SERVER, PORT, RECONNECT_TIME, BOTNAME, OAUTH_TOKEN), true);

            // Create a list of channels from all the rows in the CHANNELS table, as well as the bot itself,
            // then create a connection to the chat server and whisper connection
            channels = new List <Channel>();
            channels.Add(new Channel(BOTNAME));
            channels.AddRange(Database.GetChannelList());
            foreach (Channel channel in channels)
            {
                // new TwitchChatRoom(oldServerConnection, whisperConnection, channel);
                new TwitchChatRoom(ircServerConnection, ircServerConnection, channel);
            }

            // Start the pulling in data from the chat server and whisper server streams
            // (if you want to added a second, third, fourth etc. bot, double up on these threads)
            // new Thread(new ThreadStart(oldServerConnection.Run)).Start();
            new Thread(new ThreadStart(ircServerConnection.Run)).Start();
            new Thread(new ThreadStart(whisperConnection.Run)).Start();
        }
Esempio n. 5
0
        public static void Main(string[] args)
        {
            // Get a client stream for reading and writing.
            using (TwitchChatConnection connection = new TwitchChatConnection(Config.ChatServer, Config.Port))
            {
                // Send login request
                Console.WriteLine("Sent login.\r\n");
                string responseData = connection.SendLoginRequest(Config.OAuth, Config.Nickname);
                Console.WriteLine("Received WELCOME: \r\n\r\n{0}", responseData);

                // send message to join channel
                connection.JoinChannel(Config.ChannelName);
                Console.WriteLine("Sent channel join.\r\n");

                // subscribe to events
                responseData = connection.SubcribeToMembershipEvents(Config.ChannelName);
                Console.WriteLine("Subcribe to JOIN/PART: \r\n\r\n{0}", responseData);

                //twitch JSON api for bots to use
                TwitchApiClient api = new TwitchApiClient();

                //db storage
                IViewerRepository     viewerDb     = new SqlViewerRepository();
                IDictionaryRepository dictionaryDb = new SqlDictionaryRepository();
                IChannelRepository    channelDb    = new SqlChannelRepository();
                IQuoteRepository      quoteDb      = new SqlQuoteRepository();
                IBlasphemyRepository  blasphDb     = new SqlBlasphemyRepository();

                //start bot
                KatBot      katbot      = new KatBot(connection.Writer, api);
                AkinatorBot akinatorBot = new AkinatorBot(connection.Writer, api);

                var quoteCommand = new Commands.Quote(connection.Writer, channelDb, quoteDb);

                //add commands
                katbot.CommandList.Add(new Commands.Command(connection.Writer));
                katbot.CommandList.Add(new Commands.HowLong(connection.Writer, api));
                katbot.CommandList.Add(new Commands.Uptime(connection.Writer, api));
                katbot.CommandList.Add(new Commands.Viewers(connection.Writer, api, viewerDb));
                katbot.CommandList.Add(new Commands.Madlib(connection.Writer, dictionaryDb));
                katbot.CommandList.Add(new Commands.FullWidth(connection.Writer));
                katbot.CommandList.Add(new Commands.Define(connection.Writer, dictionaryDb));
                katbot.CommandList.Add(new Commands.Blasphemy(connection.Writer, api, blasphDb));
                katbot.CommandList.Add(quoteCommand);
                katbot.CommandList.Add(new Commands.Bnet(connection.Writer, viewerDb));
                katbot.CommandList.Add(new Commands.Note(connection.Writer, viewerDb));

                katbot.KeywordProcessors.Add(new Commands.Question(connection.Writer, api, dictionaryDb));
                katbot.KeywordProcessors.Add(new Commands.KeywordMatcher(connection.Writer, channelDb));
                katbot.KeywordProcessors.Add(quoteCommand);
                katbot.KeywordProcessors.Add(new Commands.UrlExpander(connection.Writer));

                //Start message loop
                while (true)
                {
                    MessageInfo message = connection.ReadMessage();

                    if (message != null)
                    {
                        katbot.ProcessMessage(message);
                        akinatorBot.ProcessMessage(message);
                        akinatorBot.Update();
                    }
                }
            }
        }