mirror of https://github.com/nealey/firebot
A few fixes for #fast-food
This commit is contained in:
parent
e8b8e5aaa0
commit
7ddc784807
12
firebot.py
12
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<code>.+)$"), 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<url>\b[a-z]+://[-a-z0-9_=!?#$@~%&*+/:;.,\w]+[-a-z0-9_=#$@~%&*+/\w])"),
|
||||
shorturl))
|
||||
|
||||
|
|
12
gallium.py
12
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)
|
||||
|
|
19
shorturl.py
19
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('<title>URLs</title><h1>URLs</h1><ol>\n')
|
||||
for url in URLS:
|
||||
for i in range(len(URLS), 0, -1):
|
||||
url = URLS[i - 1]
|
||||
self.send('<li><a href="%s">%s</a></li>\n' % (url, url))
|
||||
self.send('</ol>\n')
|
||||
|
||||
|
|
Loading…
Reference in New Issue