mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Added modes to the Channel.
This commit is contained in:
parent
b01886f537
commit
6ecd46bada
@ -194,13 +194,14 @@ class IrcMsgQueue(object):
|
|||||||
# status of various modes (especially ops/halfops/voices) in channels, etc.
|
# status of various modes (especially ops/halfops/voices) in channels, etc.
|
||||||
###
|
###
|
||||||
class ChannelState(object):
|
class ChannelState(object):
|
||||||
__slots__ = ('users', 'ops', 'halfops', 'voices', 'topic')
|
__slots__ = ('users', 'ops', 'halfops', 'voices', 'topic', 'modes')
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.topic = ''
|
self.topic = ''
|
||||||
self.users = ircutils.IrcSet()
|
self.users = ircutils.IrcSet()
|
||||||
self.ops = ircutils.IrcSet()
|
self.ops = ircutils.IrcSet()
|
||||||
self.halfops = ircutils.IrcSet()
|
self.halfops = ircutils.IrcSet()
|
||||||
self.voices = ircutils.IrcSet()
|
self.voices = ircutils.IrcSet()
|
||||||
|
self.modes = ircutils.IrcDict()
|
||||||
|
|
||||||
def addUser(self, user):
|
def addUser(self, user):
|
||||||
"Adds a given user to the ChannelState. Power prefixes are handled."
|
"Adds a given user to the ChannelState. Power prefixes are handled."
|
||||||
@ -234,6 +235,13 @@ class ChannelState(object):
|
|||||||
self.halfops.discard(user)
|
self.halfops.discard(user)
|
||||||
self.voices.discard(user)
|
self.voices.discard(user)
|
||||||
|
|
||||||
|
def setMode(self, mode, value=None):
|
||||||
|
self.modes[mode] = value
|
||||||
|
|
||||||
|
def unsetMode(self, mode):
|
||||||
|
if mode in self.modes:
|
||||||
|
del self.modes[mode]
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return [getattr(self, name) for name in self.__slots__]
|
return [getattr(self, name) for name in self.__slots__]
|
||||||
|
|
||||||
@ -323,19 +331,23 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if ircutils.isChannel(channel):
|
if ircutils.isChannel(channel):
|
||||||
chan = self.channels[channel]
|
chan = self.channels[channel]
|
||||||
for (mode, nick) in ircutils.separateModes(msg.args[1:]):
|
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
||||||
if mode == '-o':
|
if mode == '-o':
|
||||||
chan.ops.discard(nick)
|
chan.ops.discard(value)
|
||||||
elif mode == '+o':
|
elif mode == '+o':
|
||||||
chan.ops.add(nick)
|
chan.ops.add(value)
|
||||||
if mode == '-h':
|
if mode == '-h':
|
||||||
chan.halfops.discard(nick)
|
chan.halfops.discard(value)
|
||||||
elif mode == '+h':
|
elif mode == '+h':
|
||||||
chan.halfops.add(nick)
|
chan.halfops.add(value)
|
||||||
if mode == '-v':
|
if mode == '-v':
|
||||||
chan.voices.discard(nick)
|
chan.voices.discard(value)
|
||||||
elif mode == '+v':
|
elif mode == '+v':
|
||||||
chan.voices.add(nick)
|
chan.voices.add(value)
|
||||||
|
elif mode == '+i':
|
||||||
|
chan.setMode('i')
|
||||||
|
elif mode == '-i':
|
||||||
|
chan.unsetMode('i')
|
||||||
|
|
||||||
def do353(self, irc, msg):
|
def do353(self, irc, msg):
|
||||||
(_, _, channel, users) = msg.args
|
(_, _, channel, users) = msg.args
|
||||||
|
Loading…
Reference in New Issue
Block a user