Example #1
0
        public async Task RunAsync()
        {
            try
            {
                communication.SendDebugMessage("*** Starting Up ***");
                communication.SendDebugMessage("Connecting to Twitch");

                if (!await botTokenValidator.TryToConnect())
                {
                    communication.SendErrorMessage("------------> URGENT <------------");
                    communication.SendErrorMessage("Please check bot credential process and try again.");
                    communication.SendErrorMessage("Unable to connect to Twitch");
                    communication.SendErrorMessage("Exiting bot application now...");
                    await Task.Delay(7500);

                    Environment.Exit(1);
                }

                //if (!await broadcasterTokenValidator.TryToConnect())
                //{
                //    communication.SendErrorMessage("------------> URGENT <------------");
                //    communication.SendErrorMessage("Please check broadcaster credential process and try again.");
                //    communication.SendErrorMessage("Unable to connect to Twitch");
                //    communication.SendErrorMessage("Exiting bot application now...");
                //    await Task.Delay(7500);
                //    Environment.Exit(1);
                //}


                communication.SendDebugMessage("Connecting to IRC");

                await ircClient.Start();

                //Kick off Validator
                botTokenValidator.RunValidator();
                //broadcasterTokenValidator.RunValidator();

                communication.SendPublicChatMessage("I have connected.");
            }
            catch (Exception ex)
            {
                errorHandler.LogFatalException(ex);
            }

            try
            {
                await applicationManagement.WaitForEndAsync();
            }
            catch (Exception ex)
            {
                errorHandler.LogSystemException(ex);
            }
        }
Example #2
0
        public virtual async void HandleChatMessage(Core.IRC.IRCMessage message)
        {
            if (message.ircCommand != Core.IRC.IRCCommand.PrivMsg && message.ircCommand != Core.IRC.IRCCommand.Whisper)
            {
                communication.SendDebugMessage($"Error: Passing forward non-chat message:\n    {message}");
                return;
            }

            Core.IRC.TwitchChatter chatter = await Core.IRC.TwitchChatter.FromIRCMessage(message);

            if (chatter == null)
            {
                return;
            }

            communication.DispatchChatMessage(chatter);
        }