diff --git a/plugins/AutoMode/config.py b/plugins/AutoMode/config.py index aa8766655..95e0692c9 100644 --- a/plugins/AutoMode/config.py +++ b/plugins/AutoMode/config.py @@ -71,6 +71,9 @@ conf.registerChannelValue(AutoMode.ban, 'period', registry.PositiveInteger(86400, _("""Determines how many seconds the bot will automatically ban a person when banning."""))) +conf.registerChannelValue(AutoMode, 'delay', + registry.Integer(0, _("""Determines how many seconds the bot will wait + before applying a mode. Has no effect on bans."""))) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/AutoMode/plugin.py b/plugins/AutoMode/plugin.py index 6a1ddc82d..8a706b409 100644 --- a/plugins/AutoMode/plugin.py +++ b/plugins/AutoMode/plugin.py @@ -55,16 +55,24 @@ class AutoMode(callbacks.Plugin): if ircdb.checkCapability(msg.prefix, cap, ignoreOwner=not self.registryValue('owner')): if self.registryValue(type, channel): - self.log.info('Sending auto-%s of %s in %s.', + self.log.info('Scheduling auto-%s of %s in %s.', type, msg.prefix, channel) msgmaker = getattr(ircmsgs, type) - irc.queueMsg(msgmaker(channel, msg.nick)) + schedule_msg(msgmaker(channel, msg.nick)) raise Continue # Even if fallthrough, let's only do one. elif not fallthrough: self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s' ' is not enabled in %s, refusing to fall ' 'through.', msg.prefix, cap, type, channel) raise Continue + def schedule_msg(msg): + def f(): + irc.queueMsg(msg) + delay = self.registryValue('delay', channel) + if delay: + schedule.addEvent(f, time.time() + delay) + else: + f() try: do('op') if 'h' in irc.state.supported['prefix']: diff --git a/src/version.py b/src/version.py index 63d2add1d..94ee64bb4 100644 --- a/src/version.py +++ b/src/version.py @@ -1,3 +1,3 @@ """stick the various versioning attributes in here, so we only have to change them once.""" -version = '0.83.4.1+limnoria (2012-04-04T13:55:08+0000)' +version = '0.83.4.1+limnoria (2012-04-04T13:55:42+0000)'