diff options
author | tv <tv@nomic.retiolum> | 2013-12-09 20:07:19 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-12-09 20:07:19 +0100 |
commit | f4f5b3b7aff2ac45ee035f54d6e8899ff963d133 (patch) | |
tree | 415410184165bbeaa7ed0cb54b7b915a856e909b /noise/modules/twitter | |
parent | 5788b95fe7834d3049df9de1009f3d8dbc34fea2 (diff) |
noise: RIP
Diffstat (limited to 'noise/modules/twitter')
-rwxr-xr-x | noise/modules/twitter | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/noise/modules/twitter b/noise/modules/twitter deleted file mode 100755 index 26982525..00000000 --- a/noise/modules/twitter +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python -#encode=utf8 - -#print "[31;4;5;1mTODO Bug Robert to implement Twitter-OAuth![m" -#exit(1) -import sys - -#sys.path.append("/usr/local/lib/") - -import twitter, os, pwd - -#os.getlogin = lambda: pwd.getpwuid(os.getuid())[0] - -sys.stderr = sys.stdout - -def shorten(text): - - text = text.replace("about ", "~") - text = text.replace("an", "1") - text = text.replace(" minutes", "m") - text = text.replace(" minute", "m") - text = text.replace(" hours", "h") - text = text.replace(" hour", "h") - text = text.replace(" seconds", "s") - text = text.replace(" second", "s") - text = text.replace(" days", "d") - text = text.replace(" day", "d") - text = text.replace(" weeks", "w") - text = text.replace(" week", "w") - text = text.replace(" years", "y") - text = text.replace(" year", "y") - text = text.replace(" ago", "") - text = text.replace("a", "1") - return text - - -def parse(text): - text = text.replace("\n","") - t = text.split(" ") - new = "" - for piece in t: - escape = "" - if piece.startswith("@"): - escape = "[33;4m" - if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": - escape = "[31;4m" - - elif piece.startswith("#"): - escape = "[35m" - elif piece.startswith("http://"): - escape = "[36;4m" - if escape: - new += escape + piece + "[m " - else: - new += piece + " " - - return new - -if len(sys.argv) > 1 and sys.argv[1] == "--help": - print "read or post to the shackspam twitter timeline" - if len(sys.argv) == 3 and sys.argv[2] == "--verbose": - print "call without parameters to read" - print "use /twitter [your tweet] to tweet something to the shackspam twitter timeline" - exit() - - - -api = twitter.Api("Z7f9npE5ixvZ0lMCHDZBOg", "8z0gyfOABar1HxKvqL6fYXLqRFUPLQ9OOzDFt7Q4F4", "139766258-94TGPvNsJ8tYVv68eZewfXOIyDvRCWdycNlUgHrs", "NRnDQZPCoLrDizFvakZkSWgoG4vgGuT3OOMChSfiI") - -#api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42") - -if len(sys.argv) > 1: - - - tweet = u"" - - for t in sys.argv[1:]: - tweet += t.decode("utf8") + u" " - tweet = tweet[:-1] - - print u"Length: [32;1m" + str(len(tweet)) + u"[m" - - if len(tweet) > 140: - print u"[31;6mYour Tweet must be shorter than 140 characters.[m\n" - exit() - - status = api.PostUpdate(tweet) - - - - -else: - """print "\t[31;4mshackspace tweets:[m" - for i in api.GetUserTimeline(): - i.text = parse(i.text) - print ("[32m" + i.user.screen_name + "[m [34m" + i.GetRelativeCreatedAt() + "[m " + i.text).encode("utf8").replace("\n"," ") - - print "\n\t[31;4mfriends tweets[m" - """ - a = api.GetFriendsTimeline() - a.reverse() - for i in a: - text = i.text - ilen = len(i.user.screen_name) + len(shorten(i.GetRelativeCreatedAt())) + 2 - if i.user.screen_name.lower() == "shackspace" or i.user.screen_name.lower() == "shackspam": - info = "[32;4m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" - else: - info = "[32m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" - text = info + " " + parse(text) - - t = text.split(" ") - tmp = "" - for n in t: - if ((len(tmp) + len(n)) >= 80): - print parse(tmp).encode("utf8") - tmp = " " * ilen - - tmp += " " + n - if len(tmp) > ilen: - print parse(tmp).encode("utf8") - - - - - |