mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-11-03 17:17:23 +01:00 
			
		
		
		
	Guarded IrcState.doMode to work only with channels.
This commit is contained in:
		
							parent
							
								
									1410d1af43
								
							
						
					
					
						commit
						6169822349
					
				@ -268,20 +268,22 @@ class IrcState(IrcCommandDispatcher):
 | 
			
		||||
                self.channels[channel] = chan
 | 
			
		||||
 | 
			
		||||
    def doMode(self, irc, msg):
 | 
			
		||||
        chan = self.channels[msg.args[0]]
 | 
			
		||||
        for (mode, nick) in ircutils.separateModes(msg.args[1:]):
 | 
			
		||||
            if mode == '-o':
 | 
			
		||||
                chan.ops.discard(nick)
 | 
			
		||||
            elif mode == '+o':
 | 
			
		||||
                chan.ops.add(nick)
 | 
			
		||||
            if mode == '-h':
 | 
			
		||||
                chan.halfops.discard(nick)
 | 
			
		||||
            elif mode == '+h':
 | 
			
		||||
                chan.halfops.add(nick)
 | 
			
		||||
            if mode == '-v':
 | 
			
		||||
                chan.voices.discard(nick)
 | 
			
		||||
            elif mode == '+v':
 | 
			
		||||
                chan.voices.add(nick)
 | 
			
		||||
        channel = msg.args[0]
 | 
			
		||||
        if ircutils.isChannel(channel):
 | 
			
		||||
            chan = self.channels[channel]
 | 
			
		||||
            for (mode, nick) in ircutils.separateModes(msg.args[1:]):
 | 
			
		||||
                if mode == '-o':
 | 
			
		||||
                    chan.ops.discard(nick)
 | 
			
		||||
                elif mode == '+o':
 | 
			
		||||
                    chan.ops.add(nick)
 | 
			
		||||
                if mode == '-h':
 | 
			
		||||
                    chan.halfops.discard(nick)
 | 
			
		||||
                elif mode == '+h':
 | 
			
		||||
                    chan.halfops.add(nick)
 | 
			
		||||
                if mode == '-v':
 | 
			
		||||
                    chan.voices.discard(nick)
 | 
			
		||||
                elif mode == '+v':
 | 
			
		||||
                    chan.voices.add(nick)
 | 
			
		||||
 | 
			
		||||
    def do353(self, irc, msg):
 | 
			
		||||
        (_, _, channel, users) = msg.args
 | 
			
		||||
 | 
			
		||||
@ -212,6 +212,10 @@ class IrcStateTestCase(unittest.TestCase):
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar'))
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].halfops)
 | 
			
		||||
 | 
			
		||||
    def testDoModeOnlyChannels(self):
 | 
			
		||||
        st = irclib.IrcState()
 | 
			
		||||
        self.assert_(st.addMsg(self.irc, ircmsgs.IrcMsg('MODE foo +i')) or 1)
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    def testChannels(self):
 | 
			
		||||
        channel =
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user