コード例 #1
0
    def voice_func(self, irc, msg, args, channel):
        """[channel]
		Bascule tous les utilisateurs du canal en mode +v
		"""
        if not channel:
            channel = msg.args[0]
        users = []
        if channel in irc.state.channels:
            for user in irc.state.channels[channel].users:
                if user not in irc.state.channels[channel].voices \
                 and user not in irc.state.channels[channel].ops \
                 and user not in self.nicks_moderated:
                    users += [user]
                    if len(users) > 3:
                        irc.queueMsg(ircmsgs.voices(channel, users))
                        users = []
            if len(users) != 0:
                irc.queueMsg(ircmsgs.voices(channel, users))
コード例 #2
0
ファイル: plugin.py プロジェクト: WnP/archange
	def voice_func (self, irc, msg, args, channel):
		"""[channel]
		Bascule tous les utilisateurs du canal en mode +v
		"""
		if not channel:
			channel = msg.args[0]
		users = []
		if channel in irc.state.channels:
			for user in irc.state.channels[channel].users:
				if user not in irc.state.channels[channel].voices \
					and user not in irc.state.channels[channel].ops \
					and user not in self.nicks_moderated:
					users += [user]
					if len(users) > 3:
						irc.queueMsg (ircmsgs.voices(channel, users))
						users = []
			if len(users) != 0:
				irc.queueMsg (ircmsgs.voices(channel, users))
コード例 #3
0
ファイル: plugin.py プロジェクト: nyuszika7h/limnoria-plugins
    def voiceall(self, irc, msg, args, channel):
        """[<channel>]

        Voices everyone in the channel. <channel> is only necessary
        if the message isn't sent in the channel itself.
        """

        chanstate = irc.state.channels[channel]
        users = [user for user in chanstate.users if not chanstate.isVoice(user)]

        for batch in self._split_modes(users):
            irc.queueMsg(ircmsgs.voices(channel, batch))
コード例 #4
0
 def f(L):
     return ircmsgs.voices(channel, L)
コード例 #5
0
 def testVoices(self):
     m = ircmsgs.voices('#foo', ['foo', 'bar', 'baz'])
     self.assertEqual(str(m), 'MODE #foo +vvv foo bar :baz\r\n')
コード例 #6
0
		def f(L):
			return ircmsgs.voices(self.channel, L)
コード例 #7
0
 def f(L):
     return ircmsgs.voices(channel, L)
コード例 #8
0
ファイル: plugin.py プロジェクト: crazedpsyc/Supybot-plugins
    def _autoMagic(self, irc, msg, channel):
        # If bot does not got op
        if irc.nick not in irc.state.channels[channel].ops:
            return
        # Read database
        hostdict, _ = self._readFile(channel)

        # If for some reason _readFile() failed
        if hostdict == -3:
            return -3
        elif hostdict == -2:
            return -2
        elif hostdict == -1:
            return -1

        # List of those nicks that are to gain modes
        oplist = []
        halfoplist = []
        voicelist = []

        # For all nicks in channel
        for u in irc.state.channels[channel].users:
            hostname = irc.state.nickToHostmask(u)
            for regex in hostdict.iteritems():
                match = re.search(regex[0], hostname)
                if match:
                    if regex[1] == "op":
                        if u not in irc.state.channels[channel].ops:
                            oplist.append(u)
                    elif regex[1] == "halfop":
                        if u not in irc.state.channels[channel].halfops:
                            halfoplist.append(u)
                    elif regex[1] == "voice":
                        if u not in irc.state.channels[channel].voices:
                            voicelist.append(u)

        maxmodes = 4
        # While there are still people to give op to
        while len(oplist) > 0:
            # Op the first 4, or whatever maxmode is
            irc.queueMsg(ircmsgs.ops(channel, oplist[:maxmodes]))
            # Remove those that have been given op from the list
            oplist = oplist[maxmodes:]
            # If the list is shorter than maxmode, op them all.
            if len(oplist) <= maxmodes:
                irc.queueMsg(ircmsgs.ops(channel, oplist))
                break

        while len(halfoplist) > 0:
            irc.queueMsg(ircmsgs.halfops(channel, halfoplist[:maxmodes]))
            halfoplist = halfoplist[maxmodes:]
            if len(halfoplist) <= maxmodes:
                irc.queueMsg(ircmsgs.halfops(channel, halfoplist))
                break

        while len(voicelist) > 0:
            irc.queueMsg(ircmsgs.voices(channel, voicelist[:maxmodes]))
            voicelist = voicelist[maxmodes:]
            if len(voicelist) <= maxmodes:
                irc.queueMsg(ircmsgs.voices(channel, voicelist))
                break

        # Can't really remember that this does.
        irc.noReply()
コード例 #9
0
ファイル: test_ircmsgs.py プロジェクト: ElectroCode/Limnoria
 def testVoices(self):
     m = ircmsgs.voices('#foo', ['foo', 'bar', 'baz'])
     self.assertEqual(str(m), 'MODE #foo +vvv foo bar :baz\r\n')
コード例 #10
0
ファイル: plugin.py プロジェクト: nomadicus/Supybot-plugins
    def _autoMagic(self, irc, msg, channel):
        # If bot does not got op
        if irc.nick not in irc.state.channels[channel].ops:
            return
        # Read database
        hostdict, _ = self._readFile(channel)

        # If for some reason _readFile() failed
        if hostdict == -3:
            return -3
        elif hostdict == -2:
            return -2
        elif hostdict == -1:
            return -1

        # List of those nicks that are to gain modes
        oplist = []
        halfoplist = []
        voicelist = []

        # For all nicks in channel
        for u in irc.state.channels[channel].users:
            hostname = irc.state.nickToHostmask(u)
            for regex in hostdict.iteritems():
                match = re.search(regex[0], hostname)
                if match:
                    if regex[1] == "op":
                        if u not in irc.state.channels[channel].ops:
                            oplist.append(u)
                    elif regex[1] == "halfop":
                        if u not in irc.state.channels[channel].halfops:
                            halfoplist.append(u)
                    elif regex[1] == "voice":
                        if u not in irc.state.channels[channel].voices:
                            voicelist.append(u)

        maxmodes = 4
        # While there are still people to give op to
        while len(oplist) > 0:
            # Op the first 4, or whatever maxmode is
            irc.queueMsg(ircmsgs.ops(channel, oplist[:maxmodes]))
            # Remove those that have been given op from the list
            oplist = oplist[maxmodes:]
            # If the list is shorter than maxmode, op them all.
            if len(oplist) <= maxmodes:
                irc.queueMsg(ircmsgs.ops(channel, oplist))
                break

        while len(halfoplist) > 0:
            irc.queueMsg(ircmsgs.halfops(channel, halfoplist[:maxmodes]))
            halfoplist = halfoplist[maxmodes:]
            if len(halfoplist) <= maxmodes:
                irc.queueMsg(ircmsgs.halfops(channel, halfoplist))
                break

        while len(voicelist) > 0:
            irc.queueMsg(ircmsgs.voices(channel, voicelist[:maxmodes]))
            voicelist = voicelist[maxmodes:]
            if len(voicelist) <= maxmodes:
                irc.queueMsg(ircmsgs.voices(channel, voicelist))
                break

        # Can't really remember that this does.
        irc.noReply()