Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Listener(StreamListener):
def __init__(self, api=None):
# This method used to define what needs to be done
# before the class can be actually used
# In our case, we're making sure the api is set up
# and loading the values we need for our tests
self.api = api or tweepy.API()
self.domains = load_domains()
self.twitter_accounts = load_twitter_accounts()
# simple proof of concept
def on_status(self, status):
# This is the method the processes the statuses
# sent by twitter, in our case we want to check
# the statuses against our tests
if self.domain_test(status=status):
# This is the function we want to call in
# when we find a match :)
twitter_hit(status)
if self.user_mention(status=status):
# This is the function we want to call in
# when we find a match :)
twitter_hit(status)
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.