Beispiel #1
0
        void InitializeCommandProcessors()
        {
            var joinProcessor = new JoinCommandProcessor();

            joinProcessor.Joined += (channel, username) =>
                                    Dispatcher.Invoke(() => JoinedRoom?.Invoke(channel, username));
            joinProcessor.Joined += (channel, username) => {
                // Bot successfully connected to the channel.
                string lowerName = Connection.Username.ToLowerInvariant();
                if (channel == Connection.Channel && username == lowerName)
                {
                    Dispatcher.Invoke(() => Connected?.Invoke());
                }
            };

            var messageProcessor = new MessageCommandProcessor();

            messageProcessor.MessageReceived += message =>
                                                Dispatcher.Invoke(() => MessageReceived?.Invoke(message));

            var userStateProcessor = new UserStateCommandProcessor();

            userStateProcessor.AcquireUserState += user =>
                                                   Dispatcher.Invoke(() => AcquireUserState?.Invoke(user));

            // Attach processors.
            commandProcessors = new Dictionary <string, ITwitchCommandProcessor>();
            commandProcessors.Add("JOIN", joinProcessor);
            commandProcessors.Add("PRIVMSG", messageProcessor);
            commandProcessors.Add("USERSTATE", userStateProcessor);
            commandProcessors.Add("PING", new PingCommandProcessor());
        }
 protected virtual void OnAcquireUserState(TwitchUser user) =>
 AcquireUserState?.Invoke(user);