Exemple #1
0
        //private void GetAuthToken()
        //{
        //    try
        //    {
        //        try
        //        {
        //            p = System.Diagnostics.Process.Start("Chrome.exe", $"--app=https://id.twitch.tv/oauth2/authorize?client_id={Settings.ClientId}&redirect_uri=http://localhost:7425&response_type=code&scope=channel_check_subscription --window-size=600,800");
        //        }
        //        catch
        //        {

        //            p = System.Diagnostics.Process.Start("firefox.exe", $"https://id.twitch.tv/oauth2/authorize?client_id={Settings.ClientId}&redirect_uri=http://localhost:7425&response_type=code&scope=channel_check_subscription");
        //        }
        //    }
        //    catch
        //    {
        //        p = System.Diagnostics.Process.Start("MicrosoftEdge.exe", $"https://id.twitch.tv/oauth2/authorize?client_id={Settings.ClientId}&redirect_uri=http://localhost:7425&response_type=code&scope=channel_check_subscription");
        //    }
        //    p.Exited += (object sender, EventArgs e) =>
        //    {
        //        Thread.CurrentThread.Abort();
        //    };
        //    Task t = new Task(async () =>
        //    {
        //        var prefix = "http://localhost:7425/";
        //        HttpListener listener = new HttpListener();
        //        listener.Prefixes.Add(prefix);
        //        try
        //        {
        //            listener.Start();
        //        }
        //        catch (HttpListenerException hlex)
        //        {
        //        }

        //        while (listener.IsListening && !p.HasExited)
        //        {
        //            try
        //            {

        //                var context = await listener.GetContextAsync();

        //                if (!string.IsNullOrEmpty(context.Request.QueryString["code"]))
        //                {
        //                    Settings.AuthToken = "a38dd5of0jsy47mjve7f1hwinegpy7";
        //                    listener.Close();
        //                    p.Kill();
        //                }
        //                else
        //                {
        //                    listener.Close();
        //                    p.Kill();
        //                }
        //            }
        //            catch
        //            {
        //            }
        //        }
        //    }
        //    );
        //    t.Start();
        //    while(!t.IsCompleted && !p.HasExited)
        //    {

        //    }
        //}

        //public async void RunHttp(Process p)
        //{
        //    var prefix = "http://localhost:7425/";
        //    HttpListener listener = new HttpListener();
        //    listener.Prefixes.Add(prefix);
        //    try
        //    {
        //        listener.Start();
        //    }
        //    catch (HttpListenerException hlex)
        //    {
        //    }

        //    while (listener.IsListening && !p.HasExited)
        //    {
        //        try
        //        {

        //            var context = await listener.GetContextAsync();

        //            if (!string.IsNullOrEmpty(context.Request.QueryString["code"]))
        //            {
        //                Settings.AuthToken = "a38dd5of0jsy47mjve7f1hwinegpy7";
        //                listener.Close();
        //                p.Kill();
        //            }
        //            else
        //            {
        //                listener.Close();
        //                p.Kill();
        //            }
        //        }
        //        catch
        //        {
        //        }
        //    }
        //}

        private void Client_TimedOut(object sender, OnUserTimedoutArgs e)
        {
            window.Dispatcher.Invoke((Action)(() =>
            {
                window.BotStopped();
            }));
        }