Commit Graph

53 Commits

Author SHA1 Message Date
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 fc2814e57c don't attach to pubmsg/privmsg events by default anymore.
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.
2011-01-07 21:04:33 -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 35419f9db9 to stop responding by default is too much power for one module to wield 2011-01-07 09:19:19 -06:00
Brian S. Stephan de3f9d9ae7 provide a priority (default 50) to add_global_handler 2011-01-07 01:10:52 -06:00
Brian S. Stephan 8bec2e62a1 make it possible for a module to respond and tell irclib to stop calling other handlers.
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
2011-01-07 00:44:31 -06:00
Brian S. Stephan c1c9908d5d don't include metaopt meta.internal_only in lists (such as aliases) 2011-01-06 22:17:46 -06:00
Brian S. Stephan ea0fd9d509 small but significant unload/reload changes.
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
2011-01-06 19:54:16 -06:00
Brian S. Stephan 0878c8809d implement a save() for modules, use it in MegaHAL to sync brain to disk 2011-01-06 00:28:50 -06:00
Brian S. Stephan 377d2145fa catch all exceptions around self.do, and log to console
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
2010-12-24 13:16:09 -06:00
Brian S. Stephan f590daf5cd have all modules run a shutdown() when quitting, use it to have MegaHAL close the brain 2010-12-24 10:41:12 -06:00
Brian S. Stephan 1fe9575502 move recursion stuff out of Module.py and into modules/Alias.py
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
2010-12-16 23:43:16 -06:00
Brian S. Stephan d18b2e49ff add 'meta.internal_only' option, defaulting to true
this allows for better control on recursion/alias type things, which
is an awful lot of what the bot does these days
2010-12-16 21:06:20 -06:00
Brian S. Stephan 0db4dbb518 duh, actually call register_handlers after doing a module reload 2010-12-15 20:55:04 -06:00
Brian S. Stephan 7a9b68f2c4 remove unnecessary method, preferring register_handlers 2010-12-15 20:53:52 -06:00
Brian S. Stephan 22615d7b9a rewrite reload support, making it an IrcAdmin command
only lightly tested for the moment
2010-12-15 20:43:14 -06:00
Brian S. Stephan 914e86d567 don't try to privmsg (and then crash) if replystr is None 2010-12-08 22:18:46 -06:00
Brian S. Stephan 57b6ffa0b7 re.IGNORECASE in the regexp function compiled for sqlite 2010-11-01 22:12:14 -05:00
Brian S. Stephan b7f2b9bd0e use re.search() rather than re.match() in a couple places
(search() looks for the regex anywhere in the string whereas
match() only looks for the regex starting from the beginning)
2010-10-29 00:30:02 -05:00
Brian S. Stephan 487e997a55 define a regexp function in sqlite 2010-10-28 23:52:06 -05:00
Brian S. Stephan 1d73deda1c sqlite related stuff as part of making sqlite the canonical backend
* 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
2010-10-27 17:59:01 -05:00
Mike Bloy 98f07105bc karma data store moved to sqlite 2010-10-24 15:13:00 -05:00
Mike Bloy 6a67795b18 modules know how to ask for a version number from the database 2010-10-24 15:11:39 -05:00
Mike Bloy 240612fecf database connection grabbing for Modules 2010-10-24 15:11:35 -05:00
Brian S. Stephan 2a1ef11d95 don't attempt recursion when the subcmd is, in fact, an empty string (i.e. text was '[]') 2010-10-12 11:54:43 -05:00
Brian S. Stephan 52b740a52c split the register_handlers into a method other than the object constructor
the reasoning behind this is that we may want to load one object
but have it connect to multiple servers. this allows that.
2010-10-09 18:52:51 -05:00
Brian S. Stephan a7f0070a39 module reloading appears to be broken. disabling for now. 2010-09-08 20:06:20 -05:00
Brian S. Stephan f5caeb3833 add new meta options to remove_metaoptions() 2010-09-08 19:58:29 -05:00
Brian S. Stephan 338c1e759f meta option 'meta.strip_bot_name_from_input' to determine just that. 2010-09-08 19:49:56 -05:00
Brian S. Stephan fc8a61a110 meta option 'meta.pubmsg_ignore_bot_prefix' to have module not try [] recursion.
handy for the alias module, which will want to preserve that recursion stuff (if
it shows up) after it does its alias lookup
2010-09-08 19:38:19 -05:00
Brian S. Stephan 98c30e1714 module meta option to ignore when bot is addressed directly.
the motivation for this is if you have commands that have been aliased
that you do not want to fire when they normally would via 'bot: blah'
2010-09-08 19:32:06 -05:00
Brian S. Stephan bf8fe46522 retransmit_event takes an Event and re-runs it through normal event handling.
i wrote this for something and then realized i didn't need it, but
it may be interesting for some reason in the future
2010-09-04 10:45:18 -05:00
Brian S. Stephan 4712e69336 refer to the actual list variable when looking up meta.pubmsg_needs_bot_prefix 2010-08-01 12:19:15 -05:00
Brian S. Stephan e13264fc3b add method to remove metaoptions (debug, the new 'meta.pubmsg_needs_bot_prefix') from a list. provided for convenience 2010-08-01 12:13:38 -05:00
Brian S. Stephan 1ec197be95 establish a per-module option that specifies whether or not active commands to it need to be prefixed with the bot's name. doesn't help stuff like Seen's reimplementation of on_pubmsg, since it would want to do the tracking regardless of this option. also, work around this addition in the countdown module, so it doesn't show up in lists. 2010-08-01 11:55:14 -05:00
Brian S. Stephan 4d41314195 standardize config sections to use class name. NOTE: USERS NEED TO UPDATE THEIR CONFIG 2010-08-01 11:41:26 -05:00
Brian S. Stephan 5f29d12561 minor comment update following the recent register_handlers() change 2010-07-30 18:54:57 -05:00
Brian S. Stephan 594c4d297d remove_global_handler() for pubmsg and privmsg by default, since Module does the add_global_handler() (last commit) 2010-07-30 18:53:58 -05:00
Brian S. Stephan eb1efa4919 add_global_handler() for pubmsg and privmsg by default, since Module defines on_pubmsg/on_privmsg anyway, and that's been the default for almost every module so far 2010-07-30 18:50:56 -05:00
Brian S. Stephan 7feb90242d renaming 'irclib' dir to 'extlib' 2010-07-30 18:34:10 -05:00
Brian S. Stephan 262ee2e3e1 PEP 257ifying dr.botzo.py and Module.py 2010-07-30 13:34:51 -05:00
Brian S. Stephan 6e86096f2b some comments in the module reload 2010-07-30 06:56:37 -05:00
Brian S. Stephan ae4c1fa726 move common reply functionality into a method in Module 2010-07-30 00:34:57 -05:00
Brian S. Stephan 57090fdda4 long list of changes to allow modular Module reloads: server as module variable, class appends self to module list, unregister_handlers method which must be overridden, reload method which does the magic to create the a new object of the re-read class. drop use of the main rehash and reload_modules, and don't pass rehash around anymore. load initial objects 'the old way' again. feature modules change for compatability and implementation of all of the above changes 2010-07-29 22:36:08 -05:00
Brian S. Stephan 21963fe580 print name of module that was loaded in __init__ 2010-07-29 19:50:13 -05:00
Brian S. Stephan 632f89e61c remove a bunch of variables in Module that were added because of ?????? 2010-07-29 19:45:02 -05:00
Brian S. Stephan 26d2e0c294 making imports fit my style convention, actually importing os in the module that needs it 2010-07-29 00:18:20 -05:00
Brian S. Stephan 91e535978f comment nitpicking and restyling 2010-07-29 00:04:01 -05:00
Brian S. Stephan 48498898bf vi modelines for split out files 2010-07-28 23:48:47 -05:00
Brian S. Stephan b65c01fb31 GPLv3 headers on the split out files 2010-07-28 23:47:29 -05:00