mirror of https://github.com/nealey/firebot
Merge branch 'master' of /home/neale/public_html/repos/firebot
This commit is contained in:
commit
6ef32e3368
39
arsenic.py
39
arsenic.py
|
@ -10,6 +10,7 @@ import re
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
|
import rp
|
||||||
|
|
||||||
def esc(arg):
|
def esc(arg):
|
||||||
return "'" + arg.replace("'", r"'\''") + "'"
|
return "'" + arg.replace("'", r"'\''") + "'"
|
||||||
|
@ -21,7 +22,7 @@ class Arsenic(firebot.FireBot, ProcBot):
|
||||||
debug = False
|
debug = False
|
||||||
bindings = []
|
bindings = []
|
||||||
ping_interval = 120
|
ping_interval = 120
|
||||||
chatty = False # #x can't play nice
|
chatty = True # Maybe #x can play nice now
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
firebot.FireBot.__init__(self, *args, **kwargs)
|
firebot.FireBot.__init__(self, *args, **kwargs)
|
||||||
|
@ -44,12 +45,16 @@ class Arsenic(firebot.FireBot, ProcBot):
|
||||||
runcmd))
|
runcmd))
|
||||||
|
|
||||||
def rp(self, sender, forum, addl, match):
|
def rp(self, sender, forum, addl, match):
|
||||||
command = 'rp'
|
long = match.group('long') and True
|
||||||
argstr = match.group('args')
|
conn = rp.make_connection()
|
||||||
Finger(('db.nic.lanl.gov', 5833),
|
rows = rp.rp(match.group('args').strip(), conn=conn)
|
||||||
argstr,
|
ret = rp.format(rows, long=long)
|
||||||
lambda l: self.proc_cb('%s: ' % command, sender, forum, l, 0))
|
if long:
|
||||||
bindings.append((re.compile(r"^(?P<command>rp) +(?P<args>.*)$"),
|
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))
|
rp))
|
||||||
|
|
||||||
def finger(self, sender, forum, addl, match):
|
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"),
|
bindings.append((re.compile(r"^\008[,: ]+ (what is the )?(server )?lag"),
|
||||||
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)
|
bindings.extend(firebot.FireBot.bindings)
|
||||||
|
|
||||||
|
@ -142,8 +132,11 @@ class Arsenic(firebot.FireBot, ProcBot):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import daemon
|
import daemon
|
||||||
|
import sys
|
||||||
|
|
||||||
debug = True
|
debug = False
|
||||||
|
if "-d" in sys.argv:
|
||||||
|
debug = True
|
||||||
|
|
||||||
if not debug:
|
if not debug:
|
||||||
# Become a daemon
|
# Become a daemon
|
||||||
|
|
|
@ -2,6 +2,7 @@ import irc
|
||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
import types
|
import types
|
||||||
|
import os
|
||||||
|
|
||||||
class Match:
|
class Match:
|
||||||
"""A wrapper around a regex match, to replace \008 with a word.
|
"""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"""
|
"""Save the traceback for later inspection"""
|
||||||
irc.Bot.err(self, exception)
|
irc.Bot.err(self, exception)
|
||||||
t,v,tb = exception
|
t,v,tb = exception
|
||||||
tbinfo = []
|
info = []
|
||||||
while 1:
|
while 1:
|
||||||
tbinfo.append ((
|
info.append('%s:%d(%s)' % (os.path.basename(tb.tb_frame.f_code.co_filename),
|
||||||
tb.tb_frame.f_code.co_filename,
|
tb.tb_lineno,
|
||||||
tb.tb_frame.f_code.co_name,
|
tb.tb_frame.f_code.co_name))
|
||||||
str(tb.tb_lineno)
|
|
||||||
))
|
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
if not tb:
|
if not tb:
|
||||||
break
|
break
|
||||||
# just to be safe
|
del tb # just to be safe
|
||||||
del tb
|
infostr = '[' + '] ['.join(info) + ']'
|
||||||
file, function, line = tbinfo[-1]
|
self.last_tb = '%s %s %s' % (t, v, infostr)
|
||||||
info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']'
|
|
||||||
self.last_tb = '%s %s %s' % (t, v, info)
|
|
||||||
print self.last_tb
|
print self.last_tb
|
||||||
|
|
||||||
def matches(self, text):
|
def matches(self, text):
|
||||||
|
|
Loading…
Reference in New Issue