示例#1
0
        public TwitchAPI()
        {
            _subscribers = new List<string>();
            connected = false;

            try
            {
                //TYPE THIS INTO BROWSER TO RECEIVE OAUTH FOR BOT + USER
                //string uri = "https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=fjhkjex3dosfwql6jcne4klacgixv80&redirect_uri=http://dram55.com/bot&scope=user_read+channel_subscriptions+channel_check_subscription";
                twitchClient = new TwitchAuthenticatedClient(BotSettings.BotOAuth, BotSettings.BotClientID);
                connected = true;
            }
            catch (Exception)
            {
                Console.WriteLine("WARNING: Unable to retrieve subs list. Invalid BotOAuth in Settings.");
                Console.WriteLine("Update settings and restart bot if you'd like to connect to the API. ");
                Console.WriteLine();
            }
        }
        public bool Login(string authkey)
        {
            var tempClient = new TwitchAuthenticatedClient(authkey, Globals.ClientId);
            var user = tempClient.GetMyUser();

            if (user == null || IsNullOrWhiteSpace(user.Name))
            {
                return false;
            }
            Globals.Client = tempClient;

            Globals.Status.Username = user.Name;
            Globals.Status.Displayname = user.DisplayName;

            Globals.Config.AuthKey = authkey;
            Globals.Config.Save();
            return true;
        }
示例#3
0
        private static void TwitchConnect()
        {
            string oAuthKey = iniFile.Section("Twitch").Get("OAuthKey");
            string clientID = iniFile.Section("Twitch").Get("ClientID");

            try
            {
                var tempClient = new TwitchAuthenticatedClient(oAuthKey, clientID);
                string username = tempClient.GetMyChannel().Name;
                client = new TwitchNamedClient(username, oAuthKey, clientID);

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


        }