Как отправить ответ, если пользователь неактивен с моим окном чата (означает, что пользователь не предоставлял никакого запроса окну чата) - PullRequest
0 голосов
/ 04 июля 2019

Я работаю в плагине chatbot, где я должен добавить настройку, чтобы, когда пользователь какое-то время не обращался к боту, бот должен дать ответ типа «Ты здесь?» обнаруживая неактивное состояние пользователя.

  jQuery(document).ready(function() {
  var idleTime = 0;
  var idleInterval = setInterval(textResponse, 60000);
  $(".myc-content-overlay .myc-content-overlay-on").mousemove(function(e) 
  {
    idleTime = 0;
   });
  $(".myc-content-overlay .myc-content-overlay-on").keypress(function (e) 
   {
    idleTime = 0;
   });
   });
  function textResponse(text, sequence,idleTime) {
if (text === "") {
    text = myc_script_vars.messages.internal_error;
}
var date = new Date();
var img="<img src=\"http://demo.robasys.quikrltd.com/wp- 
    content/uploads/2019/04/chatlogo%20white%20bg.png\">"
var innerHTML = "<div class=\"myc-conversation img\">"+img+"</div>"+" 
    <div class=\"myc-conversation-bubble-container myc-conversation- 
   bubble-container-response myc-conversation-bubble-container-response 
    img \"><div class=\"myc-conversation-bubble myc-conversation-response 
    myc-is-active myc-text-response\">" + text+ "</div>";
var html = "<div class=\"myc-conversation img\">"+img+"</div>"+"<div 
    class=\"myc-conversation-bubble-container myc-conversation-bubble- 
     container-response myc-conversation-bubble-container-response img \"> 
     <div class=\"myc-conversation-bubble myc-conversation-response myc- 
     is-active myc-text-response\">" +"Are u there?"+ "</div>";
if (myc_script_vars.show_time) {
    innerHTML += "<div class=\"myc-datetime\">" + 
     date.toLocaleTimeString() + "</div>";
}
innerHTML += "</div>";
jQuery("#myc-container-" + sequence + " .myc-conversation- 
    area").append(innerHTML);
idleTime = idleTime + 1;
     if (idleTime > 1) { // 1 minutes
    jQuery("#myc-container-" + sequence + " .myc-conversation- 
    area").append(html);    
      }
var n=jQuery(".myc-conversation-bubble").length;
if(n>=3){
jQuery(".myc-content-overlay-header-text").replaceWith("<span 
   class=\"wrapo\"><div class=\"myc-conversation_pic \">"+img+" 
    </div>"+"Now chatting"+"</span>");
} 
var end="<button class=\"Endchat\">"+"End chat"+"</button>";
setTimeout(function(){  
jQuery(".wrapo").replaceWith("<div class=\"overlaytext\">"+img+" 
   </div>"+end);
    },15000);
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...