From 7ddc78480733cfe958aa3d4b410cc7f7b1a973e7 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 4 Oct 2007 16:09:33 -0600 Subject: [PATCH] A few fixes for #fast-food --- firebot.py | 12 +++++++++--- gallium.py | 12 +++++++++++- shorturl.py | 19 +++++++++++-------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/firebot.py b/firebot.py index d2344f5..3f46547 100755 --- a/firebot.py +++ b/firebot.py @@ -43,9 +43,10 @@ class FireBot(infobot.InfoBot, procbot.ProcBot): heartbeat_interval = 0.5 ping_interval = 120 - def __init__(self, host, nicks, gecos, channels, dbname='info.db', ssl=False, **kwargs): + def __init__(self, host, nicks, gecos, channels, + dbname='info.cdb', ssl=False, **kwargs): infobot.InfoBot.__init__(self, host, nicks, gecos, channels, - **kwargs) + dbname=dbname, **kwargs) self.ssl = ssl self.nosy = True self.seen = {} @@ -159,11 +160,16 @@ class FireBot(infobot.InfoBot, procbot.ProcBot): #bindings.append((re.compile(r"^\; *(?P.+)$"), evalstr)) #msg_cat['eval'] = ('%(code)s ==> %(ret)s',) + shorturlnotice = True def shorturl(self, sender, forum, addl, match): url = match.group('url') print ('url', url) idx = shorturl.add(url) - forum.msg('http://%s:%d/%d' % (URLSERVER[0], URLSERVER[1], idx)) + if self.shorturlnotice: + f = forum.notice + else: + f = forum.msg + f('http://%s:%d/%d' % (URLSERVER[0], URLSERVER[1], idx)) bindings.append((re.compile(r".*\b(?P\b[a-z]+://[-a-z0-9_=!?#$@~%&*+/:;.,\w]+[-a-z0-9_=#$@~%&*+/\w])"), shorturl)) diff --git a/gallium.py b/gallium.py index 10285d0..ca711ed 100755 --- a/gallium.py +++ b/gallium.py @@ -90,7 +90,7 @@ if __name__ == '__main__': import socket import daemon import sys - + debug = False if "-d" in sys.argv: debug = True @@ -105,10 +105,20 @@ if __name__ == '__main__': firebot.URLSERVER = (socket.gethostbyaddr(socket.gethostname())[0], us.getsockname()[1]) + # gallium gallium = Gallium(('fozzie.woozle.org', 6667), ['gallium'], "I'm a little printf, short and stdout", ["#woozle", "#gallium"]) + gallium.shorturlnotice = False gallium.debug = debug + # fink + fink = Gallium(('irc.oftc.net', 6667), + ['fink'], + "Do you like my hat?", + ["#fast-food", "#orion"], + dbname='fink.cdb') + fink.debug = debug + irc.run_forever(0.5) diff --git a/shorturl.py b/shorturl.py index 23a25c4..43e3754 100755 --- a/shorturl.py +++ b/shorturl.py @@ -274,13 +274,15 @@ class URLHandler(HTTPHandler): if self.path == '/': self.list_urls() return - - try: - idx = int(self.path[1:]) - url = URLS[idx] - except (ValueError, IndexError): - self.send_error(404) - return + elif self.path == '/newest': + url = URLS[-1] + else: + try: + idx = int(self.path[1:]) + url = URLS[idx] + except (ValueError, IndexError): + self.send_error(404) + return self.send_response(301) self.send_header('Location', url) @@ -297,7 +299,8 @@ class URLHandler(HTTPHandler): self.send_header('Content-Type', 'text/html') self.end_headers() self.send('URLs

URLs

    \n') - for url in URLS: + for i in range(len(URLS), 0, -1): + url = URLS[i - 1] self.send('
  1. %s
  2. \n' % (url, url)) self.send('
\n')