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
|
heartbeat_interval = 0.5
|
||||||
ping_interval = 120
|
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,
|
infobot.InfoBot.__init__(self, host, nicks, gecos, channels,
|
||||||
**kwargs)
|
dbname=dbname, **kwargs)
|
||||||
self.ssl = ssl
|
self.ssl = ssl
|
||||||
self.nosy = True
|
self.nosy = True
|
||||||
self.seen = {}
|
self.seen = {}
|
||||||
|
@ -159,11 +160,16 @@ class FireBot(infobot.InfoBot, procbot.ProcBot):
|
||||||
#bindings.append((re.compile(r"^\; *(?P<code>.+)$"), evalstr))
|
#bindings.append((re.compile(r"^\; *(?P<code>.+)$"), evalstr))
|
||||||
#msg_cat['eval'] = ('%(code)s ==> %(ret)s',)
|
#msg_cat['eval'] = ('%(code)s ==> %(ret)s',)
|
||||||
|
|
||||||
|
shorturlnotice = True
|
||||||
def shorturl(self, sender, forum, addl, match):
|
def shorturl(self, sender, forum, addl, match):
|
||||||
url = match.group('url')
|
url = match.group('url')
|
||||||
print ('url', url)
|
print ('url', url)
|
||||||
idx = shorturl.add(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])"),
|
bindings.append((re.compile(r".*\b(?P<url>\b[a-z]+://[-a-z0-9_=!?#$@~%&*+/:;.,\w]+[-a-z0-9_=#$@~%&*+/\w])"),
|
||||||
shorturl))
|
shorturl))
|
||||||
|
|
||||||
|
|
10
gallium.py
10
gallium.py
|
@ -105,10 +105,20 @@ if __name__ == '__main__':
|
||||||
firebot.URLSERVER = (socket.gethostbyaddr(socket.gethostname())[0],
|
firebot.URLSERVER = (socket.gethostbyaddr(socket.gethostname())[0],
|
||||||
us.getsockname()[1])
|
us.getsockname()[1])
|
||||||
|
|
||||||
|
# gallium
|
||||||
gallium = Gallium(('fozzie.woozle.org', 6667),
|
gallium = Gallium(('fozzie.woozle.org', 6667),
|
||||||
['gallium'],
|
['gallium'],
|
||||||
"I'm a little printf, short and stdout",
|
"I'm a little printf, short and stdout",
|
||||||
["#woozle", "#gallium"])
|
["#woozle", "#gallium"])
|
||||||
|
gallium.shorturlnotice = False
|
||||||
gallium.debug = debug
|
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)
|
irc.run_forever(0.5)
|
||||||
|
|
19
shorturl.py
19
shorturl.py
|
@ -274,13 +274,15 @@ class URLHandler(HTTPHandler):
|
||||||
if self.path == '/':
|
if self.path == '/':
|
||||||
self.list_urls()
|
self.list_urls()
|
||||||
return
|
return
|
||||||
|
elif self.path == '/newest':
|
||||||
try:
|
url = URLS[-1]
|
||||||
idx = int(self.path[1:])
|
else:
|
||||||
url = URLS[idx]
|
try:
|
||||||
except (ValueError, IndexError):
|
idx = int(self.path[1:])
|
||||||
self.send_error(404)
|
url = URLS[idx]
|
||||||
return
|
except (ValueError, IndexError):
|
||||||
|
self.send_error(404)
|
||||||
|
return
|
||||||
|
|
||||||
self.send_response(301)
|
self.send_response(301)
|
||||||
self.send_header('Location', url)
|
self.send_header('Location', url)
|
||||||
|
@ -297,7 +299,8 @@ class URLHandler(HTTPHandler):
|
||||||
self.send_header('Content-Type', 'text/html')
|
self.send_header('Content-Type', 'text/html')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.send('<title>URLs</title><h1>URLs</h1><ol>\n')
|
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('<li><a href="%s">%s</a></li>\n' % (url, url))
|
||||||
self.send('</ol>\n')
|
self.send('</ol>\n')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue