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.

Revisions

  1. Christian Stefanescu created this gist Feb 2, 2012.
    32 changes: 32 additions & 0 deletions heise-notify.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/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)