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);
            }
        }
        private void ReceiveMessageHandler(Core.IRC.TwitchChatter chatter)
        {
            switch (chatter.Message.ToUpperInvariant())
            {
            case "F":
                //Press F
                buttonPressDispatcher.TriggerKeyPress(DirectXKeyStrokes.DIK_F, 50);
                break;

            case "GG":
                communication.SendPublicChatMessage($"Shut up, @{chatter.UserName}!");
                break;

            default:
                //Do Nothing
                break;
            }
        }