Merge branch 'master' of /home/neale/public_html/repos/firebot

This commit is contained in:
Neale Pickett 2008-03-27 17:01:56 -06:00
commit 6ef32e3368
2 changed files with 24 additions and 34 deletions

View File

@ -10,6 +10,7 @@ import re
import os
import time
import socket
import rp
def esc(arg):
return "'" + arg.replace("'", r"'\''") + "'"
@ -21,7 +22,7 @@ class Arsenic(firebot.FireBot, ProcBot):
debug = False
bindings = []
ping_interval = 120
chatty = False # #x can't play nice
chatty = True # Maybe #x can play nice now
def __init__(self, *args, **kwargs):
firebot.FireBot.__init__(self, *args, **kwargs)
@ -44,12 +45,16 @@ class Arsenic(firebot.FireBot, ProcBot):
runcmd))
def rp(self, sender, forum, addl, match):
command = 'rp'
argstr = match.group('args')
Finger(('db.nic.lanl.gov', 5833),
argstr,
lambda l: self.proc_cb('%s: ' % command, sender, forum, l, 0))
bindings.append((re.compile(r"^(?P<command>rp) +(?P<args>.*)$"),
long = match.group('long') and True
conn = rp.make_connection()
rows = rp.rp(match.group('args').strip(), conn=conn)
ret = rp.format(rows, long=long)
if long:
forum.msg('[Sending privately]')
self.despool(sender, ret)
else:
self.despool(forum, ret)
bindings.append((re.compile(r"^rp +(?P<long>(-l|--long) +)?(?P<args>.*)$"),
rp))
def finger(self, sender, forum, addl, match):
@ -66,21 +71,6 @@ class Arsenic(firebot.FireBot, ProcBot):
bindings.append((re.compile(r"^\008[,: ]+ (what is the )?(server )?lag"),
lag))
def note(self, sender, forum, addl, match):
whom = match.group('whom')
what = match.group('what')
when = time.time()
key = '\013notes:%s' % whom
note = (when, sender.name(), what)
try:
n = self.db[key]
except KeyError:
n = []
n.append(note)
self.db[key] = n
forum.msg(self.gettext('okay', sender=sender.name()))
bindings.append((re.compile(r"^\008[:, ]+note (to )?(?P<whom>[^: ]+):? +(?P<what>.*)"),
note))
bindings.extend(firebot.FireBot.bindings)
@ -142,8 +132,11 @@ class Arsenic(firebot.FireBot, ProcBot):
if __name__ == '__main__':
import daemon
import sys
debug = True
debug = False
if "-d" in sys.argv:
debug = True
if not debug:
# Become a daemon

View File

@ -2,6 +2,7 @@ import irc
import re
import random
import types
import os
class Match:
"""A wrapper around a regex match, to replace \008 with a word.
@ -38,21 +39,17 @@ class BindingsBot(irc.Bot):
"""Save the traceback for later inspection"""
irc.Bot.err(self, exception)
t,v,tb = exception
tbinfo = []
info = []
while 1:
tbinfo.append ((
tb.tb_frame.f_code.co_filename,
tb.tb_frame.f_code.co_name,
str(tb.tb_lineno)
))
info.append('%s:%d(%s)' % (os.path.basename(tb.tb_frame.f_code.co_filename),
tb.tb_lineno,
tb.tb_frame.f_code.co_name))
tb = tb.tb_next
if not tb:
break
# just to be safe
del tb
file, function, line = tbinfo[-1]
info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']'
self.last_tb = '%s %s %s' % (t, v, info)
del tb # just to be safe
infostr = '[' + '] ['.join(info) + ']'
self.last_tb = '%s %s %s' % (t, v, infostr)
print self.last_tb
def matches(self, text):