private void Postchecker_DoWork(object sender, DoWorkEventArgs e) { // change any link to a mobile link string url = Post.Text; string reg = @"facebook.+"; Regex re = new Regex(reg); var res = re.Match(url); url = "https://m." + res.Value; // store the new link in the textbox to use as public variable Post.Invoke((MethodInvoker) delegate { Post.Text = url; }); driver.Navigate().GoToUrl(Post.Text); try { //comment place var na = driver.FindElement(By.TagName("input")); // enable the next options if (na != null) { PostError.Invoke((MethodInvoker) delegate { PostError.Visible = false; }); Post.Invoke((MethodInvoker) delegate { Post.Enabled = false; }); TestPost.Invoke((MethodInvoker) delegate { TestPost.Enabled = false; }); Comments.Invoke((MethodInvoker) delegate { Comments.Enabled = true; }); RandomTime.Invoke((MethodInvoker) delegate { RandomTime.Enabled = true; }); Generate.Invoke((MethodInvoker) delegate { Generate.Enabled = true; }); NoComments.Invoke((MethodInvoker) delegate { NoComments.Enabled = true; }); } else { PostError.Invoke((MethodInvoker) delegate { PostError.Visible = true; }); } } catch (Exception ex) { PostError.Invoke((MethodInvoker) delegate { PostError.Visible = true; PostError.Text = ex.Message; }); } }
private static string AddConversationalResponseTag(string ResponseText, string QueryText) { const string NoComments = "I am sorry, I do not have a comment at this moment. Can you try again?"; Random i = new Random(DateTime.Now.Millisecond); int j = i.Next(10); while (User.CurrentContext.PreviousRandomNumber == j) { j = i.Next(10); // make sure dont show the same inspiration or relaxing info twice } string PrefixText = ""; string peotryText = ""; string reg = QueryText.ToLower(); if (User.SameQuestionCount > 2 && User.SameQuestionCount < 6 && User.CurrentContext.LastQueryText.ToLower() == reg) { if (j == 1) { PrefixText = "I believe you are repeating yourself. But, you are an important customer.<br/>"; } if (j == 2) { PrefixText = "I have to remind you that you have asked me the same question for more then 2 times.<br/>"; } if (j == 3) { PrefixText = "Maybe repeition is good for retention.<br/>"; } if (j == 4) { PrefixText = "Wow, you are persistent.<br/>"; } if (j == 5) { PrefixText = "Ok, I get you you need more information? This is what I have got for now.<br/>"; } if (j == 6) { PrefixText = "My nice fellow, I think we need to be more productive than this.<br/>"; } if (j == 7) { PrefixText = "Are you testing my answers? I have only so much information for now.<br/>"; } if (j > 7) { PrefixText = "Never say die. You ask for it again.<br/>"; } } if (User.SameQuestionCount > 3 && User.CurrentContext.LastQueryText.ToLower() == reg) { string shadow = "style='-webkit-box-shadow: 0 3px 8px 0 #C15E3F;box-shadow: 0 3px 8px 0 #C15E3F;'"; PrefixText = GetRepeatPrefixText(); if (j == 1) { PrefixText += "For a change let me share with you a nice peotry.<br/><br/>"; peotryText = PrefixText + "<div><img " + shadow + " src='http://lanalp.org/wp-content/uploads/2017/12/Embrace-innovation-and-Empower.jpg' class='img-fluid z-depth-3 rounded' width='70%' border=0></p>To believe is to know that every day is a new beginning. <br/>Is to trust that miracles happen, and dreams really do come true.<br/>To believe is to see angels dancing among the clouds,<br/>To know the wonder of a stardust sky and the wisdom of the man in the moon.<br/>To believe is to know the value of a nurturing heart,<br/>The innocence of a child's eyes and the beauty of an aging hand,<br/>for it is through their teachings we learn to love."; } if (j == 2) { PrefixText += "Maybe you need to chill. Read this:<br/<br/>"; peotryText = PrefixText + "<p><img " + shadow + "src='https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/inspirational-quotes-ella-fitzgerald-1546446479.jpg?crop=1xw:1xh;center,top&resize=480:*' class='img-fluid z-depth-3 rounded' width='70%' border=0></p><br/>I like the inspiring thoughts it invokes!"; } if (j == 3) { PrefixText += "Are you tired? May be some exercise will help:<br/><br/>"; peotryText = PrefixText + "<p><img " + shadow + "src='https://makeyourbodywork.com/wp-content/uploads/sites/41/2013/12/100percent.png' class='img-fluid z-depth-3 rounded' width='65%' border=0></p><br/>The baby is hilarious!!! Agree right?"; } if (j == 4) { PrefixText += "You are making me hungry repeating myself:<br/><br/>"; peotryText = PrefixText + "<p><img " + shadow + "src='https://education.cu-portland.edu/wp-content/uploads/sites/33/2018/05/teaching-hungry-students.jpg' class='img-fluid z-depth-3 rounded' width='70%' border=0></p><br/>Hunger pangs are hard to deal with. Please spare me a thought. Just kidding..."; } if (j == 5) { PrefixText += "Maybe something to cheer you up:<br/><br/>"; peotryText = PrefixText + "<p><embed " + shadow + " height='400'width='100%' src='https://www.youtube.com/v/tgbNymZ7vqY'></p><br/>Animals are funny somettimes or maybe its puppets are funny."; } if (j == 6) { PrefixText += "Relax and enjoy a beautiful piece 'The Lonely Shepherd':<br/><br/>"; peotryText = PrefixText + "<p><iframe " + shadow + " height='400'width='100%' src='https://www.youtube.com/embed/h5p8TO2wIZU' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe></p><br/>"; } if (j == 7) { PrefixText += "Right. Here is a brief view of the history of ISS NUS for a change:<br/><br/>"; peotryText = PrefixText + "<p><embed " + shadow + " height='400'width='100%' src='https://www.youtube.com/embed/6GjgwbcGZ4A'></p><br/>"; } if (j == 8) { PrefixText += "Let's have a break and look at a great video introduction on ISS and its programme:<br/><br/>"; peotryText = PrefixText + "<p><embed " + shadow + " height='400'width='100%' src='https://www.youtube.com/embed/YCJk3PUNRB0'></p><br/>"; } if (j == 9) { PrefixText += "An inspriation to think about!:<br/><br/>"; peotryText = PrefixText + "<p><img " + shadow + "src='https://brightdrops.com/wp-content/uploads/2016/10/michelangelo-if-people.jpg' class='img-fluid z-depth-3 rounded' width='70%' border=0></p><br/>Hard work and persistent to reach the top is what counts!"; } if (j == 10) { PrefixText += "A straight forward answer!:<br/><br/>"; peotryText = PrefixText + "<p><img " + shadow + "src='https://cdn2.geckoandfly.com/wp-content/uploads/2014/02/bruce-lee-kung-fu-quotes-22.jpg' class='img-fluid z-depth-3 rounded' width='70%' border=0></p><br/>You have to just do it sometimes!"; } User.CurrentContext.PreviousRandomNumber = j; User.Store(); if (peotryText != "") { return(peotryText); } } bool IsNoComment = (ResponseText.ToLower() == NoComments.ToLower()); bool IsQuestion = reg.Contains("?"); bool L1 = (reg.Contains("are available") && IsQuestion) || reg.Contains("do you have") || reg.Contains("does iss have") || (reg.Contains("is available") && IsQuestion) || reg.Contains("does iss provide") || reg.Contains("does iss offer") || reg.Contains("does iss nus offer") || reg.Contains("does iss nus provide"); if (L1 && IsNoComment == false && j < 3) { return(PrefixText + "Yes, we have. " + ResponseText); } if (L1 && IsNoComment == false && j >= 7) { return(PrefixText + "Sure, we have that. " + ResponseText); } if (L1 && IsNoComment == false && j >= 3 && j < 7) { return(PrefixText + "I am happy to say we have got it! " + ResponseText); } L1 = reg.Contains("tell me") || reg.Contains("explain more") || (reg.Contains("eloborate to me") && IsQuestion) || reg.Contains("can you epxlain"); if (L1 && IsNoComment == false && j < 3) { return(PrefixText + "Sure, glad to share. " + ResponseText); } if (L1 && IsNoComment == false && j >= 7) { return(PrefixText + "Ok, here you go.. " + ResponseText); } if (L1 && IsNoComment == false && j > 3 && j < 7) { return(PrefixText + "No problem, what we have. " + ResponseText); } return(ResponseText); }