Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def user_mention(self, status):
# Once again we create an empty array
results = []
# Here we want to check the user mentions component of the status
# So the first step is to identify if it's empty or not
if status.entities['user_mentions']:
# Multiple users can be mentioned in a tweet,
# so we'll want to build a for-loop
for user in status.entities['user_mentions']:
# We lower our results like we lowered our input to compare them
# For our case, we're pulling out the value of screen_name, this is
# based on the assumption that you're tracking the screen names of the user's.
# Alternatively you could use their id, but you'd need to set up a process to get
# the ids first.
results.append(str(user['screen_name']).lower() in self.twitter_accounts)
else:
pass
# We want to return if there's any that true in our array
return any(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.