Commit Graph

50 Commits

Author SHA1 Message Date
Brian S. Stephan 89847a6e58 IrcAdmin: sleep a configured time before autojoin
this is to let any sort of autosend commands apply before joining
channels. for example, i have my bot set to turn on its hostserv cloak,
which was sometimes happening after channel joins, making its hostname
appear different in various channels. this solves that

as a total aside, this module is becoming really poorly named, i should
probably do something about that
2013-01-13 11:45:01 -06:00
Brian S. Stephan 891b2bcab8 remove all of the help stuff
sorry, mikeb. it never really caught on and seemed kind of janky. i
intend to have something that uses docstrings in the future, with the
helping baked into Module or maybe even DrBotIRC
2012-12-19 21:12:49 -06:00
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 8a5e6b9130 IrcAdmin: note limitation with automsg and vhosts
i feel as if i should fix this eventually, but it's pretty low on the
priority list, to be honest
2012-12-18 20:56:30 -06:00
Brian S. Stephan b51b8b521d IrcAdmin: option for sending privmsgs on connect
nickserv/hostserv stuff are the obvious uses for this. i guess you could
have some sort of "hi i connected" type thing to the admin if you wanted
2012-12-18 20:15:32 -06:00
Brian S. Stephan 8b2269c441 pyflakes cleanups 2012-07-27 20:38:45 -05:00
Brian S. Stephan c7846e415a IrcAdmin: don't crash by trying to tell #chan that you just left #chan 2011-06-20 20:27:20 -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 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 18fc614a4a assorted whitespace nitpicking 2011-01-20 14:15:10 -06:00
Mike Bloy 66a736b108 added help for the IrcAdmin module 2011-01-08 23:41:41 -06:00
Brian S. Stephan 1664cf2de7 since the save command was saving both modules and config, call it !save, not !config save 2011-01-08 09:16:37 -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 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