Exemple #1
0
 private static void omegle_MessageReceived(object sender, MessageReceivedArgs e)
 {
     Console.WriteLine("Message received: " + e.message + "\n");
     Console.Write(">");
     string answer = Console.ReadLine();
     omegle.SendMessage(answer);
 }
Exemple #2
0
 public static void omegle_MessageReceived(object sender, MessageReceivedArgs e)
 {
     DateTime temporaryNow = DateTime.Now;
     string time = string.Format("{0}:{1}:{2} ", temporaryNow.Hour, temporaryNow.Minute, temporaryNow.Second);
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     if (e.message != string.Empty)
     {
         Console.WriteLine("Stranger: " + e.message);
         Log(time + "Stranger: " + e.message);
     }
     Console.ForegroundColor = ConsoleColor.DarkCyan;
     omegle.StartTyping();
     string response = bot.Think(e.message).Replace("Cleverbot", "Jasmin"); //MWAHAHAHA
     omegle.StopTyping();
     omegle.SendMessageRaw(response); //Already URI encoded
     Console.WriteLine("Cleverbot: " + response);
     Log(time + "Cleverbot: " + response);
     Console.ForegroundColor = ConsoleColor.Gray;
 }
Exemple #3
0
        /// <summary>
        /// Handles the MessageReceived event of the omegle class.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void omegle_MessageReceived(object sender, MessageReceivedArgs e)
        {
            SetStatus("");
            if (e.message != null && e.message.Trim().Length > 0)
            {
                WriteMessage("Stranger", e.message.Trim(), Color.SaddleBrown);
            }

            if (botEnabledToolStripMenuItem.Checked)
            {
                string botName = currentbotToolStripButton.Text;
                string answer = String.Empty; int retries = 4;

                SetStatus(botName + " is thinking...", true);

                DateTime thinkingStart = DateTime.Now;

                try
                {
                    while ((answer = session.Think(e.message).Trim()).Length == 0 && retries-- > 0)
                    {
                        WriteText("Error getting " + botName + "'s response, retrying.", Color.Red);
                    }
                }
                catch (Exception ex)
                {
                    WriteText("Exception while getting " + botName + "'s response: " + ex.ToString(), Color.Red);
                }

                TimeSpan thinkingTime = DateTime.Now.Subtract(thinkingStart);

                if (answer.Length > 0)
                {
                    answer = HttpUtility.HtmlDecode(answer).Replace("  ", " ");

                    SetStatus(botName + " is typing...", false);

                    omegle.StartTyping();

                    //  Good Typist (90 wpm) --- 0.12 seconds
                    double durationMs = TimeSpan.FromSeconds(answer.Length * 0.12)
                        .Subtract(thinkingTime).TotalMilliseconds;

                    if (durationMs > 0)
                        System.Threading.Thread.Sleep((int)durationMs);

                    omegle.StopTyping();

                    SetStatus(botName + " stopped typing...");
                    if (botEnabledToolStripMenuItem.Checked) // Double check
                    {
                        omegle.SendMessageRaw(answer);
                        WriteMessage(botName, answer, Color.Teal);
                    }

                    SetStatus("");
                }
                else
                    SetStatus("Could not get " + botName + "'s response.", false);
            }
        }
Exemple #4
0
 //When Stranger 2 sends a message, send it to stranger 1
 private void Stranger2_MessageReceived(object sender, MessageReceivedArgs e)
 {
     ChatBrowser.PrintMessage("Stranger 2", e.message, System.Drawing.Color.Red);
     if (Stranger1.IsConnected)
         Stranger1.SendMessage(e.message);
     else
     {
         stranger1backlog.Enqueue(e.message);
     }
 }
Exemple #5
0
        /// <summary>
        /// Handles the MessageReceived event of the omegle class.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void omegle_MessageReceived(object sender, MessageReceivedArgs e)
        {
            SetStatus("");
            if (e.message != null && e.message.Trim().Length > 0)
            {
                WriteMessage("Stranger", e.message.Trim(), Color.SaddleBrown);
            }

            if (botEnabledToolStripMenuItem.Checked)
            {
                string botName = currentbotToolStripButton.Text;

                omegle.StartTyping();
                string answer; int retries = 4;

                while ((answer = session.Think(e.message).Trim()).Length == 0 && retries-- > 0)
                {
                    WriteText("Error getting " + botName + "'s response, retrying.", Color.Red);
                }

                if (answer.Length > 0)
                {
                    answer = HttpUtility.HtmlDecode(answer);
                    omegle.StopTyping();
                    if (botEnabledToolStripMenuItem.Checked) // Double check
                    {
                        omegle.SendMessageRaw(answer);
                        WriteMessage(botName, answer, Color.Teal);
                    }
                }
                else
                    WriteText("Could not get " + botName + "'s response.", Color.Red);
            }
        }
Exemple #6
0
 private static void omegle_MessageReceived(object sender, MessageReceivedArgs e)
 {
     Console.WriteLine("Stranger: " + e.message); //we received a message, lets echo it back
     OmegleObj.SendMessage(e.message + " to you too, buddy.");
     Console.WriteLine("You: " + e.message + " to you too, buddy.");
 }