//private readonly Core.API.Twitch.IBroadcasterTokenValidator broadcasterTokenValidator; public IRCOnlyApplication( Core.ICommunication communication, Core.ErrorHandler errorHandler, Core.ApplicationManagement applicationManagement, Core.IRC.IrcClient ircClient, //Core.API.Twitch.IBroadcasterTokenValidator broadcasterTokenValidator, Core.API.Twitch.IBotTokenValidator botTokenValidator) { this.communication = communication; this.errorHandler = errorHandler; this.applicationManagement = applicationManagement; this.ircClient = ircClient; this.botTokenValidator = botTokenValidator; //this.broadcasterTokenValidator = broadcasterTokenValidator; BGC.Debug.ExceptionCallback += errorHandler.LogExternalException; }
public static async Task VerifySetup( Core.Config.IBotConfigContainer botConfigContainer, Core.API.Twitch.HelixHelper helixHelper, Core.API.Twitch.IBotTokenValidator botTokenValidator) { botConfigContainer.SerializeData(); Core.Config.BotConfiguration botConfig = botConfigContainer.BotConfig; //Check Username if (string.IsNullOrEmpty(botConfig.Broadcaster)) { Console.Write("Enter the Broadcaster's Username:\n > "); string inputUserName = Console.ReadLine(); inputUserName = inputUserName.Trim(); if (string.IsNullOrEmpty(inputUserName)) { Console.WriteLine("\n\nError: Empty Broadcaster Username received. Aborting."); Environment.Exit(1); } botConfig.Broadcaster = inputUserName; botConfigContainer.SerializeData(); } //Check Bot if (string.IsNullOrEmpty(botConfig.BotName)) { Console.Write("Enter the Bot's Username:\n > "); string inputUserName = Console.ReadLine(); inputUserName = inputUserName.Trim(); if (string.IsNullOrEmpty(inputUserName)) { Console.WriteLine("\n\nError: Empty Bot Username received. Aborting."); Environment.Exit(1); } botConfig.BotName = inputUserName; botConfigContainer.SerializeData(); } //App Secrets if (string.IsNullOrEmpty(botConfig.TwitchClientId)) { Console.Write("Enter the Twitch Client ID received from https://dev.twitch.tv/console/apps \n > "); string clientID = Console.ReadLine(); clientID = clientID.Trim(); if (string.IsNullOrEmpty(clientID)) { Console.WriteLine("\n\nError: Empty Twitch ClientID received. Aborting."); Environment.Exit(1); } botConfig.TwitchClientId = clientID; botConfigContainer.SerializeData(); } if (string.IsNullOrEmpty(botConfig.TwitchClientSecret)) { Console.Write("Enter the Twitch Client Secret received from https://dev.twitch.tv/console/apps \n > "); string clientSecret = Console.ReadLine(); clientSecret = clientSecret.Trim(); if (string.IsNullOrEmpty(clientSecret)) { Console.WriteLine("\n\nError: Empty Twitch Client Secret received. Aborting."); Environment.Exit(1); } botConfig.TwitchClientSecret = clientSecret; botConfigContainer.SerializeData(); } //Try to connect and validate tokens if (await botTokenValidator.TryToConnect()) { Console.WriteLine("Bot Token successfully validates"); } else { Console.WriteLine("Unable to connect to Twitch"); Console.WriteLine("Please check bot credentials and try again."); Console.WriteLine("Exiting bot configurator now..."); Environment.Exit(1); } //Set broadcasterID if it's not set if (string.IsNullOrEmpty(botConfig.BroadcasterId)) { //Fetch the Broadcaster ID botConfig.BroadcasterId = (await helixHelper.GetUsers(null, new List <string>() { botConfig.Broadcaster })).Data[0].ID; botConfigContainer.SerializeData(); } }