commit 8cebb44f1cf3ab1afcf4ebaa4e452bc2237b1cc0
parent 768e6b06ec96d65d04c177dc16b44859e48c747c
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Mon, 11 Jun 2012 19:25:50 +0200
add custom output format, remove shortening
Diffstat:
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/wikifirc b/wikifirc
@@ -5,11 +5,15 @@ import time
import urllib.parse
import urllib.request
-API="http://uzy.me/?api&longurl=%s"
-
-def shorten(url):
- return urllib.request.urlopen(API % urllib.parse.quote(url)).read()
+colors = {
+ 'green': 3,
+ 'red': 4,
+ 'olive': 7,
+ 'teal': 10,
+ }
+def colorize(text, color):
+ return "\x03%d%s\x030" % (colors[color], text)
class Line:
def __init__(self, project, data):
@@ -27,11 +31,18 @@ class Line:
self.username = username[3:-4]
fields = rest.split(' ')
fields.pop(0) # rest of flags3
- self.diff2 = fields.pop(0)[1:-1]
+ self.diffc = fields.pop(0)[1:-1]
self.message = ' '.join(fields)[3:-1]
def __str__(self):
- return self.data
+ return ("<%s> [[%s]] %s %s \"%s\" %s" % (
+ colorize(self.username, 'green'),
+ colorize(self.page, 'olive'),
+ self.diffc,
+ colorize(self.flags+self.flags2, 'red'),
+ colorize(self.message, 'teal'),
+ self.diff,
+ ))
def register(pages, page):
if page in pages: