Skip to content

Instantly share code, notes, and snippets.

@kyleterry
Created August 10, 2011 08:55
Show Gist options
  • Save kyleterry/1136404 to your computer and use it in GitHub Desktop.
Save kyleterry/1136404 to your computer and use it in GitHub Desktop.
import time
import redis
import twitter
accounts = ('reddit', 'AnonymousIRC',)
channels = ('hackpark', 'infoforcefeed')
def main():
r = redis.Redis()
api = twitter.Twitter()
while True:
for account in accounts:
if not r.get('%s_since_id' % account):
tweets = api.statuses.user_timeline(screen_name=account,
count=10, include_rts=True)
else:
tweets = api.statuses.user_timeline(screen_name=account,
count=10, include_rts=True,
since_id=r.get('%s_since_id' % account))
if tweets:
r.set('%s_since_id' % account, tweets[0]['id'])
for tweet in tweets:
for channel in channels:
r.publish('#%s_out' % channel,
'%s tweet: %s' % (account, tweet['text']))
time.sleep(2)
time.sleep(60)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment