mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Channel: allow adding an auto-rejoin delay via supybot.plugins.Channel.rejoinDelay
Closes #1011.
This commit is contained in:
parent
a59784a366
commit
f3107a928f
@ -51,6 +51,9 @@ conf.registerChannelValue(Channel, 'nicksInPrivate',
|
|||||||
registry.Boolean(True, _("""Determines whether the output of 'nicks' will
|
registry.Boolean(True, _("""Determines whether the output of 'nicks' will
|
||||||
be sent in private. This prevents mass-highlights of a channel's users,
|
be sent in private. This prevents mass-highlights of a channel's users,
|
||||||
accidental or on purpose.""")))
|
accidental or on purpose.""")))
|
||||||
|
conf.registerChannelValue(Channel, 'rejoinDelay',
|
||||||
|
registry.NonNegativeInteger(0, _("""Determines how many seconds the bot will wait
|
||||||
|
before rejoining a channel if kicked and
|
||||||
|
supybot.plugins.Channel.alwaysRejoin is on.""")))
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
import time
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
@ -46,6 +47,7 @@ class Channel(callbacks.Plugin):
|
|||||||
"""This plugin provides various commands for channel management, such
|
"""This plugin provides various commands for channel management, such
|
||||||
as setting modes and channel-wide bans/ignores/capabilities. This is
|
as setting modes and channel-wide bans/ignores/capabilities. This is
|
||||||
a core Supybot plugin that should not be removed!"""
|
a core Supybot plugin that should not be removed!"""
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Channel, self)
|
self.__parent = super(Channel, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
@ -55,10 +57,18 @@ class Channel(callbacks.Plugin):
|
|||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if msg.args[1] == irc.nick:
|
if msg.args[1] == irc.nick:
|
||||||
if self.registryValue('alwaysRejoin', channel):
|
if self.registryValue('alwaysRejoin', channel):
|
||||||
self.log.info('Kicked from %s by %s. Rejoining.' %
|
delay = self.registryValue('rejoinDelay', channel)
|
||||||
(channel, msg.prefix))
|
|
||||||
networkGroup = conf.supybot.networks.get(irc.network)
|
networkGroup = conf.supybot.networks.get(irc.network)
|
||||||
irc.sendMsg(networkGroup.channels.join(channel))
|
if delay:
|
||||||
|
def f():
|
||||||
|
irc.sendMsg(networkGroup.channels.join(channel))
|
||||||
|
schedule.addEvent(f, time.time() + delay)
|
||||||
|
self.log.info('Kicked from %s by %s. Rejoining after %s '
|
||||||
|
'seconds.', channel, msg.prefix, delay)
|
||||||
|
else:
|
||||||
|
self.log.info('Kicked from %s by %s. Rejoining.',
|
||||||
|
channel, msg.prefix)
|
||||||
|
irc.sendMsg(networkGroup.channels.join(channel))
|
||||||
else:
|
else:
|
||||||
self.log.info('Kicked from %s by %s. Not auto-rejoining.' %
|
self.log.info('Kicked from %s by %s. Not auto-rejoining.' %
|
||||||
(channel, msg.prefix))
|
(channel, msg.prefix))
|
||||||
|
Loading…
Reference in New Issue
Block a user