This commit is contained in:
Neale Pickett 2007-12-12 13:44:06 -07:00
commit 5d26919667
4 changed files with 51 additions and 30 deletions

View File

@ -33,8 +33,9 @@ class Arsenic(firebot.FireBot, ProcBot):
def runcmd(self, sender, forum, addl, match):
command = match.group('command')
args = lesc(match.group('args').split(' '))
args = lesc(lesc(match.group('args').split(' ')))
argstr = ' '.join(args)
print argstr
Runner('%s %s' % (command, argstr),
lambda l,r: self.proc_cb('%s: ' % command, sender, forum, l, r))
bindings.append((re.compile(r"^(?P<command>whois) +(?P<args>.*)$"),
@ -142,7 +143,7 @@ class Arsenic(firebot.FireBot, ProcBot):
if __name__ == '__main__':
import daemon
debug = False
debug = True
if not debug:
# Become a daemon

View File

@ -260,7 +260,8 @@ class FireBot(infobot.InfoBot, procbot.ProcBot):
def generic_cmd(self, sender, forum, addl, match):
cmd = match.group('cmd')
args = match.group('args').split(' ')
argstr = ' '.join(procbot.lesc(args))
args = procbot.lesc(args)
argstr = ' '.join(args)
Runner('%s %s' % (cmd, argstr),
lambda l,r: self.proc_cb(None, sender, forum, l, r))
bindings.append((re.compile(r"^(?P<cmd>host) (?P<args>.+)$"),

View File

@ -6,14 +6,9 @@ import irc
import re
import os
import random
import feedparser
from procbot import ProcBot, Runner
def esc(arg):
return "'" + arg.replace("'", r"'\''") + "'"
def lesc(args):
return [esc(arg) for arg in args]
class Gallium(firebot.FireBot, ProcBot):
opall = False
bindings = []
@ -70,21 +65,36 @@ class Gallium(firebot.FireBot, ProcBot):
bindings.append((re.compile(r"^u\+rand$"),
randglyph))
def runcmd(self, sender, forum, addl, match):
command = match.group('command')
args = match.group('args').split(' ')
args = [x.replace("'", "'\\''") for x in args]
argstr = ' '.join(args)
Runner('%s %s' % (command, argstr),
lambda l,r: self.proc_cb('%s: ' % command, sender, forum, l, r))
bindings.append((re.compile(r"^(?P<command>whois) +(?P<args>.*)$"),
runcmd))
bindings.append((re.compile(r"^(?P<command>host) +(?P<args>.*)$"),
runcmd))
bindings.extend(firebot.FireBot.bindings)
class Wiibot(Gallium):
def __init__(self, *args, **kwargs):
Gallium.__init__(self, *args, **kwargs)
self.wiis = []
self.add_timer(27, self.check_wiis)
def check_wiis(self):
d = feedparser.parse('http://www.wiitracker.com/rss.xml')
try:
nt = []
for e in d.entries:
t = e.title
if 'no stock at this time' not in t:
nt.append(t)
if self.wiis != nt:
if nt:
for t in nt:
self.announce('[wii] ' + t)
else:
self.announce('[wii] No more wiis')
self.wiis = nt
except:
pass
self.add_timer(27, self.check_wiis)
if __name__ == '__main__':
import shorturl
import socket
@ -106,19 +116,19 @@ if __name__ == '__main__':
us.getsockname()[1])
# gallium
gallium = Gallium(('fozzie.woozle.org', 6667),
['gallium'],
"I'm a little printf, short and stdout",
["#woozle", "#gallium"])
gallium = Wiibot(('localhost', 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"],
dbname='fink.cdb')
fink = Wiibot(('irc.oftc.net', 6667),
['fink'],
"Do you like my hat?",
["#fast-food"],
dbname='fink.cdb')
fink.debug = debug
irc.run_forever(0.5)

View File

@ -169,6 +169,15 @@ class InfoBot(BindingsBot):
bindings.append((re.compile(r"^\008[,: ]+unlock (?P<key>.+)$", re.IGNORECASE),
unlock_entry))
def forget_and_lock(self, sender, forum, addl, match):
key = match.group('key')
self.unlock(key)
self.delete(key)
self.lock(key)
forum.msg(self.gettext('okay', key=key, sender=sender.name()))
bindings.append((re.compile(r"^\008[,: ]+forget and lock (?P<key>.+)$", re.IGNORECASE),
forget_and_lock))
# Literal entry
def literal(self, sender, forum, addl, match):
key = match.group('key')