AutoMode: Add configurable delay. Closes GH-188.

This commit is contained in:
Valentin Lorentz 2012-04-04 15:55:42 +02:00
parent 8558640a00
commit e6032c68bc
3 changed files with 14 additions and 3 deletions

View File

@ -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:

View File

@ -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']:

View File

@ -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)'