Created
February 2, 2012 11:35
-
-
Save stchris/1723089 to your computer and use it in GitHub Desktop.
Python script to show twitter updates with pyinotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import pynotify | |
import twitter | |
import time | |
last_id = {} | |
users = ['heiseonline'] | |
def notify(title, text): | |
notification = pynotify.Notification(title, text) | |
notification.show() | |
def get_tweets(user): | |
if last_id.has_key(user): | |
s = api.GetUserTimeline(users, since_id = last_id[user]) | |
if s: | |
last_id[user] = s[0].id | |
return s | |
else: | |
s = api.GetUserTimeline(user) | |
last_id[user] = s[0].id | |
return s[0:4] | |
if __name__=='__main__': | |
pynotify.init('heise-notify') | |
api = twitter.Api() | |
while True: | |
for user in users: | |
t = get_tweets(user) | |
for s in t: | |
notify("@%s" % user, s.text) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice