Advertisement
Pyorot

LondonPogoMap/Pushbullet Bot 1.2.1

Mar 20th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function notifyPB(title, body) {
  2.     var xhr = new XMLHttpRequest();
  3.     xhr.open('POST', "https://api.pushbullet.com/v2/pushes", true);
  4.     xhr.setRequestHeader('Access-Token', access_token);
  5.     xhr.setRequestHeader('Content-Type', 'application/json');
  6.     xhr.send('{"body":"' + body + '","title":"' + title + '","type":"note"}');
  7.     console.log(title);
  8. }
  9.  
  10. function time(timecode) {
  11.     if (typeof timecode == 'undefined') {var date = new Date();} else {var date = new Date(timecode);};
  12.     var hours = date.getHours();
  13.     var minutes = "0" + date.getMinutes();
  14.     var seconds = "0" + date.getSeconds();
  15.     return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
  16. }
  17.  
  18. iv = Array.apply(null, new Array(252)).map(Number.prototype.valueOf,-48);
  19. r = Array.apply(null, new Array(252)).map(Number.prototype.valueOf,0);
  20. known_despawns = [];
  21.  
  22. iv[111] = -4;  r[111] = 1.2;
  23. iv[112] = -6;  r[112] = 0.8;
  24. iv[113] = -45; r[113] = 1.2;
  25. iv[114] = -45; r[114] = 5;
  26. iv[129] = -4;  r[129] = 0.7;
  27. iv[130] = -4;  r[130] = 1.2;
  28. iv[133] = -4;  r[133] = 1.2;
  29. iv[143] = -45; r[143] = 0.5;
  30. iv[147] = -4;  r[147] = 1.2;
  31. iv[148] = -3;  r[148] = 1.2;
  32. iv[149] = -45; r[149] = 1.2;
  33. home_lat = 0; home_lng = 0;
  34. access_token = '0'
  35.  
  36. notifyPB('Initialised', 'Home: http://www.google.com/maps/place/' + home_lat + ',' + home_lng);
  37. var timer = setInterval(function() {
  38.  
  39. b = [];
  40.  
  41. for (i = 0, len = this.pokemons.length; i < len; i++) {
  42.     test = this.pokemons[i];
  43.     test_iv = (test.attack + test.defence + test.stamina) - 45;
  44.     if (test_iv >= iv[test.id]) {
  45.         test_x = Math.abs(test.center.lat - home_lat)*110.574;
  46.         test_y = Math.abs(test.center.lng - home_lng)*69.298;
  47.         if (test_x*test_x + test_y*test_y < r[test.id]*r[test.id]) {
  48.             test.r = Math.sqrt(test_x*test_x + test_y*test_y);
  49.             test.iv = test_iv;
  50.             b.push(test);
  51.         }
  52.     }          
  53. }
  54.  
  55. for (i = 0, len = b.length; i < len; i++) {
  56.     if (known_despawns.indexOf(b[i].despawn) != -1) { continue; }
  57.     test_time = time(b[i].despawn*1000);
  58.     notif = pokeDict[b[i].id].name+' | '+b[i].iv+' | '+b[i].r.toFixed(2)+'km | '+test_time;
  59.     url = 'http://www.google.com/maps/place/' + b[i].center.lat + ',' + b[i].center.lng;
  60.     notifyPB(notif, url);
  61.     known_despawns.push(b[i].despawn);
  62. }
  63.  
  64. console.log('Ran at '+time())
  65. }, 30 * 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement