Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bot.dialog('/', function (session) {
  2.    
  3.    
  4.     /*if(session.message.text.toLowerCase.contains('input1') || session.message.text.toLower.Case.contains('input2') || session.message.text.toLower.Case.contains('input3'))
  5.     {
  6.       session.send('Answer');
  7.     }*/
  8.  
  9.     const userText = session.message.text.toLowerCase();
  10.  
  11.     String.prototype.is = function() {
  12.         const args = Array.prototype.slice.call(arguments);
  13.         const text = userText;
  14.         for(let i = 0; i < args.length; i++) if(text.includes(args[i])) return true;
  15.         return false;
  16.     };
  17.  
  18. //Greeting  
  19.     if(userText.is('hello', 'hi', 'good morning', 'good afternoon', 'hey'))
  20.     session.send(`Hello. How are you?`);
  21.  
  22. //Help    
  23.     else if(userText.is('help'))    
  24.     session.send(`What can I help you with? Do you want to know something specific?`);
  25.  
  26. //Unrecognized messages    
  27.     else                                            
  28.     session.send(`Sorry, I don't understand you. Try to formulate your question differently please.`);
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement