mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Merge pull request #1063 from GLolol/channel/autorejoin-delay
Channel: allow adding an auto-rejoin delay
This commit is contained in:
commit
f6c789b018
@ -51,6 +51,10 @@ conf.registerChannelValue(Channel, 'nicksInPrivate',
|
||||
registry.Boolean(True, _("""Determines whether the output of 'nicks' will
|
||||
be sent in private. This prevents mass-highlights of a channel's users,
|
||||
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.""")))
|
||||
conf.registerChannelValue(Channel, 'partMsg',
|
||||
registry.String('$version', _("""Determines what part message should be
|
||||
used by default. If the part command is called without a part message,
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
import sys
|
||||
import fnmatch
|
||||
import time
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.ircdb as ircdb
|
||||
@ -46,6 +47,7 @@ class Channel(callbacks.Plugin):
|
||||
"""This plugin provides various commands for channel management, such
|
||||
as setting modes and channel-wide bans/ignores/capabilities. This is
|
||||
a core Supybot plugin that should not be removed!"""
|
||||
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Channel, self)
|
||||
self.__parent.__init__(irc)
|
||||
@ -55,10 +57,18 @@ class Channel(callbacks.Plugin):
|
||||
channel = msg.args[0]
|
||||
if msg.args[1] == irc.nick:
|
||||
if self.registryValue('alwaysRejoin', channel):
|
||||
self.log.info('Kicked from %s by %s. Rejoining.' %
|
||||
(channel, msg.prefix))
|
||||
delay = self.registryValue('rejoinDelay', channel)
|
||||
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:
|
||||
self.log.info('Kicked from %s by %s. Not auto-rejoining.' %
|
||||
(channel, msg.prefix))
|
||||
|
Loading…
Reference in New Issue
Block a user