mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added network-specific channels.
This commit is contained in:
parent
fb0a5dd51f
commit
7328bd50ba
23
src/Admin.py
23
src/Admin.py
@ -66,7 +66,9 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
self.pendingNickChanges = {}
|
||||
|
||||
def do376(self, irc, msg):
|
||||
channels = list(conf.supybot.channels())
|
||||
channels = ircutils.IrcSet(conf.supybot.channels())
|
||||
channels |= conf.supybot.networks.get(irc.network).channels()
|
||||
channels = list(channels)
|
||||
if not channels:
|
||||
return
|
||||
utils.sortBy(lambda s: ',' not in s, channels)
|
||||
@ -269,17 +271,18 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
||||
reason = ' '.join(args)
|
||||
for chan in channels:
|
||||
if chan not in irc.state.channels:
|
||||
irc.error('I\'m not currently in %s' % chan)
|
||||
irc.error('I\'m not currently in %s.' % chan)
|
||||
return
|
||||
for chan in channels:
|
||||
L = []
|
||||
for channelWithPass in conf.supybot.channels():
|
||||
channel = channelWithPass.split(',')[0]
|
||||
if ircutils.strEqual(chan, channel):
|
||||
L.append(channelWithPass)
|
||||
# This is necessary so the set doesn't change size while iterating.
|
||||
for channel in L:
|
||||
conf.supybot.channels().remove(channel)
|
||||
try:
|
||||
conf.supybot.channels.removeChannel(chan)
|
||||
except KeyError:
|
||||
pass # It might be in the network thingy.
|
||||
try:
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
networkGroup.channels.removeChannel(chan)
|
||||
except KeyError:
|
||||
pass # It might be in the non-network thingy.
|
||||
irc.queueMsg(ircmsgs.parts(channels, reason or msg.nick))
|
||||
inAtLeastOneChannel = False
|
||||
for chan in channels:
|
||||
|
48
src/conf.py
48
src/conf.py
@ -187,28 +187,6 @@ class Servers(registry.SpaceSeparatedListOfStrings):
|
||||
def __str__(self):
|
||||
return ' '.join(registry.SpaceSeparatedListOfStrings.__call__(self))
|
||||
|
||||
def registerNetwork(name, password='', servers=()):
|
||||
name = intern(name)
|
||||
network = registerGroup(supybot.networks, name)
|
||||
registerGlobalValue(network, 'password', registry.String(password,
|
||||
"""Determines what password will be used on %s. Yes, we know that
|
||||
technically passwords are server-specific and not network-specific,
|
||||
but this is the best we can do right now.""" % name))
|
||||
registerGlobalValue(network, 'servers', Servers(servers,
|
||||
"""Determines what servers the bot will connect to for %s. Each will
|
||||
be tried in order, wrapping back to the first when the cycle is
|
||||
completed.""" % name))
|
||||
return network
|
||||
|
||||
# Let's fill our networks.
|
||||
for (name, s) in registry._cache.iteritems():
|
||||
if name.startswith('supybot.networks.'):
|
||||
parts = name.split('.')
|
||||
name = parts[2]
|
||||
if name != 'default':
|
||||
registerNetwork(name)
|
||||
|
||||
|
||||
class SpaceSeparatedSetOfChannels(registry.SpaceSeparatedListOf):
|
||||
List = ircutils.IrcSet
|
||||
Value = ValidChannel
|
||||
@ -221,7 +199,31 @@ class SpaceSeparatedSetOfChannels(registry.SpaceSeparatedListOf):
|
||||
if chan == channel:
|
||||
removals.append(c)
|
||||
for removal in removals:
|
||||
self.value.remove(discard)
|
||||
self.value.remove(removal)
|
||||
|
||||
def registerNetwork(name, password='', servers=()):
|
||||
name = intern(name)
|
||||
network = registerGroup(supybot.networks, name)
|
||||
registerGlobalValue(network, 'password', registry.String(password,
|
||||
"""Determines what password will be used on %s. Yes, we know that
|
||||
technically passwords are server-specific and not network-specific,
|
||||
but this is the best we can do right now.""" % name))
|
||||
registerGlobalValue(network, 'servers', Servers(servers,
|
||||
"""Determines what servers the bot will connect to for %s. Each will
|
||||
be tried in order, wrapping back to the first when the cycle is
|
||||
completed.""" % name))
|
||||
registerGlobalValue(network, 'channels', SpaceSeparatedSetOfChannels([],
|
||||
"""Determines what channels the bot will join only on %s.""" % name))
|
||||
return network
|
||||
|
||||
# Let's fill our networks.
|
||||
for (name, s) in registry._cache.iteritems():
|
||||
if name.startswith('supybot.networks.'):
|
||||
parts = name.split('.')
|
||||
name = parts[2]
|
||||
if name != 'default':
|
||||
registerNetwork(name)
|
||||
|
||||
|
||||
registerGlobalValue(supybot, 'channels',
|
||||
SpaceSeparatedSetOfChannels(['#supybot'], """Determines what channels the
|
||||
|
Loading…
Reference in New Issue
Block a user