SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 122 in 4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var getLC = function(collection, msg) {
  3. if ( !config.check_chats(msg.chat.id) ) { return; }
  4.  
  5.  
  6.  
  7. if (typeof(msg.text) === "undefined") { return; }
  8. msg_txt = msg.text.toString().toLowerCase();
  9. if (!msg_txt.includes("!lc ")) { return; }
  10.  
  11. console.log("TEST");
  12. msg_txt = msg_txt.replace("!lc " , "" );
  13. var regex = new RegExp(["^", msg_txt, "$"].join(""), "i");
  14. var regex = new RegExp([".*", msg_txt , ".*"].join(""), "i");
  15.  
  16.     absURL = Meteor.absoluteUrl();
  17.     // Get Port
  18.     port = absURL.split(":")[2].split("/")[0];
  19.     port = parseInt(port)+1;
  20.  
  21.     // Get MongoURL
  22.     mongoURL = Meteor.absoluteUrl().split("//")[1].split(":")[0];
  23.  
  24.     var url = "mongodb://"+ mongoURL + ":"+ String(port) + "/meteor";
  25.  
  26.  
  27.     if (typeof(msg.text) === "undefined") { return; }
  28.     global.MongoClient.connect(url,{ useNewUrlParser: true }, function(err, db) {
  29.         if (err) throw err;
  30.         var dbo = db.db("meteor");
  31.         dbo.collection("offensive_plays").find({ off_play: regex }).toArray((err, result) => {
  32.             var answer = [];
  33.             //console.log(result);
  34.  
  35.             result.forEach(function(element) {
  36.                  bot.sendMessage(msg.chat.id, element.off_play );
  37.             ///
  38.             var answer = [];
  39.             answer.push(element.off_play);
  40.            // console.log(element._id);
  41.             global.MongoClient.connect(url,{ useNewUrlParser: true }, function(err2, db2) {
  42.                 var dbo2 = db2.db("meteor");
  43.                 dbo2.collection("play_data").find({ off_play: "CDQiLEufHeiv28hsy" ,  avg: { $ne: NaN }  }, { sort: { avg: 1 } }).toArray((err2, result2) => {    
  44.                 //console.log(result2);
  45.  
  46.                 result2.forEach(function(item,index)  {
  47.                     global.MongoClient.connect(url,{ useNewUrlParser: true }, function(err3, db3) {
  48.                         var dbo3 = db3.db("meteor");    
  49.                          dbo3.collection("defensive_plays").findOne({ _id: item.def_play  }).then(function(d_play_data) {
  50.                             answer.push( d_play_data.formation + " - " + d_play_data.def_play + ": " + item.avg );
  51.                          });
  52.                         console.log(answer);
  53.                      });
  54.                 });
  55.            
  56.  
  57.         });
  58.     });
  59.         ////    
  60.             });
  61.         });
  62.             db.close();
  63.     });
  64. }
  65.  
  66.  
  67. bot.on('message', (msg) => {
  68.   getLC("offensive_plays",msg);
  69. })
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top