mirror of https://github.com/nealey/firebot
Including wii tracker
This commit is contained in:
parent
9da0e88ea8
commit
88d896f783
|
@ -33,8 +33,9 @@ class Arsenic(firebot.FireBot, ProcBot):
|
||||||
|
|
||||||
def runcmd(self, sender, forum, addl, match):
|
def runcmd(self, sender, forum, addl, match):
|
||||||
command = match.group('command')
|
command = match.group('command')
|
||||||
args = lesc(match.group('args').split(' '))
|
args = lesc(lesc(match.group('args').split(' ')))
|
||||||
argstr = ' '.join(args)
|
argstr = ' '.join(args)
|
||||||
|
print argstr
|
||||||
Runner('%s %s' % (command, argstr),
|
Runner('%s %s' % (command, argstr),
|
||||||
lambda l,r: self.proc_cb('%s: ' % command, sender, forum, l, r))
|
lambda l,r: self.proc_cb('%s: ' % command, sender, forum, l, r))
|
||||||
bindings.append((re.compile(r"^(?P<command>whois) +(?P<args>.*)$"),
|
bindings.append((re.compile(r"^(?P<command>whois) +(?P<args>.*)$"),
|
||||||
|
@ -142,7 +143,7 @@ class Arsenic(firebot.FireBot, ProcBot):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import daemon
|
import daemon
|
||||||
|
|
||||||
debug = False
|
debug = True
|
||||||
|
|
||||||
if not debug:
|
if not debug:
|
||||||
# Become a daemon
|
# Become a daemon
|
||||||
|
|
|
@ -260,7 +260,8 @@ class FireBot(infobot.InfoBot, procbot.ProcBot):
|
||||||
def generic_cmd(self, sender, forum, addl, match):
|
def generic_cmd(self, sender, forum, addl, match):
|
||||||
cmd = match.group('cmd')
|
cmd = match.group('cmd')
|
||||||
args = match.group('args').split(' ')
|
args = match.group('args').split(' ')
|
||||||
argstr = ' '.join(procbot.lesc(args))
|
args = procbot.lesc(args)
|
||||||
|
argstr = ' '.join(args)
|
||||||
Runner('%s %s' % (cmd, argstr),
|
Runner('%s %s' % (cmd, argstr),
|
||||||
lambda l,r: self.proc_cb(None, sender, forum, l, r))
|
lambda l,r: self.proc_cb(None, sender, forum, l, r))
|
||||||
bindings.append((re.compile(r"^(?P<cmd>host) (?P<args>.+)$"),
|
bindings.append((re.compile(r"^(?P<cmd>host) (?P<args>.+)$"),
|
||||||
|
|
64
gallium.py
64
gallium.py
|
@ -6,14 +6,9 @@ import irc
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import feedparser
|
||||||
from procbot import ProcBot, Runner
|
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):
|
class Gallium(firebot.FireBot, ProcBot):
|
||||||
opall = False
|
opall = False
|
||||||
bindings = []
|
bindings = []
|
||||||
|
@ -70,21 +65,36 @@ class Gallium(firebot.FireBot, ProcBot):
|
||||||
bindings.append((re.compile(r"^u\+rand$"),
|
bindings.append((re.compile(r"^u\+rand$"),
|
||||||
randglyph))
|
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)
|
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__':
|
if __name__ == '__main__':
|
||||||
import shorturl
|
import shorturl
|
||||||
import socket
|
import socket
|
||||||
|
@ -106,19 +116,19 @@ if __name__ == '__main__':
|
||||||
us.getsockname()[1])
|
us.getsockname()[1])
|
||||||
|
|
||||||
# gallium
|
# gallium
|
||||||
gallium = Gallium(('fozzie.woozle.org', 6667),
|
gallium = Wiibot(('localhost', 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.shorturlnotice = False
|
||||||
gallium.debug = debug
|
gallium.debug = debug
|
||||||
|
|
||||||
# fink
|
# fink
|
||||||
fink = Gallium(('irc.oftc.net', 6667),
|
fink = Wiibot(('irc.oftc.net', 6667),
|
||||||
['fink'],
|
['fink'],
|
||||||
"Do you like my hat?",
|
"Do you like my hat?",
|
||||||
["#fast-food"],
|
["#fast-food"],
|
||||||
dbname='fink.cdb')
|
dbname='fink.cdb')
|
||||||
fink.debug = debug
|
fink.debug = debug
|
||||||
|
|
||||||
irc.run_forever(0.5)
|
irc.run_forever(0.5)
|
||||||
|
|
|
@ -169,6 +169,15 @@ class InfoBot(BindingsBot):
|
||||||
bindings.append((re.compile(r"^\008[,: ]+unlock (?P<key>.+)$", re.IGNORECASE),
|
bindings.append((re.compile(r"^\008[,: ]+unlock (?P<key>.+)$", re.IGNORECASE),
|
||||||
unlock_entry))
|
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
|
# Literal entry
|
||||||
def literal(self, sender, forum, addl, match):
|
def literal(self, sender, forum, addl, match):
|
||||||
key = match.group('key')
|
key = match.group('key')
|
||||||
|
|
Loading…
Reference in New Issue