Commit Graph

49 Commits

Author SHA1 Message Date
Brian S. Stephan 8d6d66333b Module: don't pass DrBotServerConnection to init
another "this is unnecessary" change, obviously impacting all the
modules that override __init__ as well as the base class. again, they
can use the DrBotIRC instance for anything, which is (with one
exception) only for add/remove_global_handler, which i'm planning on
working my way off of anyway
2012-12-19 21:06:53 -06:00
Brian S. Stephan 3e76f75bba Module: remove reply(), use DrBotIRC's
obviously this means all of the modules changed to accomodate. this is
one of many steps to reduce the number of times we pass connections and
servers and other such info around, when it's mostly unnecessary because
modules have a reference to DrBotIRC
2012-12-19 20:51:35 -06:00
Brian S. Stephan e4225abba4 DrBotIRC: remove connection argument from reply()
we only have one connection, we don't need to be told what to reply to
2012-12-19 20:32:18 -06:00
Brian S. Stephan 456671615b DrBotIRC: document irclib.IRC.connections
this is before i stupidly remove it again
2012-12-19 20:22:48 -06:00
Brian S. Stephan 582328973e DrBotIRC: use config nick/user to guess nickhost
we still override the nickhost guess with what comes out of the ircd's
welcome message, if it is a full nick!user@host (although now i'm
doubting if we should expect such a thing or if it was just unrealircd
being nice), but this produces more accurate guesses for the cases where
we don't do that override. this was affecting splitting
2012-12-19 15:12:57 -06:00
Brian S. Stephan a10e54bcc8 DrBotIRC: properly debug log welcome events
my git surgery failed me
2012-12-19 00:09:28 -06:00
Brian S. Stephan ebfeafe87b DrBotIRC: use format() rather than string concat
a couple other generic ' vs. " show up here too
2012-12-18 22:32:11 -06:00
Brian S. Stephan bf8a7e6453 DrBotIRC: module-wide logger rather than per-class
a couple formatting changes are caught in the wake of this change, and
NASFWG
2012-12-18 22:30:31 -06:00
Brian S. Stephan f30e1fd308 DrBotIRC: remove some unused imports 2012-12-18 22:17:04 -06:00
Brian S. Stephan da430981be DrBotIRC: docstring/comment cleanups
this is some of the oldest code in the bot, there's probably a lot more
that could be cleaned up (and, indeed, some upcoming commits do some of
that)
2012-12-18 22:15:52 -06:00
Brian S. Stephan b1d2e06639 DrBotIRC: don't log XML-RPC requests 2012-07-28 09:55:54 -05:00
Brian S. Stephan f8674db4a9 DrBotIRC: log exceptions sanely 2012-07-26 21:20:26 -05:00
Brian S. Stephan d14ed69916 DrBotIRC: improve logging when failing to load a module 2012-07-26 20:25:55 -05:00
Brian S. Stephan 2a0cd05cbc DrBotIRC: rename logger to drbotzo for clarity's sake 2012-07-26 20:13:05 -05:00
Brian S. Stephan 92555867f5 DrBotIRC: log when shutting down 2012-07-15 21:48:33 -05:00
Brian S. Stephan 9654f4de98 switch to use python's logging, with config file i'm not entirely happy about 2012-07-15 21:32:12 -05:00
Brian S. Stephan 0b51eb88a8 DrBotIRC: better printing of exceptions 2012-07-14 09:16:59 -05:00
Brian S. Stephan d50b0867e8 DrBotIRC: bring reply() back to the base server, for use in alias 2012-07-10 17:18:35 -05:00
Brian S. Stephan 1aa7a542f2 DrBotIRC: only register a function if there's an xmlrpc server loaded 2012-03-30 17:25:46 -05:00
Brian S. Stephan 731aec8c0c DrBotIRC, Facts: clean up some method header doc since it shows up in XML-RPC 2012-03-30 11:14:31 -05:00
Brian S. Stephan e16d698d0e DrBotIRC: add method to register a function to the XML-RPC server
this appears to be safe to do while the other thread is doing serve_forever()
2012-03-30 10:17:13 -05:00
Brian S. Stephan 05a3bd0af7 move XML-RPC support into DrBotIRC so everything can eventually use it 2012-03-30 09:43:30 -05:00
Brian S. Stephan 07744a0f66 indicate recursion better by adding _recursing to Event
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
2012-03-29 20:07:32 -05:00
Brian S. Stephan 341066a0ba DrBotIRC: when doing ignore checks, lowercase the input nick, since that's what the config module does 2012-03-07 22:48:30 -06:00
Brian S. Stephan ef9b80d86f DrBotIRC: add support for ignoring all events from a nick
rudimentary for the moment. pop something like this in your config:

[Ignore]
nick_to_ignore = 1
2012-03-01 22:00:42 -06:00
Brian S. Stephan b82dd382ee DrBotIRC: swallow the rare exception that trickles up this far 2011-10-18 00:48:11 -05:00
Brian S. Stephan 75ba29739c don't treat the string 'debug' as an alias from the config file
stuff like '!echo debug' would result in 'false'. oops
2011-06-20 20:05:03 -05:00
Brian S. Stephan 1a69610785 Alias: fix ^!alias$ == crash bug 2011-06-14 22:40:45 -05:00
Brian S. Stephan aa6ea083fd remove reload support, since it was broken in the first place (somehow) 2011-04-27 22:49:04 -05:00
Brian S. Stephan be4763f6a5 DrBotIRC: fix an !alias add thinko with event handling ordering
before, !alias commands were handled via an on_pubmsg() in DrBotIRC,
which meant they happened (due to refactoring) after alias and
recursion scanning happened in a more low-level routine.

thus, if you were trying to add an alias that had recursion in it,
your alias would be the outcome of that recursion, not the command
to recurse. oops
2011-04-27 22:11:37 -05:00
Brian S. Stephan fca716af9e allow for multiple modules to respond to recursion text 2011-02-17 12:01:32 -06:00
Brian S. Stephan f4d69c90d4 Alias: don't crash when doing alias info output because i forgot to update the reply calls. 2011-02-17 10:07:29 -06:00
Brian S. Stephan 04c5a641d1 Alias: ignore case in alias search 2011-02-17 09:38:41 -06:00
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