Skip to content

Instantly share code, notes, and snippets.

@planglois925
Created September 11, 2017 16:08
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 planglois925/b55cf085afbf5093f6378baa46d4f9fc to your computer and use it in GitHub Desktop.
Save planglois925/b55cf085afbf5093f6378baa46d4f9fc to your computer and use it in GitHub Desktop.
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