Created
April 14, 2021 09:47
-
-
Save kemalersin/5f75db42ff58b54a6798c4fb27a56199 to your computer and use it in GitHub Desktop.
Sozzio Twitter Participation Check Methods
This file contains 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
twitter: { | |
pagelike: async (function (account, campaign) { | |
if (account.profileId == twSelf.profileId) { | |
return true; | |
} | |
var result = await (twAccountClient.get('friendships/show', { | |
target_id: twSelf.profileId | |
}).catch(console.log)); | |
if (_.get(result, 'data.relationship.source.following')) { | |
return true; | |
} | |
return false; | |
}), | |
postlike: async (function (account, campaign) { | |
var result = await (twAccountClient.get('favorites/list', { | |
count: 1, | |
max_id: campaign.twitter.postId | |
}).catch(console.log)); | |
return _.has(result, 'data') && ( | |
_.chain(result.data).head().get('id_str').value() === | |
campaign.twitter.postId | |
); | |
}), | |
postshare: async (function (account, campaign) { | |
var result = await (twAccountClient.get('statuses/retweeters/ids', { | |
id: campaign.twitter.postId, | |
count: 100 | |
}).catch(console.log)); | |
return _.has(result, 'data.ids') && | |
_.includes(result.data.ids, +account.profileId); | |
}), | |
postcomment: async (function (account, campaign) { | |
var result = await (twSelfClient.get('statuses/mentions_timeline', { | |
since_id: campaign.twitter.postId, | |
count: 100 | |
}).catch(console.log)); | |
return _.has(result, 'data') && ( | |
!!_.find(result.data, function (comment) { | |
return ( | |
_.get(comment, 'user.id_str') === account.profileId && | |
_.get(comment, 'in_reply_to_status_id_str') === campaign.twitter.postId | |
) | |
}) | |
); | |
}), | |
friendtag: async (function (account, campaign) { | |
var result = await (twSelfClient.get('statuses/mentions_timeline', { | |
since_id: campaign.twitter.postId, | |
count: 100 | |
}).catch(console.log)); | |
return _.has(result, 'data') && ( | |
!!_.find(result.data, function (comment) { | |
return ( | |
_.get(comment, 'user.id_str') === account.profileId && | |
_.get(comment, 'in_reply_to_status_id_str') === campaign.twitter.postId && | |
( | |
_.filter(_.get(comment, 'entities.user_mentions'), function (mention) { | |
return mention.id_str !== twSelf.profileId; | |
}).length >= campaign.twitter.friendTagCount | |
) | |
) | |
}) | |
); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment