Skip to content

Instantly share code, notes, and snippets.

@stchris
Created February 2, 2012 11:35
Show Gist options
  • Save stchris/1723089 to your computer and use it in GitHub Desktop.
Save stchris/1723089 to your computer and use it in GitHub Desktop.
Python script to show twitter updates with pyinotify
#!/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)
@alexgs922
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment