示例#1
0
        private void txtTalkText_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                if (cboTalkAs.Items.Count > 0 && txtTalkText.TextLength > 0)
                {
                    if (cboTalkAs.SelectedItem.ToString() == Bot1.ID)
                    {
                        bool success = Bot1.Say(txtTalkText.Text);
                        if (success)
                        {
                            Convo("You > " + Bot1.ID, Color.DarkGreen, System.Drawing.FontStyle.Bold, false);
                            Convo(": ", System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, false);
                            Convo(txtTalkText.Text, System.Drawing.Color.Black, System.Drawing.FontStyle.Regular, true);
                        }
                    }
                    else if (cboTalkAs.SelectedItem.ToString() == Bot2.ID)
                    {
                        bool success = Bot2.Say(txtTalkText.Text);
                        if (success)
                        {
                            Convo("You > " + Bot2.ID, Color.DarkGreen, System.Drawing.FontStyle.Bold, false);
                            Convo(": ", System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, false);
                            Convo(txtTalkText.Text, System.Drawing.Color.Black, System.Drawing.FontStyle.Regular, true);
                        }
                    }
                    else if (cboTalkAs.SelectedItem.ToString() == "Both")
                    {
                        bool success = false;
                        if (Bot1.PollEvents)
                        {
                            success = Bot1.Say(txtTalkText.Text);
                        }
                        if (Bot2.PollEvents)
                        {
                            success = Bot2.Say(txtTalkText.Text);
                        }
                        if (success)
                        {
                            Convo("You > Both", Color.DarkGreen, System.Drawing.FontStyle.Bold, false);
                            Convo(": ", System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, false);
                            Convo(txtTalkText.Text, System.Drawing.Color.Black, System.Drawing.FontStyle.Regular, true);
                        }
                    }
                }

                txtTalkText.Text = "";
                txtTalkText.Focus();
            }
        }
示例#2
0
        private void HandleEvents(Hashtable events)
        {
            IDictionaryEnumerator en = events.GetEnumerator();

            while (en.MoveNext())
            {
                f.txtDebug.Text          += ID + " > " + "[\"" + en.Key.ToString() + "\", \"" + en.Value.ToString() + "\"]" + Environment.NewLine;
                f.txtDebug.SelectionStart = f.txtDebug.TextLength;
                f.txtDebug.ScrollToCaret();
                switch (en.Key.ToString())
                {
                case "typing":
                    if (otherBot != null && otherBot.PollEvents)
                    {
                        otherBot.Request("{OMEGLEURL}/typing", "id=" + otherBot.ID);
                    }
                    lblBotStatus.Text = ID + " is typing..";
                    break;

                case "stoppedTyping":
                    if (otherBot != null && otherBot.PollEvents)
                    {
                        otherBot.Request("{OMEGLEURL}/stoppedtyping", "id=" + otherBot.ID);
                    }
                    lblBotStatus.Text = ID + " is connected.";
                    break;

                case "waiting":
                    break;

                case "connected":
                    f.Convo("Found a stranger.", System.Drawing.Color.Gray, System.Drawing.FontStyle.Bold, true);
                    lblBotStatus.Text = ID + " is connected.";
                    break;

                case "gotMessage":
                    f.Convo(ID, chatColor, System.Drawing.FontStyle.Bold, false);
                    f.Convo(": ", System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, false);
                    f.Convo(en.Value.ToString(), System.Drawing.Color.Black, System.Drawing.FontStyle.Regular, true);
                    if (otherBot != null && otherBot.PollEvents)
                    {
                        otherBot.Say(en.Value.ToString());
                    }
                    lblBotStatus.Text = ID + " is connected.";
                    break;

                case "strangerDisconnected":
                    PollEvents = false;
                    f.Convo("Bot ", System.Drawing.Color.DarkGray, System.Drawing.FontStyle.Bold, false);
                    f.Convo(ID, System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, false);
                    f.Convo(" has disconnected.", System.Drawing.Color.DarkGray, System.Drawing.FontStyle.Bold, true);
                    f.cboTalkAs.Items.Remove(this.ID);
                    lblBotStatus.Text = ID + " is idle.";
                    break;

                case "recaptchaRequired":
                    PollEvents   = false;
                    challengeKey = en.Value.ToString();
                    this.newReCaptcha();
                    break;

                case "recaptchaRejected":
                    PollEvents = false;
                    f.panelRecaptcha.Visible = true;
                    pbCaptcha.Enabled        = true;
                    txtCaptcha.Enabled       = true;
                    txtCaptcha.Text          = "";
                    txtCaptcha.Focus();
                    System.Windows.Forms.MessageBox.Show("You have incorrectly answered the reCAPTCHA for Bot " + ID + ". Try again.");
                    break;

                default:
                    f.Convo("Server returned ", System.Drawing.Color.DarkGray, System.Drawing.FontStyle.Bold, false);
                    f.Convo("[\"" + en.Key.ToString() + "\", \"" + en.Value.ToString() + "\"]", System.Drawing.Color.Black, System.Drawing.FontStyle.Bold, true);
                    break;
                }
            }
        }