Ejemplo n.º 1
0
        private void CmdSave_Click(object sender, EventArgs e)
        {
            List <string> lsErrors = new List <string>();

            var creds = new creds();

            HandleEmptyCredentials("Account name", tbAccountName.Text, ref creds.username, ref lsErrors);
            HandleEmptyCredentials("OAuth", tbOauth.Text, ref creds.oauth, ref lsErrors);
            HandleEmptyCredentials("Client ID", tbClientID.Text.ToLower(), ref creds.clientID, ref lsErrors);
            HandleEmptyCredentials("Channel name", tbChannelName.Text.ToLower(), ref creds.channeltomod, ref lsErrors);

            if (lsErrors.Count <= 0)
            {
                File.WriteAllText("creds.json", JsonConvert.SerializeObject(creds, Formatting.Indented));
                DialogResult = DialogResult.OK;
                System.Threading.Thread.Sleep(1000);
                this.Close();
            }
            else
            {
                foreach (string sError in lsErrors)
                {
                    MessageBox.Show(sError);
                }
            }
        }
Ejemplo n.º 2
0
 public DbController(IOptions<creds> optionsAccessor)
 {
     cloudantCreds = optionsAccessor.Options;
 }
Ejemplo n.º 3
0
 public DbController(IOptions <creds> options)
 {
     cloudantCreds = options.Value;
 }
Ejemplo n.º 4
0
        private void frmKruBot_Load(object sender, EventArgs e)
        {
            if (File.Exists("creds.json.old"))
            {
                DialogResult dialogResult = MessageBox.Show("We detected that your credentials were in the middle of being replaced. Recover?", "Recover Credentials?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (File.Exists("creds.json")) // Stops an error when both .old and .json exist (rare case)
                    {
                        File.Delete("creds.json");
                    }
                    File.Move("creds.json.old", "creds.json");
                }
                else
                {
                    File.Delete("creds.json.old");
                }
            }
            if (File.Exists("ChatCurrency.json"))
            {
                currency = JsonConvert.DeserializeObject <Currency>(File.ReadAllText("ChatCurrency.json"));
            }
            else
            {
                currency = new Currency();
                currency.CurrencyName   = "Krutons";
                currency.CurrencySymbol = "K";
                currency.users          = new List <KeyValuePair <string, int> >();
                currency.users.Add(new KeyValuePair <string, int>("PFCKrutonium", 1));
            }

            CefSettings settings = new CefSettings();

            settings.CachePath              = "./browsercache";
            settings.PersistSessionCookies  = true;
            settings.PersistUserPreferences = true;
            settings.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-required");
            Cef.Initialize(settings);

            if (File.Exists("creds.json"))
            {
                cred = JsonConvert.DeserializeObject <creds>(File.ReadAllText("creds.json"));
            }
            else
            {
                frmCredentials frmcreds = new frmCredentials();
                frmcreds.ShowDialog();
                cred = JsonConvert.DeserializeObject <creds>(File.ReadAllText("creds.json"));
            }

            if (File.Exists("quotes.json"))
            {
                try
                {
                    quotes = JsonConvert.DeserializeObject <List <Quote> >(File.ReadAllText("quotes.json"));
                }
                catch (Exception ex)
                {
                    // Could not deserialize quotes file.
                }
            }

            ChannelToMod = cred.channeltomod;
            //Loads our Twitch Credentials from the Json file.
            credentials = new ConnectionCredentials(cred.username, cred.oauth);
            client.Initialize(credentials, ChannelToMod); //Channel were connecting to.
            client.OnConnected       += Client_OnConnected;
            client.OnJoinedChannel   += Client_OnJoinedChannel;
            client.OnMessageReceived += Client_OnMessageReceived;
            client.Connect();
            browser      = new ChromiumWebBrowser("https://www.twitch.tv/popout/" + ChannelToMod + "/chat?popout=");
            browser.Dock = DockStyle.Fill;
            tbMusicVolume.MaximumSize = new System.Drawing.Size(tbMusicVolume.Width, 0);
            BrowserWindow.Controls.Add(browser);
            UpdateViewerList.Enabled = true;
            client.OnDisconnected   += Client_OnDisconnected;
            client.OnReconnected    += Client_OnReconnected;
            browser.AddressChanged  += Browser_AddressChanged;
            //browser. <INJECT JAVASCRIPT ON POPUPS>
            browser.ActivateBrowserOnCreation = true;
            ResetConnection.Enabled           = true;
            var tmpBrowser = new ChromiumWebBrowser(cred.alertsURL);

            tmpBrowser.ActivateBrowserOnCreation = true;
            gbAlerts.Controls.Add(tmpBrowser);
            client.OnDisconnected += Client_OnDisconnected1;

            api.Settings.ClientId    = cred.clientID;
            api.Settings.AccessToken = cred.oauth;
        }