Skip to content

Instantly share code, notes, and snippets.

@wonderb0lt
Created May 22, 2013 21:53
Show Gist options
  • Save wonderb0lt/5631249 to your computer and use it in GitHub Desktop.
Save wonderb0lt/5631249 to your computer and use it in GitHub Desktop.
The implementation for gist 5731132
funcs = []
USER_STREAM = '__userstream__'
class on_tweet(object):
def __init__(self, sender = None):
print 'In on_tweet ctor with sender =' + sender
self.sender = sender
self.f = None
def __call__(self, f):
print 'Now decorating function ' + str(f)
self.f = f
def wrapped(*args):
print 'Executing a wrapped function (maybe)'
print 'args are ' + str(args)
if self.passes(args[0]):
f(*args)
funcs.append(wrapped)
return wrapped
def passes(self, tweet):
print 'on_tweet passes'
return tweet.user.screen_name == self.sender
class on_mention(on_tweet):
def __init__(self, num_mentionees, *args, **kwargs):
self.num_mentionees = num_mentionees
print 'on_mention ctor with num_mentionees = ' + str(num_mentionees) + ' WITH NO CARE FOR ALL OTHER PARAMS'
on_tweet.__init__(self, *args, **kwargs)
def passes(self, tweet):
print 'on_mention passes'
return on_tweet.passes(self, tweet) and len(tweet.entities.user_mentions) == self.num_mentionees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment