Esempio n. 1
0
 //  Start a new private message
 void Whisper()
 {
     if (!Whispers.Any(x => x.UserName.ToLower() == NewWhisperUserName.ToLower()))
     {
         using (var wc = new TwitchApiClient())
         {
             try
             {
                 var result = Json.Helper.Parse <TwitchUserResult>(wc.DownloadData("https://api.twitch.tv/kraken/users/" + NewWhisperUserName.ToLower()));
                 if (result.name.ToLower() == _irc.User.ToLower())
                 {
                     MessageBox.Show("Unable to message self");
                 }
                 else
                 {
                     Whispers.Add(new Dialog.WhisperWindowViewModel(_irc, NewWhisperUserName));
                 }
             }
             catch
             {
                 MessageBox.Show("User not found");
             }
         }
     }
     NewWhisperUserName = string.Empty;
 }
Esempio n. 2
0
        public TwitchIrcClient()
        {
            //  Get available servers and initialize IrcClient with the first one
            using (var wc = new TwitchApiClient())
            {
                var result = Json.Helper.Parse <TwitchServerResult>(wc.DownloadData("http://tmi.twitch.tv/servers?channel=twitch"));
                var server = result.servers.First().Split(':');

                Server = server[0];
                Port   = int.Parse(server[1]);
            }
        }
Esempio n. 3
0
        //  Login to twitch
        void Login()
        {
            var login = new Dialog.LoginWindow();

            login.ShowDialog();
            var token = login.Token;

            try
            {
                using (var wc = new TwitchApiClient(token))
                {
                    var result = Json.Helper.Parse <TwitchUserResult>(wc.DownloadData("https://api.twitch.tv/kraken/user"));

                    _irc.Login(result.name, "oauth:" + token);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unhandled exception while logging in: {0}", args: ex);
            }
        }