New way to do units

This commit is contained in:
Neale Pickett 2008-10-08 10:14:08 -06:00
parent 6ef32e3368
commit d4e74f4d3b
2 changed files with 13 additions and 8 deletions

View File

@ -245,7 +245,7 @@ class FireBot(infobot.InfoBot, procbot.ProcBot):
f = '1 ' + f[2:] f = '1 ' + f[2:]
Runner('/usr/bin/units -v %s %s' % (esc(f), esc(t)), Runner('/usr/bin/units -v %s %s' % (esc(f), esc(t)),
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"^units +(?P<from>.*) +in +(?P<to>.*)$"), bindings.append((re.compile(r"^(?P<from>.*) +-> +(?P<to>.*)$"),
units)) units))
bindings.append((re.compile(r"^how many (?P<to>.*) in (?P<from>[^?]*)[?.!]*$"), bindings.append((re.compile(r"^how many (?P<to>.*) in (?P<from>[^?]*)[?.!]*$"),
units)) units))

View File

@ -36,7 +36,10 @@ class Gallium(firebot.FireBot, ProcBot):
def server_status(self, sender, forum, addl, match): def server_status(self, sender, forum, addl, match):
loadavg = file('/proc/loadavg').read().strip() loadavg = file('/proc/loadavg').read().strip()
io_status = file('/proc/io_status').read().strip() try:
io_status = file('/proc/io_status').read().strip()
except IOError:
io_status = "xen is awesome"
forum.msg('%s; load %s' % (io_status, loadavg)) forum.msg('%s; load %s' % (io_status, loadavg))
bindings.append((re.compile(r"^\008[:, ]+server status"), bindings.append((re.compile(r"^\008[:, ]+server status"),
server_status)) server_status))
@ -149,11 +152,13 @@ if __name__ == '__main__':
gallium.debug = debug gallium.debug = debug
# fink # fink
fink = Wiibot(('irc.oftc.net', 6667), if False:
['fink'], fink = Gallium(('irc.oftc.net', 6667),
"Do you like my hat?", ['fink'],
["#fast-food"], "Do you like my hat?",
dbname='fink.cdb') ["#fast-food"],
fink.debug = debug dbname='fink.cdb')
fink.debug = debug
fink.chatty = False
irc.run_forever(0.5) irc.run_forever(0.5)