document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //-----------------------
  2. //The name of our chatbot
  3. //-----------------------
  4. $chatBot::name = "Bob";
  5.  
  6. //-------------------------------------------------------------
  7. //Our Chatbot\'s Responses, anything that uses multiple
  8. //Words should instead use an underscore "_" instead of a space
  9. //Users can constantly add new keywords to respond to
  10. //-------------------------------------------------------------
  11. $chatBot::response["Hi"] = "Hi Hey What\'s_up Heya Howdy";
  12. $chatBot::response["Lol"] = "What\'s_So_Funny? Haha_I_don\'t_get_it... That\'s_not_funny";
  13.  
  14. //--------------------------------------------------------
  15. //Number of milliseconds that our chatbot will not respond
  16. //After having responded to any phrase at all
  17. //--------------------------------------------------------
  18. $chatBot::timeOut = 5000;
  19.  
  20.  
  21. package myFirstChatBot
  22. {
  23.     //---------------------------------------------------------
  24.     //There are only a few parameters we need to focus on here
  25.     //Which are %name and %msg
  26.     //---------------------------------------------------------
  27.    
  28.     function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
  29.     {
  30.         parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
  31.     }
  32. };
  33. activatePackage(myFirstChatBot);
  34.  
  35. //----------------------------------------------
  36. //This function picks one of our random phrases
  37. //And returns it so we can use it
  38. //----------------------------------------------
  39.  
  40. function chatBot_getRandomPhraseFromWord(%word)
  41. {
  42.     %phrases = $chatBot::response[%word];
  43.    
  44.     if(%phrases !$= "")
  45.     {
  46.         %count = getWordCount(%phrases);
  47.         %ranPhrase = getWord(%phrases,getRandom(0,%count));
  48.         %ranPhrase = strReplace(%ranPhrase,"_"," ");
  49.        
  50.         return %ranPhrase;
  51.     }
  52.     else
  53.         return false;
  54. }
  55.  
  56. //---------------------------------------------------
  57. //This function checks a string sent by another user
  58. //And if it has one of our response triggers
  59. //It\'ll return that word, otherwise it returns false
  60. //---------------------------------------------------
  61.  
  62. function chatBot_messageHasTriggerWord(%string)
  63. {
  64.     %wordCount = getWordCount(%string);
  65.    
  66.     for(%i=0;%i<%wordCount;%i++)
  67.     {
  68.         %word = getWord(%string,%i);
  69.        
  70.         if($chatBot::response[%word] !$= "")
  71.         {
  72.             return %word;
  73.         }
  74.     }
  75.     return false;
  76. }
  77.  
  78. //-------------------------------------------
  79. //This function will attempt to say a string
  80. //As the chat bot, and checks things like
  81. //Flood protection triggering and spamming
  82. //-------------------------------------------
  83.  
  84. function chatBot_say(%string)
  85. {
  86.     %time = getSimTime();
  87.    
  88.     if(%time - $chatBot::lastTalkTime >= $chatBot::timeOut)
  89.     {
  90.         if($chatBot::lastTalkMessage $= %string)
  91.         {
  92.             error("Our chatbot will trigger the flood protection, returning false";
  93.             return false;
  94.         }
  95.         else
  96.         {
  97.             commandToServer(\'messageSent\',$chatBot::name @ " => " @ %string);
  98.             $chatBot::lastTalkMessage = %string;
  99.             $chatBot::lastTalkTime = %time;
  100.         }
  101.        
  102.         return true;
  103.     }
  104.     return false;
  105. }
');