Пример #1
0
        /// <summary>
        /// Responds to command call
        /// </summary>
        /// <param name="sender">User who sent the command</param>
        /// <param name="message">String command message send by user</param>
        private void RespondToCommand(User sender, string message)
        {
            // TODO: Fix this parsing and make it more efficient
            var command = _commandsHandler.CommandsList.FirstOrDefault(cmd =>
            {
                List <string> parsedMessageCommand = message.Split(' ').ToList();
                string messageCmdName = parsedMessageCommand.FirstOrDefault();
                int commandArgs       = cmd.CommandFormat.Split(' ').Count();

                return(cmd.CommandFormat.Contains(messageCmdName) && parsedMessageCommand.Count == commandArgs);
            });

            if (command != null)
            {
                if (!command.VerifyFormat(message))
                { // Check permission, if user doesn't have permission, don't send anything
                    // FIX: Inform user about wrong command structure?
                    //DeliverCommandResults(command, command.CheckCommandPermissions(sender) ? command.GetAboutInfoMessage() : "", sender);
                    return;
                }

                string commandResult = _commandsHandler.ExecuteCommand(command, sender, Parsing.ParseCommandValues(message));
                OnCommandReceived?.Invoke(this, new OnCommandReceivedArgs {
                    Command = command
                });
                DeliverCommandResults(command, commandResult, sender);
            }
        }
Пример #2
0
 private void TwitchClient_OnMessageReceived(object sender, TwitchLib.Client.Events.OnMessageReceivedArgs e)
 {
     if (e?.ChatMessage?.Message?.StartsWith("!") == true)
     {
         OnCommandReceived?.Invoke(this, e.ChatMessage.Message);
     }
 }
Пример #3
0
 public void Initialize()
 {
     method1.Initialize();
     method2.Initialize();
     method1.OnCommandReceived += (s, e) => OnCommandReceived?.Invoke(s, e);
     method2.OnCommandReceived += (s, e) => OnCommandReceived?.Invoke(s, e);
 }
Пример #4
0
        private static void Main()
        {
            SetupLogger();
            Log.Info("Scheduler started...");

            mapper = CreateMapper();
            AppDomain.CurrentDomain.UnhandledException += HandleException;

            SetupConfig();
            BuildInjectionContainer();

            AttachConsoleCommander();
            //RunTestMethod();

            //TODO: Make it configurable
            jobRunner = new JobRunner(injectionContainer);
            jobRunner.AddJob(nameof(EmailSummaryJob));
            jobRunner.AddJob(nameof(PerformanceAuditJob));
            jobRunner.AddJob(nameof(OtodomFeedJob));
            jobRunner.AddJob(nameof(PriceDetectiveJob));

            jobRunner.RunJobs();

            while (true)
            {
                var command = Console.ReadLine();
                OnCommandReceived?.Invoke(command);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NanomiteClient"/> class.
 /// </summary>
 /// <param name="communicationClient">The communication service wrapping the actual grpc client/&gt;</param>
 /// <param name="clientVersion">The client version.</param>
 public NanomiteClient(CommunicationClient communicationClient, string clientVersion)
 {
     this.communicationClient = communicationClient;
     this.clientVersion       = SemVersion.Parse(clientVersion.ToString());
     this.communicationClient.OnCommandReceived = (package, client) => { OnCommandReceived?.Invoke(package, client); };
     this.communicationClient.OnLog             = (sender, srcId, msg, level) => { OnLog?.Invoke(sender, srcId, msg, level); };
     this.communicationClient.OnConnected       = () => { OnConnected?.Invoke(); };
     this.communicationClient.OnDisconnected    = () => { this.OnDisconnected?.Invoke(this.communicationClient.SrcDeviceId); };
 }
Пример #6
0
 private void TwitchClientOnOnChatCommandReceived(object sender, OnChatCommandReceivedArgs e)
 {
     //switch (e.Command.CommandText)
     //{
     //    case "jello":
     //        SendMessage($"Command received: {e.Command.CommandText}");
     //        break;
     //}
     OnCommandReceived?.Invoke(this, e.ToCommandReceivedEventArgs());
 }
Пример #7
0
        /////////////////////////////////////////////////
        /// Sets up the connection to the azure hub.
        /// Will also subscripe to the UpdateSpecific
        /// topic. Starts the connection and adds an
        /// event that handles if the connection is lost.
        /////////////////////////////////////////////////
        private void SetUpInternal()
        {
            _connection = new HubConnectionBuilder().WithUrl("http://fwps.azurewebsites.net/devices").Build();

            _connection.On <string, string, object>("UpdateSpecific", ((type, target, obj) =>
            {
                OnCommandReceived?.Invoke(this, new SignalREventArgs(obj, target, type));
            }));

            _connection.StartAsync().Wait();

            _connection.Closed += ConnectionOnClosed;
        }
Пример #8
0
        private Task OnClientMessageReceived(SocketMessage arg)
        {
            if (arg == null ||
                OnCommandReceived == null ||
                arg.Author == null)
            {
                return(Task.CompletedTask);
            }

            bool isMention = arg
                             .MentionedUsers
                             .Any(u => u.IsBot && u.Id.Equals(_discordClient.CurrentUser.Id));

            if (!isMention)
            {
                return(Task.CompletedTask);
            }

            SocketGuild guild = _discordClient
                                .Guilds
                                .FirstOrDefault(g => g
                                                .Channels
                                                .Any(c => c.Id.Equals(arg.Channel.Id)));

            bool userIsAdmin =
                !arg.Author.IsBot &&
                !arg.Author.IsWebhook &&
                !string.IsNullOrWhiteSpace(arg.Author.Id.ToString()) &&
                _admins.SingleOrDefault(a => a.Equals(arg.Author.Id.ToString())) != null;

            bool userHasManageGuildPermission = guild
                                                .GetUser(arg.Author.Id)
                                                .GuildPermissions
                                                .ManageGuild;

            if (!userHasManageGuildPermission && !userIsAdmin)
            {
                return(Task.CompletedTask);
            }

            Logger.Debug($"Bot was mentioned by {arg.Author.Username}{arg.Author.Discriminator}: {arg.Content}");

            OnCommandReceived?.Invoke(this, arg);

            return(Task.CompletedTask);
        }
Пример #9
0
        private void Receive()
        {
            try
            {
                while (this.isReceiving)
                {
                    ConnectionNode[] internalnodes;
                    lock (this.nodes)
                    {
                        internalnodes = this.nodes.ToArray();
                    }
                    foreach (var node in internalnodes)
                    {
                        if (node.Peer == null)
                        {
                            continue;
                        }
                        var command = node.Peer.Receive();
                        if (command == null)
                        {
                            continue;
                        }
                        OnCommandReceived?.Invoke(this, command);
                        command.OnReceived(this.selfNode, node);
                        if (!this.isReceiving)
                        {
                            break;
                        }
                    }

                    Thread.Sleep(500);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"unexpected exception in receive: {ex}");
            }
        }
Пример #10
0
        //Download packets
        private void ProcessIncoming()
        {
            //if(!disposed)
            if (m_PacketSocket == null)
            {
                Disponse("[PacketHandler::ProcessIncoming()]");
                return;
            }
            m_recvPackets = m_localSecurity.TransferIncoming();
            if (m_recvPackets != null)
            {
                foreach (var packet in m_recvPackets)
                {
                    PacketToConsole(packet, Process.Incoming);

                    if (packet.Opcode == 0x5000 || packet.Opcode == 0x9000 || packet.Opcode == 0x2002)
                    {
                        continue;
                    }

                    OnCommandReceived?.Invoke(packet);
                }
            }
        }
Пример #11
0
 private void ChatCommandReceived(object sender, OnChatCommandReceivedArgs e)
 {
     OnCommandReceived?.Invoke(this, e.ToCommandReceivedEventArgs());
     OnUserNoticed?.Invoke(this, e.ToUserStatusEventArgs());
 }
Пример #12
0
        /// <summary>
        /// Handle a command received from chat.
        /// This is after filtering to make sure a message is a command.
        /// </summary>
        internal void HandleCommandReceived(SenderSettings senderSettings, IMessageDetail message)
        {
            bool             success;
            IList <Response> responses;

            try
            {
                responses = commandHandlerController.ExecuteCommand(senderSettings, message);
                success   = true;
            }
            catch (Exception ex)
            {
                ErrorLogger.LogException(ex, ErrorSeverity.Error);
                ErrorLogger.LogDebug($"Exception while handling: {message}", false);
                responses = new List <Response>
                {
                    new Response {
                        Message = $"{Emojis.ExclamationSymbol} {languageHandler.GetPhrase(senderSettings.ServerSettings.Language, "Error_Oops")}: {ex.Message}"
                    }
                };
                success = false;
            }

            if (dumpDebug)
            {
                var sb = MiscUtility.DumpObject(message);
                ErrorLogger.LogDebug("Handled " + message.GetType() + ": \r\n" + sb, true);
            }

            if (responses.Count > 0)
            {
                foreach (Response response in responses)
                {
                    OnCommandReceived?.Invoke(this, new CommandReceivedEventArgs(senderSettings, message, response));
                    /// Handled by <see cref="SlateBotController_OnCommandReceived"/>
                    /// and the <see cref="UserSettingsHandler"/>
                    if (dumpDebug)
                    {
                        var sb = MiscUtility.DumpObject(response);
                        ErrorLogger.LogDebug("Response " + response.GetType() + ": \r\n" + sb, true);
                    }
                }

                if ((message is SocketMessageWrapper smw) && (smw.socketMessage is SocketUserMessage sum))
                {
                    // Help out if we're debugging.
                    if (Debugger.IsAttached)
                    {
                        var sb = MiscUtility.DumpObject(sum);
                        ErrorLogger.LogDebug("Handled " + sum.GetType() + ": \r\n" + sb, dumpDebug);
                    }

                    // React to the message handled.
                    sum.AddReactionAsync(new Emoji(success ? Emojis.CheckUnicode : Emojis.CrossSymbol)).ConfigureAwait(false);
                }
            }
            else if (message is ConsoleMessageDetail) // If from the console
            {
                ErrorLogger.LogDebug(NO_RESPONSE_CONSOLE_MESSAGE + "(" + message.Message + ")", true);
            }
        }
Пример #13
0
 private void Server_MessageReceived(Client c, string message)
 {
     OnCommandReceived?.Invoke(this, new CommandEventArgs(message));
 }
Пример #14
0
        /// <summary>
        /// This function allows for testing parsing in OnReadLine via call.
        /// </summary>
        public void testOnReadLine(string decodedMessage)
        {
            if (_logging)
            {
                Console.WriteLine(decodedMessage);
            }
            if (decodedMessage.Split(':').Length > 2)
            {
                if (decodedMessage.Split(':')[2] == "You are in a maze of twisty passages, all alike.")
                {
                    _connected = true;
                    OnConnected?.Invoke(null, new OnConnectedArgs {
                        Channel = _channel, Username = TwitchUsername
                    });
                }
            }
            if (decodedMessage.Contains($"#{_channel}"))
            {
                var splitter = Regex.Split(decodedMessage, $" #{_channel}");
                var readType = splitter[0].Split(' ')[splitter[0].Split(' ').Length - 1];
                switch (readType)
                {
                case "PRIVMSG":
                    if (decodedMessage.Split('!')[0] == ":twitchnotify" &&
                        (decodedMessage.Contains("just subscribed!")))
                    {
                        var subscriber = new NewSubscriber(decodedMessage);
                        OnNewSubscriber?.Invoke(null,
                                                new OnNewSubscriberArgs {
                            Subscriber = subscriber, Channel = _channel
                        });
                    }
                    else
                    {
                        var chatMessage = new ChatMessage(decodedMessage);
                        _previousMessage = chatMessage;
                        OnMessageReceived?.Invoke(null, new OnMessageReceivedArgs {
                            ChatMessage = chatMessage
                        });
                        if (_commandIdentifier != '\0' && chatMessage.Message[0] == _commandIdentifier)
                        {
                            string command;
                            var    argumentsAsString = "";
                            var    argumentsAsList   = new List <string>();
                            if (chatMessage.Message.Contains(" "))
                            {
                                command = chatMessage.Message.Split(' ')[0].Substring(1,
                                                                                      chatMessage.Message.Split(' ')[0].Length - 1);
                                argumentsAsList.AddRange(
                                    chatMessage.Message.Split(' ').Where(arg => arg != _commandIdentifier + command));
                                argumentsAsString =
                                    chatMessage.Message.Replace(chatMessage.Message.Split(' ')[0] + " ", "");
                            }
                            else
                            {
                                command = chatMessage.Message.Substring(1, chatMessage.Message.Length - 1);
                            }
                            OnCommandReceived?.Invoke(null,
                                                      new OnCommandReceivedArgs
                            {
                                Command           = command,
                                ChatMessage       = chatMessage,
                                Channel           = _channel,
                                ArgumentsAsList   = argumentsAsList,
                                ArgumentsAsString = argumentsAsString
                            });
                        }
                    }
                    break;

                case "JOIN":
                    //:the_kraken_bot!the_kraken_bot@the_kraken_bot.tmi.twitch.tv JOIN #swiftyspiffy
                    OnViewerJoined?.Invoke(null,
                                           new OnViewerJoinedArgs {
                        Username = decodedMessage.Split('!')[1].Split('@')[0], Channel = _channel
                    });
                    break;

                case "MODE":
                    //:jtv MODE #swiftyspiffy +o swiftyspiffy
                    if (decodedMessage.Split(' ').Length == 4)
                    {
                        OnModeratorJoined?.Invoke(null,
                                                  new OnModeratorJoinedArgs {
                            Username = decodedMessage.Split(' ')[4], Channel = _channel
                        });
                    }
                    else
                    {
                        if (_logging)
                        {
                            Console.WriteLine("FAILED PARSE: " + decodedMessage);
                        }
                    }
                    break;

                case "NOTICE":
                    if (decodedMessage.Contains("Error logging in"))
                    {
                        _client.Disconnect();
                        OnIncorrectLogin?.Invoke(null,
                                                 new OnIncorrectLoginArgs
                        {
                            Exception =
                                new ErrorLoggingInException(decodedMessage, _credentials.TwitchUsername)
                        });
                    }
                    if (decodedMessage.Contains("has gone offline"))
                    {
                        OnHostLeft?.Invoke(null, null);
                    }
                    break;

                case "ROOMSTATE":
                    _state = new ChannelState(decodedMessage);
                    OnChannelStateChanged?.Invoke(null, new OnChannelStateChangedArgs {
                        ChannelState = _state
                    });
                    break;

                case "USERSTATE":
                    //@color=#8A2BE2;display-name=The_Kraken_Bot;emote-sets=0,5628;subscriber=0;turbo=0;user-type=mod :tmi.twitch.tv USERSTATE #swiftyspiffy
                    var userState = new UserState(decodedMessage);
                    OnUserStateChanged?.Invoke(null, new OnUserStateChangedArgs {
                        UserState = userState
                    });
                    break;

                case "USERNOTICE":
                    //@badges=subscriber/1,turbo/1;color=#2B119C;display-name=JustFunkIt;emotes=;login=justfunkit;mod=0;msg-id=resub;msg-param-months=2;room-id=44338537;subscriber=1;system-msg=JustFunkIt\ssubscribed\sfor\s2\smonths\sin\sa\srow!;turbo=1;user-id=26526370;user-type= :tmi.twitch.tv USERNOTICE #burkeblack :AVAST YEE SCURVY DOG
                    switch (decodedMessage.Split(';')[6].Split('=')[1])
                    {
                    case "resub":
                        var resubObj = new ReSubscriber(decodedMessage);
                        OnReSubscriber?.Invoke(null, new OnReSubscriberArgs {
                            ReSubscriber = resubObj
                        });
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    if (_logging)
                    {
                        Console.WriteLine("Unaccounted for: {0}", decodedMessage);
                    }
                    break;
                }
            }
            else
            {
                //Special cases
                if (decodedMessage == ":tmi.twitch.tv NOTICE * :Error logging in")
                {
                    _client.Disconnect();
                    OnIncorrectLogin?.Invoke(null,
                                             new OnIncorrectLoginArgs
                    {
                        Exception = new ErrorLoggingInException(decodedMessage, _credentials.TwitchUsername)
                    });
                }
                else
                {
                    if (_logging)
                    {
                        Console.WriteLine("Not registered: " + decodedMessage);
                    }
                }
            }
        }
Пример #15
0
 private void CommandReceived(string command)
 {
     OnCommandReceived?.Invoke(command);
 }
Пример #16
0
 private void ChatCommandReceived(object sender, OnChatCommandReceivedArgs e)
 {
     OnCommandReceived?.Invoke(this, e.ToCommandReceivedEventArgs());
 }
Пример #17
0
 private void OnReadLine(object sender, ReadLineEventArgs e)
 {
     if (_logging)
     {
         Console.WriteLine(e.Line);
     }
     if (e.Line.Split(':').Length > 2)
     {
         if (e.Line.Split(':')[2] == "You are in a maze of twisty passages, all alike.")
         {
             _connected = true;
             OnConnected?.Invoke(null, new OnConnectedArgs {
                 Username = TwitchUsername
             });
         }
     }
     if (e.Line.Split(' ').Length > 3 && e.Line.Split(' ')[2] == "WHISPER")
     {
         var whisperMessage = new WhisperMessage(e.Line, _credentials.TwitchUsername);
         _previousWhisper = whisperMessage;
         OnWhisperReceived?.Invoke(null, new OnWhisperReceivedArgs {
             WhisperMessage = whisperMessage
         });
         if (_commandIdentifier == '\0' || whisperMessage.Message[0] != _commandIdentifier)
         {
             return;
         }
         string command;
         var    argumentsAsString = "";
         var    argumentsAsList   = new List <string>();
         if (whisperMessage.Message.Contains(" "))
         {
             command = whisperMessage.Message.Split(' ')[0].Substring(1,
                                                                      whisperMessage.Message.Split(' ')[0].Length - 1);
             argumentsAsList.AddRange(
                 whisperMessage.Message.Split(' ').Where(arg => arg != _commandIdentifier + command));
             argumentsAsString = whisperMessage.Message.Replace(whisperMessage.Message.Split(' ')[0] + " ", "");
         }
         else
         {
             command = whisperMessage.Message.Substring(1, whisperMessage.Message.Length - 1);
         }
         OnCommandReceived?.Invoke(null,
                                   new OnCommandReceivedArgs
         {
             Command           = command,
             Username          = whisperMessage.Username,
             ArgumentsAsList   = argumentsAsList,
             ArgumentsAsString = argumentsAsString
         });
     }
     else
     {
         //Special cases
         if (e.Line == ":tmi.twitch.tv NOTICE * :Error logging in")
         {
             _client.Disconnect();
             OnIncorrectLogin?.Invoke(null,
                                      new OnIncorrectLoginArgs
             {
                 Exception = new ErrorLoggingInException(e.Line, _credentials.TwitchUsername)
             });
         }
         else
         {
             if (_logging)
             {
                 Console.WriteLine("Not registered: " + e.Line);
             }
         }
     }
 }
Пример #18
0
 private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     OnCommandReceived?.Invoke(this, new CommandEventArgs(Port.ReadExisting()));
 }
Пример #19
0
        public static async void StartService()
        {
            try
            {
                if (isRunning)
                {
                    // If the service is already running, exits.
                    return;
                }

                isRunning = true;

                var isConnected = false;
                while (!isConnected)
                {
                    // Be sure to be connected to the Internet.
                    var profile = NetworkInformation.GetInternetConnectionProfile();
                    isConnected = profile?.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
                    await Task.Delay(200);
                }

                if (Settings.Instance == null)
                {
                    await LoadSettingsAsync();
                }

                if (directLineClient == null)
                {
                    // Obtain a token using the Direct Line secret
                    var tokenResponse = await new DirectLineClient(Settings.Instance.DirectLineSecret).Tokens.GenerateTokenForNewConversationAsync();

                    // Use token to create conversation
                    directLineClient = new DirectLineClient(tokenResponse.Token);
                    conversation     = await directLineClient.Conversations.StartConversationAsync();

                    // Connect using a WebSocket.
                    webSocketClient = new MessageWebSocket();
                    webSocketClient.MessageReceived += WebSocketClient_MessageReceived;
                    await webSocketClient.ConnectAsync(new Uri(conversation.StreamUrl));
                }

                if (assistantInvokerSpeechRecognizer == null)
                {
                    // Create an instance of SpeechRecognizer.
                    assistantInvokerSpeechRecognizer = new SpeechRecognizer(new Language(Settings.Instance.Culture));
                    assistantInvokerSpeechRecognizer.Timeouts.InitialSilenceTimeout = TimeSpan.MaxValue;
                    assistantInvokerSpeechRecognizer.Timeouts.BabbleTimeout         = TimeSpan.MaxValue;

                    // Add a list constraint to the recognizer.
                    var listConstraint = new SpeechRecognitionListConstraint(new string[] { Settings.Instance.AssistantName }, "assistant");
                    assistantInvokerSpeechRecognizer.Constraints.Add(listConstraint);
                    await assistantInvokerSpeechRecognizer.CompileConstraintsAsync();
                }

                if (commandSpeechRecognizer == null)
                {
                    commandSpeechRecognizer = new SpeechRecognizer(new Language(Settings.Instance.Culture));

                    // Apply the dictation topic constraint to optimize for dictated freeform speech.
                    var dictationConstraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "dictation");
                    commandSpeechRecognizer.Constraints.Add(dictationConstraint);
                    await commandSpeechRecognizer.CompileConstraintsAsync();
                }

                // The assistant is ready to receive input.
                SoundPlayer.Instance.Play(Sounds.SpeechActive);

                while (isRunning)
                {
                    try
                    {
                        var assistantInvocationResult = await assistantInvokerSpeechRecognizer.RecognizeAsync();

                        if (assistantInvocationResult.Status == SpeechRecognitionResultStatus.Success && assistantInvocationResult.Confidence != SpeechRecognitionConfidence.Rejected)
                        {
                            OnStartRecognition?.Invoke(null, EventArgs.Empty);
                            SoundPlayer.Instance.Play(Sounds.Ready);

                            // Starts command recognition. It returns when the first utterance has been recognized.
                            var commandResult = await commandSpeechRecognizer.RecognizeAsync();

                            if (commandResult.Status == SpeechRecognitionResultStatus.Success && commandResult.Confidence != SpeechRecognitionConfidence.Rejected)
                            {
                                var command = commandResult.NormalizeText();
                                Debug.WriteLine(command);

                                OnCommandReceived?.Invoke(null, EventArgs.Empty);

                                // Sends the activity to the Bot. The answer will be received in the WebSocket received event handler.
                                var userMessage = new Activity
                                {
                                    From = new ChannelAccount(Settings.Instance.UserName),
                                    Text = command,
                                    Type = ActivityTypes.Message
                                };

                                await directLineClient.Conversations.PostActivityAsync(conversation.ConversationId, userMessage);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        OnResponseReceived?.Invoke(null, new BotEventArgs(ex.Message));
                    }
                }

                // Clean up used resources.
                SoundPlayer.Instance.Play(Sounds.SpeechStopped);
            }
            catch (Exception ex)
            {
                OnResponseReceived?.Invoke(null, new BotEventArgs(ex.Message));
                SoundPlayer.Instance.Play(Sounds.SpeechStopped);
            }

            assistantInvokerSpeechRecognizer?.Dispose();
            commandSpeechRecognizer?.Dispose();
            webSocketClient?.Dispose();
            directLineClient?.Dispose();

            assistantInvokerSpeechRecognizer = null;
            commandSpeechRecognizer          = null;
            webSocketClient  = null;
            conversation     = null;
            directLineClient = null;

            isRunning = false;
        }
Пример #20
0
 private void RaiseOnCommand(ITFtpCommand command, IPEndPoint endpoint)
 {
     OnCommandReceived?.Invoke(command, endpoint);
 }
Пример #21
0
        private void OnReadLine(object sender, ReadLineEventArgs e)
        {
            if (_logging)
            {
                Console.WriteLine(e.Line);
            }
            if (e.Line.Split(':').Length > 2)
            {
                if (e.Line.Split(':')[2] == "You are in a maze of twisty passages, all alike.")
                {
                    _connected = true;
                    OnConnected?.Invoke(null, new OnConnectedArgs {
                        Channel = _channel, Username = TwitchUsername
                    });
                }
            }
            if (e.Line.Contains($"#{_channel}"))
            {
                var splitter = Regex.Split(e.Line, $" #{_channel}");
                var readType = splitter[0].Split(' ')[splitter[0].Split(' ').Length - 1];
                switch (readType)
                {
                case "PRIVMSG":
                    if (e.Line.Split('!')[0] == ":twitchnotify" &&
                        (e.Line.Contains("just subscribed!") || e.Line.Contains("subscribed for")))
                    {
                        var subscriber = new Subscriber(e.Line);
                        OnSubscriber?.Invoke(null,
                                             new OnSubscriberArgs {
                            Subscriber = subscriber, Channel = _channel
                        });
                    }
                    else
                    {
                        var chatMessage = new ChatMessage(e.Line);
                        _previousMessage = chatMessage;
                        OnMessageReceived?.Invoke(null, new OnMessageReceivedArgs {
                            ChatMessage = chatMessage
                        });
                        if (_commandIdentifier != '\0' && chatMessage.Message[0] == _commandIdentifier)
                        {
                            string command;
                            var    argumentsAsString = "";
                            var    argumentsAsList   = new List <string>();
                            if (chatMessage.Message.Contains(" "))
                            {
                                command = chatMessage.Message.Split(' ')[0].Substring(1,
                                                                                      chatMessage.Message.Split(' ')[0].Length - 1);
                                argumentsAsList.AddRange(
                                    chatMessage.Message.Split(' ').Where(arg => arg != _commandIdentifier + command));
                                argumentsAsString =
                                    chatMessage.Message.Replace(chatMessage.Message.Split(' ')[0] + " ", "");
                            }
                            else
                            {
                                command = chatMessage.Message.Substring(1, chatMessage.Message.Length - 1);
                            }
                            OnCommandReceived?.Invoke(null,
                                                      new OnCommandReceivedArgs
                            {
                                Command           = command,
                                ChatMessage       = chatMessage,
                                Channel           = _channel,
                                ArgumentsAsList   = argumentsAsList,
                                ArgumentsAsString = argumentsAsString
                            });
                        }
                    }
                    break;

                case "JOIN":
                    //:the_kraken_bot!the_kraken_bot@the_kraken_bot.tmi.twitch.tv JOIN #swiftyspiffy
                    OnViewerJoined?.Invoke(null,
                                           new OnViewerJoinedArgs {
                        Username = e.Line.Split('!')[1].Split('@')[0], Channel = _channel
                    });
                    break;

                case "MODE":
                    //:jtv MODE #swiftyspiffy +o swiftyspiffy
                    if (e.Line.Split(' ').Length == 4)
                    {
                        OnModeratorJoined?.Invoke(null,
                                                  new OnModeratorJoinedArgs {
                            Username = e.Line.Split(' ')[4], Channel = _channel
                        });
                    }
                    else
                    {
                        if (_logging)
                        {
                            Console.WriteLine("FAILED PARSE: " + e.Line);
                        }
                    }
                    break;

                case "NOTICE":
                    if (e.Line.Contains("Error logging in"))
                    {
                        _client.Disconnect();
                        OnIncorrectLogin?.Invoke(null,
                                                 new OnIncorrectLoginArgs
                        {
                            Exception =
                                new ErrorLoggingInException(e.Line, _credentials.TwitchUsername)
                        });
                    }
                    if (e.Line.Contains("has gone offline"))
                    {
                        OnHostLeft?.Invoke(null, null);
                    }
                    break;

                case "ROOMSTATE":
                    _state = new ChannelState(e.Line);
                    OnChannelStateChanged?.Invoke(null, new OnChannelStateChangedArgs {
                        ChannelState = _state
                    });
                    break;

                case "USERSTATE":
                    //@color=#8A2BE2;display-name=The_Kraken_Bot;emote-sets=0,5628;subscriber=0;turbo=0;user-type=mod :tmi.twitch.tv USERSTATE #swiftyspiffy
                    var userState = new UserState(e.Line);
                    OnUserStateChanged?.Invoke(null, new OnUserStateChangedArgs {
                        UserState = userState
                    });
                    break;

                default:
                    if (_logging)
                    {
                        Console.WriteLine("Unaccounted for: {0}", e.Line);
                    }
                    break;
                }
            }
            else
            {
                //Special cases
                if (e.Line == ":tmi.twitch.tv NOTICE * :Error logging in")
                {
                    _client.Disconnect();
                    OnIncorrectLogin?.Invoke(null,
                                             new OnIncorrectLoginArgs
                    {
                        Exception = new ErrorLoggingInException(e.Line, _credentials.TwitchUsername)
                    });
                }
                else
                {
                    if (_logging)
                    {
                        Console.WriteLine("Not registered: " + e.Line);
                    }
                }
            }
        }