mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-11-03 17:17:23 +01:00 
			
		
		
		
	Added op/halfop/voice handling in IrcState.
This commit is contained in:
		
							parent
							
								
									8e45ffc020
								
							
						
					
					
						commit
						fe4af22e50
					
				@ -267,6 +267,22 @@ class IrcState(IrcCommandDispatcher):
 | 
			
		||||
                chan.addUser(msg.nick)
 | 
			
		||||
                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)
 | 
			
		||||
 | 
			
		||||
    def do353(self, irc, msg):
 | 
			
		||||
        (_, _, channel, users) = msg.args
 | 
			
		||||
        chan = self.channels[channel]
 | 
			
		||||
 | 
			
		||||
@ -149,6 +149,7 @@ class ChannelTestCase(unittest.TestCase):
 | 
			
		||||
class IrcStateTestCase(unittest.TestCase):
 | 
			
		||||
    class FakeIrc:
 | 
			
		||||
        nick = 'nick'
 | 
			
		||||
        prefix = 'nick!user@host'
 | 
			
		||||
    irc = FakeIrc()
 | 
			
		||||
    def testHistory(self):
 | 
			
		||||
        oldconfmaxhistory = conf.maxHistory
 | 
			
		||||
@ -190,6 +191,26 @@ class IrcStateTestCase(unittest.TestCase):
 | 
			
		||||
            except Exception:
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
    def testHandlesModes(self):
 | 
			
		||||
        st = irclib.IrcState()
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix))
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].ops)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.op('#foo', 'bar'))
 | 
			
		||||
        self.failUnless('bar' in st.channels['#foo'].ops)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.deop('#foo', 'bar'))
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].ops)
 | 
			
		||||
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].voices)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.voice('#foo', 'bar'))
 | 
			
		||||
        self.failUnless('bar' in st.channels['#foo'].voices)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.devoice('#foo', 'bar'))
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].voices)
 | 
			
		||||
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].halfops)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.halfop('#foo', 'bar'))
 | 
			
		||||
        self.failUnless('bar' in st.channels['#foo'].halfops)
 | 
			
		||||
        st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar'))
 | 
			
		||||
        self.failIf('bar' in st.channels['#foo'].halfops)
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    def testChannels(self):
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user