Skip to content

Instantly share code, notes, and snippets.

@wonderb0lt
Last active December 17, 2015 06:39
Show Gist options
  • Save wonderb0lt/5567509 to your computer and use it in GitHub Desktop.
Save wonderb0lt/5567509 to your computer and use it in GitHub Desktop.
Error ._.
import json
import pkgutil
import tweetpony
import modules
class DispatchingHandler(tweetpony.api.StreamProcessor):
def __init__(self, api):
tweetpony.api.StreamProcessor.__init__(self, api)
self.handlers = map(lambda h: h.inject_api(self.api), modules.active)
def on_status(self, status):
for handler in self.handlers:
handler.on_status(status)
def on_message(self, message):
print 'received message from ' + message.user.screen_name
for handler in self.handlers:
handler.on_message(message)
def on_event(self, event):
print str(event)
def daemon():
consumer_key, consumer_secret, access_key, acces_secret = load_keys()
print 'Authenticating....'
api = tweetpony.API(consumer_key=consumer_key, consumer_secret=consumer_secret, access_token=access_key, access_token_secret=acces_secret)
try:
print 'Starting daemon!'
api.user_stream(processor=DispatchingHandler(api))
except KeyboardInterrupt:
print '\nShutting down...'
def load_keys():
with open('conf.json') as f:
keys = json.load(f)['keys']
return (keys['consumer_key'], keys['consumer_secret'], keys['access_token_key'], keys['access_token_secret'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment