2011-01-07 09:54:51 -06:00
|
|
|
"""
|
|
|
|
DrBotIRC - customizations of irclib, for dr.botzo
|
|
|
|
Copyright (C) 2011 Brian S. Stephan
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
|
2011-01-08 00:32:46 -06:00
|
|
|
import bisect
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
from ConfigParser import NoOptionError, NoSectionError
|
|
|
|
import re
|
|
|
|
import signal
|
2011-01-07 09:54:51 -06:00
|
|
|
import socket
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
import sys
|
2011-01-07 09:54:51 -06:00
|
|
|
|
|
|
|
from extlib import irclib
|
|
|
|
|
|
|
|
class DrBotServerConnection(irclib.ServerConnection):
|
|
|
|
|
|
|
|
"""Subclass irclib's ServerConnection, in order to expand privmsg."""
|
|
|
|
|
2011-01-08 00:05:00 -06:00
|
|
|
nickmask = None
|
2011-01-07 23:56:51 -06:00
|
|
|
|
|
|
|
def __init__(self, irclibobj):
|
|
|
|
irclib.ServerConnection.__init__(self, irclibobj)
|
|
|
|
|
|
|
|
# temporary. hopefully on_welcome() will set this
|
2011-01-08 00:05:00 -06:00
|
|
|
self.nickmask = socket.getfqdn()
|
2011-01-07 23:56:51 -06:00
|
|
|
|
|
|
|
self.add_global_handler('welcome', self.on_welcome, 1)
|
|
|
|
|
|
|
|
def on_welcome(self, connection, event):
|
2011-01-08 00:05:00 -06:00
|
|
|
"""Set the nickmask that the ircd tells us is us."""
|
2011-01-07 23:56:51 -06:00
|
|
|
what = event.arguments()[0]
|
|
|
|
|
|
|
|
match = re.search('(\S+!\S+@\S+)', what)
|
|
|
|
if match:
|
2011-01-08 00:05:00 -06:00
|
|
|
self.nickmask = match.group(1)
|
2011-01-07 23:56:51 -06:00
|
|
|
|
2011-01-07 09:54:51 -06:00
|
|
|
def privmsg(self, target, text):
|
|
|
|
"""Send a PRIVMSG command."""
|
|
|
|
|
|
|
|
splitter = "..."
|
|
|
|
|
|
|
|
# split messages that are too long. Max length is 512.
|
2011-01-08 00:05:00 -06:00
|
|
|
# TODO: this does not properly handle when the nickmask has been
|
2011-01-07 09:54:51 -06:00
|
|
|
# masked by the ircd
|
2011-01-07 23:56:51 -06:00
|
|
|
# is the above still the case?
|
2011-01-08 00:05:00 -06:00
|
|
|
space = 512 - len('\r\n') - len(' PRIVMSG ') - len(target) - len(' :') - len(self.nickmask) - len(' :')
|
2011-01-07 09:54:51 -06:00
|
|
|
splitspace = space - (len(splitter) + 1)
|
|
|
|
|
|
|
|
if len(text) > space:
|
|
|
|
times = 1
|
|
|
|
|
|
|
|
while len(text) > splitspace:
|
|
|
|
splitpos = text.rfind(' ', 0, splitspace)
|
|
|
|
splittext = text[0:splitpos] + ' ' + splitter
|
|
|
|
text = splitter + ' ' + text[splitpos+1:]
|
|
|
|
self.send_raw("PRIVMSG %s :%s" % (target, splittext))
|
|
|
|
|
|
|
|
times = times + 1
|
|
|
|
if times >= 4:
|
|
|
|
return
|
|
|
|
|
|
|
|
# done splitting
|
|
|
|
self.send_raw("PRIVMSG %s :%s" % (target, text))
|
|
|
|
else:
|
|
|
|
self.send_raw("PRIVMSG %s :%s" % (target, text))
|
|
|
|
|
|
|
|
class DrBotIRC(irclib.IRC):
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
"""Implement a customized irclib IRC."""
|
|
|
|
|
|
|
|
modlist = []
|
2011-01-08 00:32:46 -06:00
|
|
|
internal_bus = []
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
config = None
|
|
|
|
server = None
|
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
irclib.IRC.__init__(self)
|
|
|
|
|
|
|
|
self.config = config
|
|
|
|
|
|
|
|
# handle SIGINT
|
|
|
|
signal.signal(signal.SIGINT, self.sigint_handler)
|
2011-01-07 09:54:51 -06:00
|
|
|
|
|
|
|
def server(self):
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
"""Create a DrBotServerConnection."""
|
|
|
|
self.server = DrBotServerConnection(self)
|
|
|
|
self.connections.append(self.server)
|
|
|
|
|
|
|
|
self.server.add_global_handler('pubmsg', self.on_pubmsg, 1)
|
|
|
|
self.server.add_global_handler('privmsg', self.on_pubmsg, 1)
|
|
|
|
|
|
|
|
return self.server
|
|
|
|
|
|
|
|
def on_pubmsg(self, connection, event):
|
|
|
|
"""See if there is an alias ("!command") in the text, and if so, translate it into
|
|
|
|
an internal bot command and run it.
|
|
|
|
"""
|
|
|
|
|
|
|
|
nick = irclib.nm_to_n(event.source())
|
|
|
|
userhost = irclib.nm_to_uh(event.source())
|
|
|
|
replypath = event.target()
|
|
|
|
what = event.arguments()[0]
|
|
|
|
admin_unlocked = False
|
|
|
|
|
2011-01-07 21:14:14 -06:00
|
|
|
# privmsg
|
|
|
|
if replypath == connection.get_nickname():
|
|
|
|
replypath = nick
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
try:
|
|
|
|
if userhost == self.config.get('dr.botzo', 'admin_userhost'):
|
|
|
|
admin_unlocked = True
|
|
|
|
except NoOptionError: pass
|
|
|
|
|
|
|
|
# first see if the aliases are being directly manipulated via add/remove
|
|
|
|
whats = what.split(' ')
|
|
|
|
try:
|
|
|
|
if whats[0] == '!alias' and whats[1] == 'add' and len(whats) >= 4:
|
|
|
|
if not self.config.has_section('Alias'):
|
|
|
|
self.config.add_section('Alias')
|
|
|
|
|
|
|
|
self.config.set('Alias', whats[2], ' '.join(whats[3:]))
|
|
|
|
replystr = 'Added alias ' + whats[2] + '.'
|
|
|
|
return self.reply(connection, replypath, replystr)
|
|
|
|
if whats[0] == '!alias' and whats[1] == 'remove' and len(whats) >= 3:
|
|
|
|
if not self.config.has_section('Alias'):
|
|
|
|
self.config.add_section('Alias')
|
|
|
|
|
|
|
|
if self.config.remove_option('Alias', whats[2]):
|
|
|
|
replystr = 'Removed alias ' + whats[2] + '.'
|
|
|
|
return self.reply(connection, replypath, replystr)
|
|
|
|
elif whats[0] == '!alias' and whats[1] == 'list':
|
|
|
|
try:
|
|
|
|
if len(whats) > 2:
|
|
|
|
alias = self.config.get('Alias', whats[2])
|
|
|
|
return self.reply(connection, replypath, alias)
|
|
|
|
else:
|
|
|
|
alist = self.config.options('Alias')
|
2011-01-07 20:36:42 -06:00
|
|
|
alist.remove('debug')
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
alist.sort()
|
|
|
|
liststr = ', '.join(alist)
|
|
|
|
return self.reply(connection, replypath, liststr)
|
|
|
|
except NoSectionError: pass
|
|
|
|
except NoOptionError: pass
|
|
|
|
except NoSectionError: pass
|
|
|
|
|
2011-01-07 23:09:07 -06:00
|
|
|
return self.reply(connection, replypath, self.try_recursion(connection, event, nick, userhost, what, admin_unlocked))
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
|
2011-01-07 23:09:07 -06:00
|
|
|
def try_alias(self, connection, event, nick, userhost, what, admin_unlocked):
|
2011-01-07 22:34:27 -06:00
|
|
|
# try doing alias work
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
try:
|
|
|
|
alias_list = self.config.options('Alias')
|
|
|
|
|
|
|
|
for alias in alias_list:
|
|
|
|
alias_re = re.compile(alias)
|
|
|
|
if alias_re.search(what):
|
|
|
|
# we found an alias for our given string, doing a replace
|
|
|
|
command = re.sub(alias, self.config.get('Alias', alias), what)
|
|
|
|
|
2011-01-07 22:31:30 -06:00
|
|
|
# i guess someone could have an alias of an alias... try again
|
2011-01-07 23:09:07 -06:00
|
|
|
command = self.try_alias(connection, event, nick, userhost, command, admin_unlocked)
|
|
|
|
return command
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
except NoOptionError: pass
|
|
|
|
except NoSectionError: pass
|
|
|
|
|
|
|
|
# if we got here, there are no matching aliases, so return what we got
|
2011-01-07 23:09:07 -06:00
|
|
|
return what
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
|
|
|
|
def reply(self, connection, replypath, replystr, stop_responding=False):
|
2011-01-07 23:09:07 -06:00
|
|
|
"""Reply over IRC to replypath or return a string with the reply."""
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
|
|
|
|
if replystr is not None:
|
|
|
|
if replypath is None:
|
|
|
|
return replystr
|
|
|
|
else:
|
2011-01-08 14:40:01 -06:00
|
|
|
replies = replystr.split('\n')
|
|
|
|
for reply in replies:
|
|
|
|
connection.privmsg(replypath, reply)
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
if stop_responding:
|
|
|
|
return "NO MORE"
|
|
|
|
|
2011-01-07 23:09:07 -06:00
|
|
|
def try_recursion(self, connection, event, nick, userhost, what, admin_unlocked):
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
"""Scan message for subcommands to execute and use as part of this command.
|
|
|
|
|
|
|
|
Upon seeing a line intended for this module, see if there are subcommands
|
|
|
|
that we should do what is basically a text replacement on. The intent is to
|
|
|
|
allow things like the following:
|
|
|
|
|
|
|
|
command arg1 [anothercommand arg1 arg2]
|
|
|
|
|
|
|
|
where the output of anothercommand is command's arg2..n.
|
|
|
|
"""
|
|
|
|
|
|
|
|
attempt = what
|
2011-01-07 22:31:30 -06:00
|
|
|
|
|
|
|
# check for aliases
|
2011-01-07 23:09:07 -06:00
|
|
|
attempt = self.try_alias(connection, event, nick, userhost, attempt, admin_unlocked)
|
2011-01-07 22:31:30 -06:00
|
|
|
|
|
|
|
# begin recursion search
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
start_idx = attempt.find('[')
|
|
|
|
subcmd = attempt[start_idx+1:]
|
|
|
|
end_idx = subcmd.rfind(']')
|
|
|
|
subcmd = subcmd[:end_idx]
|
|
|
|
|
|
|
|
if start_idx == -1 or end_idx == -1 or len(subcmd) == 0:
|
2011-01-07 22:31:30 -06:00
|
|
|
# no recursion, so see if there's a module to handle this
|
2011-01-07 23:09:07 -06:00
|
|
|
return self.scan_modules(connection, event, nick, userhost, attempt, admin_unlocked)
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
else:
|
2011-01-07 22:31:30 -06:00
|
|
|
# found recursion, search again
|
2011-01-07 23:09:07 -06:00
|
|
|
ret = self.try_recursion(connection, event, nick, userhost, subcmd, admin_unlocked)
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
if ret is not None:
|
2011-01-07 22:31:30 -06:00
|
|
|
# recursion search had a hit, replace [foo] with it and re-recurse
|
2011-01-07 23:09:07 -06:00
|
|
|
return self.try_recursion(connection, event, nick, userhost, attempt.replace('['+subcmd+']', ret), admin_unlocked)
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
else:
|
2011-01-07 22:31:30 -06:00
|
|
|
# recursion search didn't have a hit, so see if there's a module to handle this
|
2011-01-07 23:09:07 -06:00
|
|
|
return self.scan_modules(connection, event, nick, userhost, attempt, admin_unlocked)
|
2011-01-07 22:31:30 -06:00
|
|
|
|
2011-01-07 23:09:07 -06:00
|
|
|
def scan_modules(self, connection, event, nick, userhost, attempt, admin_unlocked):
|
2011-01-07 22:31:30 -06:00
|
|
|
"""Walk the loaded modules, see if any reply to input text."""
|
|
|
|
|
|
|
|
# aliases resolved. run result against each module
|
2011-01-08 00:32:46 -06:00
|
|
|
for (priority, handler) in self.internal_bus:
|
|
|
|
ret = handler(connection, event, nick, userhost, attempt, admin_unlocked)
|
2011-01-07 22:31:30 -06:00
|
|
|
if ret is not None:
|
|
|
|
# a module had a result for us, post-alias, so return it
|
|
|
|
# TODO: scan all modules with compounding results
|
2011-01-07 23:09:07 -06:00
|
|
|
return ret
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
|
|
|
|
def quit_irc(self, connection, msg):
|
|
|
|
for module in self.modlist:
|
2011-01-08 00:44:37 -06:00
|
|
|
module.save()
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
module.shutdown()
|
|
|
|
|
|
|
|
connection.quit(msg)
|
2011-01-08 00:44:37 -06:00
|
|
|
print(self.save_config())
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
sys.exit()
|
|
|
|
|
2011-01-08 00:49:10 -06:00
|
|
|
def save_modules(self):
|
|
|
|
for module in self.modlist:
|
|
|
|
module.save()
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
def save_config(self):
|
|
|
|
with open('dr.botzo.cfg', 'w') as cfg:
|
|
|
|
self.config.write(cfg)
|
|
|
|
|
2011-01-08 00:44:37 -06:00
|
|
|
return 'Saved config.'
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
|
|
|
|
def load_module(self, modname):
|
|
|
|
"""Load a module (in both the python and dr.botzo sense) if not
|
|
|
|
already loaded.
|
|
|
|
"""
|
|
|
|
|
|
|
|
for module in self.modlist:
|
|
|
|
if modname == module.__class__.__name__:
|
|
|
|
return 'Module ' + modname + ' is already loaded.'
|
|
|
|
|
|
|
|
# not loaded, let's get to work
|
|
|
|
try:
|
|
|
|
modstr = 'modules.'+modname
|
|
|
|
__import__(modstr)
|
|
|
|
module = sys.modules[modstr]
|
|
|
|
botmod = eval('module.' + modname + '(self, self.config, self.server)')
|
|
|
|
self.modlist.append(botmod)
|
2011-01-08 00:32:46 -06:00
|
|
|
bisect.insort(self.internal_bus, (botmod.priority(), botmod.do))
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
botmod.register_handlers(self.server)
|
|
|
|
|
|
|
|
# might as well add it to the list
|
|
|
|
modset = set(self.config.get('dr.botzo', 'module_list').split(','))
|
|
|
|
modset.add(modname)
|
|
|
|
self.config.set('dr.botzo', 'module_list', ','.join(modset))
|
|
|
|
|
|
|
|
return 'Module ' + modname + ' loaded.'
|
|
|
|
except ImportError:
|
|
|
|
return 'Module ' + modname + ' not found.'
|
|
|
|
|
|
|
|
def unload_module(self, modname):
|
|
|
|
"""Attempt to unload and del a module if it's loaded."""
|
|
|
|
|
|
|
|
modstr = 'modules.'+modname
|
|
|
|
for module in self.modlist:
|
|
|
|
if modname == module.__class__.__name__:
|
|
|
|
# do anything the module needs to do to clean up
|
2011-01-08 00:44:37 -06:00
|
|
|
module.save()
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
module.shutdown()
|
|
|
|
|
|
|
|
# remove module references
|
|
|
|
self.modlist.remove(module)
|
2011-01-08 00:32:46 -06:00
|
|
|
self.internal_bus.remove((module.priority(), module.do))
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
module.unregister_handlers()
|
|
|
|
|
|
|
|
# del it
|
|
|
|
del(sys.modules[modstr])
|
|
|
|
del(module)
|
|
|
|
|
|
|
|
# might as well remove it from the list
|
|
|
|
modset = set(self.config.get('dr.botzo', 'module_list').split(','))
|
|
|
|
modset.remove(modname)
|
|
|
|
self.config.set('dr.botzo', 'module_list', ','.join(modset))
|
|
|
|
|
|
|
|
return 'Module ' + modname + ' unloaded.'
|
|
|
|
|
|
|
|
# guess it was never loaded
|
|
|
|
return 'Module ' + modname + ' is not loaded.'
|
|
|
|
|
|
|
|
def reload_module(self, modname):
|
|
|
|
"""Attempt to reload a module, by removing it from memory and then
|
|
|
|
re-initializing it.
|
|
|
|
"""
|
|
|
|
|
|
|
|
ret = self.unload_module(modname)
|
|
|
|
if ret == 'Module ' + modname + ' unloaded.':
|
|
|
|
ret = self.load_module(modname)
|
|
|
|
if ret == 'Module ' + modname + ' loaded.':
|
|
|
|
return 'Module ' + modname + ' reloaded.'
|
|
|
|
|
|
|
|
return 'Module ' + modname + ' reload failed. Check the console.'
|
|
|
|
|
2011-01-08 01:22:31 -06:00
|
|
|
def list_modules(self):
|
|
|
|
"""List loaded modules."""
|
|
|
|
|
|
|
|
modnames = []
|
|
|
|
for module in self.modlist:
|
|
|
|
modnames.append(module.__class__.__name__)
|
|
|
|
|
|
|
|
return modnames
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
# SIGINT signal handler
|
|
|
|
def sigint_handler(self, signal, frame):
|
2011-01-08 00:44:37 -06:00
|
|
|
for module in self.modlist:
|
|
|
|
module.save()
|
|
|
|
module.shutdown()
|
|
|
|
|
migrate some code that became pivotal to the bot into DrBotIRC.
this is a big change. DrBotIrc is now in charge of module loading
and unloading, aliases, and recursion. the Alias module is no more,
and a bunch of functionality was moved out of IrcAdmin, including
also config file saving, the sigint handler, and quitting the bot.
additionally, a lot of stuff got caught in the wake. dr.botzo.py
is simpler now, and lets DrBotIRC do the dynamic loading stuff.
Module.__init__ changed, modules no longer get modlist and instead
get a reference to the DrBotIRC object. IrcAdmin still has the same
exposed methods, but now calls out to DrBotIRC to achieve some of
them.
naturally, a recursion/alias rewrite was included with this change.
it is clearer now (i think), but probably brittle somewhere.
additionally, currently any module that has registered a pubmsg
handler can potentially fire more than once on one input (without
recursion). this may be the next thing to fix. do() may need to
be split, or maybe it's time to stop having modules deal with
pubmsg/privmsg entirely. need to decide.
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
2011-01-07 17:38:26 -06:00
|
|
|
print(self.save_config())
|
|
|
|
sys.exit()
|
2011-01-07 09:54:51 -06:00
|
|
|
|
|
|
|
# vi:tabstop=4:expandtab:autoindent
|
|
|
|
# kate: indent-mode python;indent-width 4;replace-tabs on;
|