Guest User

Fritter - a miniscule free twitter replacement

a guest
Oct 9th, 2010
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import datetime
  4. import time
  5. import urllib2
  6.  
  7. def once(conf, tweets):
  8.     for line in conf:
  9.         line = line.replace("\r","").replace("\n", "")
  10.         host, person = line.split()
  11.         url = "http://{0}/~{1}/fritter.txt".format(host, person)
  12.         f = urllib2.urlopen(url)
  13.         tweet = f.read()
  14.         print_tweet = True
  15.         if tweets.has_key(url):
  16.             if tweets[url] == tweet: print_tweet = False
  17.         tweets[url] = tweet
  18.         if print_tweet:
  19.             print "At {0}, {1} at {2} wrote:".format(datetime.datetime.now(), person, host)
  20.             print tweet
  21.  
  22.            
  23.        
  24.  
  25. # read configuration file
  26. conf = file("fritter.conf","r").read().splitlines()
  27. tweets = {}
  28. while(True):
  29.     once(conf, tweets)
  30.     time.sleep(5)
Add Comment
Please, Sign In to add comment