mirror of
https://github.com/jesopo/ircstates
synced 2024-06-27 11:17:12 +00:00
simplify parsing channel MODE & RPL_CHANNELMODEIS
This commit is contained in:
parent
c27c48af54
commit
2c1468295e
|
@ -431,23 +431,25 @@ class Server(object):
|
|||
channel_user.modes.append(char)
|
||||
elif char in channel_user.modes:
|
||||
channel_user.modes.remove(char)
|
||||
elif add:
|
||||
else:
|
||||
has_arg = False
|
||||
is_list = False
|
||||
if char in self.isupport.chanmodes.a_modes:
|
||||
has_arg = True
|
||||
is_list = True
|
||||
elif add:
|
||||
has_arg = char in (self.isupport.chanmodes.b_modes+
|
||||
self.isupport.chanmodes.c_modes)
|
||||
else: # remove
|
||||
has_arg = char in self.isupport.chanmodes.b_modes
|
||||
|
||||
if has_arg:
|
||||
arg = params.pop(0)
|
||||
channel.add_mode(char, arg, True)
|
||||
elif (char in self.isupport.chanmodes.b_modes or
|
||||
char in self.isupport.chanmodes.c_modes):
|
||||
arg = params.pop(0)
|
||||
channel.add_mode(char, arg, False)
|
||||
|
||||
if add:
|
||||
channel.add_mode(char, arg, is_list)
|
||||
else:
|
||||
channel.add_mode(char, None, False)
|
||||
else: # remove
|
||||
if (char in self.isupport.chanmodes.a_modes or
|
||||
char in self.isupport.chanmodes.b_modes):
|
||||
arg = params.pop(0)
|
||||
channel.remove_mode(char, arg)
|
||||
else:
|
||||
channel.remove_mode(char, None)
|
||||
|
||||
tokens.append((mode, arg))
|
||||
|
||||
|
|
|
@ -55,9 +55,10 @@ class ModeTestChannelList(unittest.TestCase):
|
|||
server.parse_tokens(irctokens.tokenise("001 nickname"))
|
||||
server.parse_tokens(irctokens.tokenise(":nickname JOIN #chan"))
|
||||
server.parse_tokens(irctokens.tokenise("MODE #chan +b asd!*@*"))
|
||||
server.parse_tokens(irctokens.tokenise("MODE #chan +b dsa!*@*"))
|
||||
server.parse_tokens(irctokens.tokenise("MODE #chan -b asd!*@*"))
|
||||
channel = server.channels["#chan"]
|
||||
self.assertEqual(channel.list_modes, {})
|
||||
self.assertEqual(channel.list_modes, {"b": ["dsa!*@*"]})
|
||||
|
||||
def test_banlist(self):
|
||||
server = ircstates.Server("test")
|
||||
|
|
Loading…
Reference in New Issue
Block a user