WARNING!
there's no going back now. this change is *huge* but it was overdue.
WARNING!
the database backend is now mysql. modules that should use a database
but don't yet were left untouched, they'll come later. scripts haven't
been converted yet, though i'm pretty sure i'll need to soon.
while i was going through everything, connection/cursor idioms were
cleaned up, as were a bunch of log messages and exception handling. this
change is so gross i'm happy things appear to be working, which is
the case --- all modules are lightly tested.
for simplicity's sake, this was added to the extlib/irclib rather
than subclassing. because i'm lazy. anyway, check that flag instead
of doing the event._target = None hack, since that hack was breaking
Markov.
for an unrelated reason (what to learn and not learn), update Markov
also remove an unused method that was getting in my way while coding this
Markov, Twitter: switch to forking a thread ourselves, and check every
second whether or not to quit. this is the "better" part above, as
now we can instantly quit the thread rather than waiting for all
the timers to fire and expire
modules that want to create a timer should implement timer_interval()
to return a non-zero value (the timer interval, in seconds) and
timer_do() (the method that does stuff)
this just sends a privmsg to the specified target on the specified
connection. pretty straightforward. also, update the modules that
need it to use it.
more of a moving of the code, actually, it now exists in (an overridden)
_handle_event, so that recursions happen against irc events directly,
rather than an already partially interpreted object.
with this change, modules don't need to implement do() nor do we have a
need for the internal_bus, which was doing an additional walk of the
modules after the irc event was already handled and turned into text. now
the core event handler does the recursion scans.
to support this, we bring back the old replypath trick and use it again,
so we know when to send a privmsg reply and when to return text so that
it may be chained in recursion. this feels old hat by now, but if you
haven't been following along, you should really look at the diff.
that's the meat of the change. the rest is updating modules to use
self.reply() and reimplementing (un)register_handlers where appropriate
Modules by default were returning None from help_description(), which
meant that they would not display in !help
Instead, return a generic not-available message. If a module really
doesn't want to display in !help, override and return None
with alias calling do() internally, there is no need for all this
replypath nonsense, and if there's ever a module that needs to reply
to stuff on its own outside of do(), it'd have to be implementing
all of this anyway, so it was pretty irrelevant.
this makes DrBotIRC alias/recursion stuff a bit cleaner.
this is possible because now the alias stuff in DrBotIRC calls
each module's do() on a pubmsg/privmsg.
this also gets rid of all the meta options (so remove them from
your config file!), and IrcAdmin now only needs to connect
to welcome.
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
this works via Module.reply(). if it produces IRC output, it returns
"NO MORE", which is returned by do(), which is returned by the handler,
which instructs irclib to cease calling handlers. now all we need
is some priorities for the modules (also supported by irclib) and
we may be in business
IrcAdmin:
* have sub_unload_module() call the module's shutdown() before deleting stuff
* sub_unload_module() needs to delete the sys.modules entry too
* slightly more verbose output in sub_unload_module()
* sub_reload_module() now does a self.sub_unload_module() + self.sub_load_module()
Module:
* remove reload() --- modules must now safely handle shutdown
as much as i find this uncouth, it is handy, and also it seems
that the megahal brain gets corrupted/unusable when an exception
isn't caught and the bot dies. this should cover most of the
cases
this comes with a recursion rewrite and simplification; it works
a bit more intuitively, now, but i still haven't figured out what
caused the bug that led me down this rabbit hole.
in any event, Alias now rules the roost when it comes to recursion,
which means it's a bit poorly named, but also means that there
won't (shouldn't) be multiple accidental runs for one output, caused
by multiple modules doing the recursion (despite only one really
having a legitimate reason to) --- a classic case of the intended
use of recursion (including the comment to only recurse when you
*know* the input is for you) being lost and forgotten with time
this also obsoletes meta.skip_recursion_scan. between this commit
and the last, people would be wise to revise their config files
* Module.py __init__ sets up sqlite db connection by default
* Module.py __init__ calls init_db() which is empty, expects subclasses to implement as necessary
* Module.py doesn't close sqlite connection by default
Changes call for a couple updates in Karma.py, namely implementing db_init
and excepting sqlite3.Error rather than closing the connection