Last active
March 19, 2021 18:18
-
-
Save vncsna/c72ddcefda2d841c7791fd4f9eb599c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function follow_protocol(number=0){ | |
let query = coin_toss ? 'protocolo' : 'protocol' | |
.get( | |
'users/search', | |
{q: query, | |
page: number, | |
count: 20, | |
include_entities: false} | |
) | |
.then(result => { | |
let user_id = [] | |
for(let user of result.data){ | |
if (user.description.includes(query) || | |
user.screen_name.includes(query) || | |
user.name.includes(query)){ | |
user_id.push(user.id_str) | |
} | |
} | |
.get( | |
'friendships/lookup', | |
{user_id: user_id} | |
) | |
.then(result => { | |
for(let friend of result.data){ | |
if(!friend.connections.includes('blocking') && | |
!friend.connections.includes('following') && | |
!friend.connections.includes('following_requested')){ | |
follow_user(friend.id_str) | |
return 0 | |
} | |
} | |
return follow_protocol(number + 1) | |
}) | |
.catch(error => { | |
console.log('follow_protocol:friendship/lookup') | |
console.log(error) | |
}) | |
}) | |
.catch(error => { | |
console.log('follow_protocol') | |
console.log(error) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment