Commit Graph

16 Commits

Author SHA1 Message Date
Brian S. Stephan 2aa369add7 rewrite recursion/alias code for the 500th time.
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
2011-02-17 01:08:45 -06:00
Brian S. Stephan c4ade3cbca catch all Exception when calling the handlers, to avoid a crash there.
this used to be in the bot before we moved this code around
2011-01-19 10:21:14 -06:00
Brian S. Stephan 649e183337 allow for newlines in DrBotIRC.reply(), split on them for multiple lines of output 2011-01-08 14:40:01 -06:00
Brian S. Stephan a6c7b6b0b2 list loaded modules in DrBotIRC, display it via IrcAdmin 2011-01-08 01:22:31 -06:00
Brian S. Stephan 3e533890a1 IrcAdmin: following the last change to saving, have !save also call a new save_modules() 2011-01-08 00:49:10 -06:00
Brian S. Stephan faf37447cf make the module saving a bit more consistent 2011-01-08 00:44:37 -06:00
Brian S. Stephan 015fe87e1a implement priority in calling do().
store module.do instead of module, making this an awful lot like
an internal command bus. steal a trick from irclib and sort based
on priority, while we're at it. we added priority a while ago, and
this means that low prio (high value) items are called later, meaning
we can do things like

!join #botname

and have the IrcAdmin handler handle it before MegaHAL gets to it
2011-01-08 00:32:46 -06:00
Brian S. Stephan c23b59d705 improve upon the splitting (which was excessive following the last commit).
clarify the terminology a bit, too
2011-01-08 00:05:00 -06:00
Brian S. Stephan bf7074b76e use a welcome handler to capture the bot's nickmask.
we do this deep in the server in order to have the split functionality
use it properly. i still don't know if it handles server privacy
masks properly (which would only be noticed if that cloak is sent
when you connect).

actually, on that note, this only works if the ircd sends the
nickmask in 001. but hey, it works on one server at least
2011-01-07 23:56:51 -06:00
Brian S. Stephan 359ca24856 remove replypath and all the places it was used.
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.
2011-01-07 23:09:07 -06:00
Brian S. Stephan a234807335 move !alias manipulation commands out of try_alias and into the pubmsg/privmsg handler 2011-01-07 22:34:27 -06:00
Brian S. Stephan 4cac5f1a93 fixes and improvements to recursion and alias support 2011-01-07 22:31:30 -06:00
Brian S. Stephan 516940630c hack the replypath to the sender, if we're handling a privmsg 2011-01-07 21:14:14 -06:00
Brian S. Stephan 6b2af47552 don't display 'debug' in the alias list 2011-01-07 20:36:42 -06:00
Brian S. Stephan 01d3c7c80c 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
Brian S. Stephan 4d6228b93a move DrBotIRC into a separate file, since we will probably be hacking more on it soon 2011-01-07 09:54:51 -06:00