daily pastebin goal
43%
SHARE
TWEET

Untitled

Muzzer16 Sep 14th, 2018 66 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. var es = new EventSource(eventFeed + nextGame.id, init);
  2.  
  3.         es.onopen = function() {
  4.            console.log("Connected!");
  5.         }
  6.  
  7.         es.addEventListener("QuestionStart", function(e) {
  8.             processQuestion(JSON.parse(e.data));
  9.         });
  10.  
  11.         es.addEventListener("error", function(err) {
  12.         console.log("Error: " + JSON.stringify(err));
  13.         });
  14.   }
  15. });
  16.  
  17. function processQuestion(json) {
  18.     var nextCounter = 0;
  19.     AMentions = 0;
  20.     BMentions = 0;
  21.     CMentions = 0;
  22.  
  23.     console.log("-- " + json.question + " --");
  24.     console.log("> Attempting to fetch answer...");
  25.  
  26.     var question = json.question;
  27.     var questionLowercase = json.question;
  28.     var questionSearch = questionLowercase;
  29.     var questionNumber = json.number;
  30.     var answer = 1;
  31.     var notDetected = false;
  32.  
  33.     if (utilities.stringContains(questionSearch, "Which of these")) {
  34.         questionSearch = questionSearch.replace("Which of these", "what");
  35.     }
  36.  
  37.     if (utilities.stringContains(question, " not ")) {
  38.         notDetected = true;
  39.         console.log("Possible anti-bot question detected!");
  40.     }
  41.  
  42.     var AMentions = 0;
  43.     var BMentions = 0;
  44.     var CMentions = 0;
  45.  
  46.     google(questionSearch, function(err, res) {
  47.         if (err) {
  48.             console.log("Failed to fetch answer!");
  49.             return;
  50.         }
  51.  
  52.         for (var i = 0; i < res.links.length; ++i) {
  53.             var link = res.links[i];
  54.             var body = res.body;
  55.  
  56.             if (link.title.indexOf(json.choices[0].choice) != -1) {
  57.                 AMentions++;
  58.             }
  59.  
  60.             if (link.title.indexOf(json.choices[1].choice) != -1) {
  61.                 BMentions++;
  62.             }
  63.  
  64.             if (link.title.indexOf(json.choices[2].choice) != -1) {
  65.                 CMentions++;
  66.             }
  67.  
  68.             if (link.description.toLowerCase().indexOf(json.choices[0].choice.toLowerCase()) != -1) {
  69.                 AMentions++;
  70.             }
  71.  
  72.             if (link.description.toLowerCase().indexOf(json.choices[1].choice.toLowerCase()) != -1) {
  73.                 BMentions++;
  74.             }
  75.  
  76.             if (link.description.toLowerCase().indexOf(json.choices[2].choice.toLowerCase()) != -1) {
  77.                 CMentions++;
  78.             }
  79.  
  80.             if (nextCounter < 4) {
  81.                 nextCounter += 1;
  82.                 if (res.next) res.next();
  83.             }
  84.         }
  85.  
  86.         if (!notDetected) {
  87.             var highest = Math.max(AMentions, BMentions, CMentions);
  88.  
  89.             if (AMentions == highest) {
  90.                 answer = 1;
  91.             } el
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top