Commit Graph

35 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 0bd681c324 convert most modules to use ! commands.
okay, it's time. we got around for a while with all sorts of silly
config options and exceptions and common strings triggering bot
commands. but now it's time to man up and expect modules to be
more strict and less loosey-goosey.

convert the popular modules (i.e. the ones that still work) to
trigger on !pi rather than pi, etc. usually, this is achieved via
regex searches, although there are some weird bugs (ones i'm hoping
are caused by other recursion/alias bugs and not this commit).

more code around this will be gutted soon, but this, at least,
means you can't say 'tweet that shit, yo' and accidentally trigger
the bot.
2011-01-07 20:37:24 -06:00
Brian S. Stephan efb92ddc83 reload should call irc.reload_module, not unload_module 2011-01-07 19:09:09 -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 de3f9d9ae7 provide a priority (default 50) to add_global_handler 2011-01-07 01:10:52 -06:00
Brian S. Stephan 8bbda8b575 if we add the module to the autoload list on a load, we should remove it on unload 2011-01-06 23:29:51 -06:00
Brian S. Stephan acca8723b3 convert to/standardize docstrings a bit.
this got boring fast, so it's only half done
2011-01-06 23:25: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 b748d43bbd have SIGINT handler call modules' shutdown() 2010-12-24 13:46:48 -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 ea0f795194 add unload method to IrcAdmin, which unloads a module
hopefully this all works right. i remove two known references
to the object, and then call a del for good measure, which i
think covers it?
2010-12-15 21:28:57 -06:00
Brian S. Stephan 2295f524d4 add load command to IrcAdmin, which (naturally) loads a module and adds it to the autoload list 2010-12-15 21:17:24 -06:00
Brian S. Stephan 467c72847a clean up some IrcAdmin output, which i was using to test reloading 2010-12-15 20:58:13 -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 f3e9568fe3 create the array of arguments in all the methods that need them 2010-09-08 19:24:26 -05:00
Brian S. Stephan 053c3f0ae6 properly call admin functions within do.
before this, recursion type stuff wasn't responded to properly because
do wasn't returning the methods' text
2010-09-04 12:26:50 -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 7feb90242d renaming 'irclib' dir to 'extlib' 2010-07-30 18:34:10 -05:00
Brian S. Stephan 5ba26107cc each module subclassing Module unnecessarily defined __init__, with the exception of IrcAdmin, whose SIGINT setup was moved to register_handlers 2010-07-30 14:38:28 -05:00
Brian S. Stephan 0fc9a325fb change command: 'save' -> 'config save'. will have other config functions, rename method eventually 2010-07-30 06:49:24 -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 861c343f2b move save of config to separate method in IrcAdmin, save config when receiving ^C 2010-07-29 23:51:43 -05:00
Brian S. Stephan 3d31d4f193 quit python when receiving quit from IRC 2010-07-29 23:19:17 -05:00
Brian S. Stephan 43d9d0ad66 sub_quit_channel -> sub_quit_irc 2010-07-29 23:16:52 -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 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
kad 02df2ca783 Cleanup code 2010-07-28 12:25:49 -06:00
kad 0c17196b32 Add some modelines and fix indentation, I hope. 2010-07-27 23:11:58 -06:00
kad ec9acdd2ee Forgot to add files :( 2010-07-27 19:35:01 -06:00