Skip to content

Instantly share code, notes, and snippets.

@satishbabariya
Created September 20, 2018 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishbabariya/2c2b7b51af5fe84f77c6fe458477949c to your computer and use it in GitHub Desktop.
Save satishbabariya/2c2b7b51af5fe84f77c6fe458477949c to your computer and use it in GitHub Desktop.
const OKCupid = require('okcupidjs');
var Promise = require('bluebird');
var okc = Promise.promisifyAll(new OKCupid());
const baseQuery = { i_want: "women", they_want: "men","maximum_age": 24, radius: 9999 };
const search = async () => {
try {
await okc.loginAsync("", "");
console.log('login done');
} catch (e) {
console.log('Failed to login. Check your username and password in the env file.');
return;
}
console.log('searching...');
let count = 0;
const search = () => {
var options = {
}
// okc.getLikes(options, function (errx, res, bodyx) {
// //console.log("Error", errx);
// //console.log("bodyx", bodyx.data);
// bodyx.data.forEach(function (element) {
// console.log(element.user.userid);
// okc.sendMessage(element.user.userid, "Hey.", function (err, res, body) {
// console.log(body);
// });
// });
// // okc.like(body);
// });
okc.search(baseQuery, function (err, res, body) {
body.data.forEach(function (user) {
console.log(user.username, user.userid);
return okc.like(user.userid, function (err, res, body) {
okc.sendMessage(user.userid, "Hey.");
});
});
var hash = body.paging.cursors.after;
// check termination condition, otherwise recurse
// if (hash != null && count <= 1) {
// baseQuery.after = hash;
// count = count + body.data.length;
// search();
// }
});
};
search();
};
search();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment