コード例 #1
0
    def limit(self, irc, msg, args, channel, limit):
        """[<channel>] [<limit>]

        Sets the channel limit to <limit>.  If <limit> is 0, or isn't given,
        removes the channel limit.  <channel> is only necessary if the message
        isn't sent in the channel itself.
        """
        if limit:
            self._sendMsg(irc, ircmsgs.mode(channel, ['+l', limit]))
        else:
            self._sendMsg(irc, ircmsgs.mode(channel, ['-l']))
コード例 #2
0
ファイル: plugin.py プロジェクト: rostob/Limnoria
    def limit(self, irc, msg, args, channel, limit):
        """[<channel>] [<limit>]

        Sets the channel limit to <limit>.  If <limit> is 0, or isn't given,
        removes the channel limit.  <channel> is only necessary if the message
        isn't sent in the channel itself.
        """
        if limit:
            self._sendMsg(irc, ircmsgs.mode(channel, ['+l', limit]))
        else:
            self._sendMsg(irc, ircmsgs.mode(channel, ['-l']))
コード例 #3
0
ファイル: plugin.py プロジェクト: TameTimmah/Supybot-plugins
    def _slot(self, lastItem):
        irc = lastItem.irc
        msg = lastItem.msg
        channel = lastItem.channel
        prefix = lastItem.prefix
        nick = prefix.split('!')[0]
        kind = lastItem.kind

        if not ircutils.isChannel(channel):
                return
        if not self.registryValue('enable', channel):
            return

        try:
            ircdb.users.getUser(msg.prefix) # May raise KeyError
            capability = self.registryValue('exempt')
            if capability:
                if ircdb.checkCapability(msg.prefix,
                        ','.join([channel, capability])):
                    self.log.info('Not punishing %s: they are immune.' %
                            prefix)
                    return
        except KeyError:
            pass
        punishment = self.registryValue('%s.punishment' % kind, channel)
        reason = _('%s flood detected') % kind

        if punishment == 'kick':
            self._eventCatcher(irc, msg, 'kicked', kicked_prefix=prefix)
        if kind == 'kicked':
            reason = _('You exceeded your kick quota.')

        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(prefix)
        if punishment == 'kick':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment == 'ban':
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
        elif punishment == 'kban':
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment.startswith('mode'):
            msg = ircmsgs.mode(channel, punishment[len('mode'):])
            irc.queueMsg(msg)
        elif punishment.startswith('umode'):
            msg = ircmsgs.mode(channel, (punishment[len('umode'):], nick))
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
コード例 #4
0
ファイル: plugin.py プロジェクト: rostob/Limnoria
    def key(self, irc, msg, args, channel, key):
        """[<channel>] [<key>]

        Sets the keyword in <channel> to <key>.  If <key> is not given, removes
        the keyword requirement to join <channel>.  <channel> is only necessary
        if the message isn't sent in the channel itself.
        """
        networkGroup = conf.supybot.networks.get(irc.network)
        networkGroup.channels.key.get(channel).setValue(key)
        if key:
            self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
        else:
            self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
コード例 #5
0
    def key(self, irc, msg, args, channel, key):
        """[<channel>] [<key>]

        Sets the keyword in <channel> to <key>.  If <key> is not given, removes
        the keyword requirement to join <channel>.  <channel> is only necessary
        if the message isn't sent in the channel itself.
        """
        networkGroup = conf.supybot.networks.get(irc.network)
        networkGroup.channels.key.get(channel).setValue(key)
        if key:
            self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
        else:
            self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
コード例 #6
0
ファイル: plugin.py プロジェクト: v2k/Supybot-plugins
    def _slot(self, lastItem):
        irc = lastItem.irc
        msg = lastItem.msg
        channel = lastItem.channel
        prefix = lastItem.prefix
        nick = prefix.split('!')[0]
        kind = lastItem.kind

        try:
            ircdb.users.getUser(msg.prefix) # May raise KeyError
            capability = self.registryValue('exempt')
            if capability:
                if ircdb.checkCapability(msg.prefix, capability):
                    return
        except KeyError:
            pass
        punishment = self.registryValue('%s.punishment' % kind, channel)
        reason = _('%s flood detected') % kind
        if punishment == 'kick':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment == 'ban':
            msg = ircmsgs.ban(channel, prefix)
            irc.queueMsg(msg)
        elif punishment == 'kban':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
            msg = ircmsgs.ban(channel, prefix)
            irc.queueMsg(msg)
        elif punishment.startswith('mode'):
            msg = ircmsgs.mode(channel, punishment[len('mode'):])
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
コード例 #7
0
ファイル: test_irclib.py プロジェクト: krattai/AEBL
 def testAddMsgRemovesOpsProperly(self):
     st = irclib.IrcState()
     st.channels['#foo'] = irclib.ChannelState()
     st.channels['#foo'].ops.add('bar')
     m = ircmsgs.mode('#foo', ('-o', 'bar'))
     st.addMsg(self.irc, m)
     self.failIf('bar' in st.channels['#foo'].ops)
コード例 #8
0
    def _slot(self, lastItem):
        irc = lastItem.irc
        msg = lastItem.msg
        channel = lastItem.channel
        prefix = lastItem.prefix
        nick = prefix.split('!')[0]
        kind = lastItem.kind

        try:
            ircdb.users.getUser(msg.prefix)  # May raise KeyError
            capability = self.registryValue('exempt')
            if capability:
                if ircdb.checkCapability(msg.prefix, capability):
                    return
        except KeyError:
            pass
        punishment = self.registryValue('%s.punishment' % kind, channel)
        reason = _('%s flood detected') % kind
        if punishment == 'kick':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment == 'ban':
            msg = ircmsgs.ban(channel, prefix)
            irc.queueMsg(msg)
        elif punishment == 'kban':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
            msg = ircmsgs.ban(channel, prefix)
            irc.queueMsg(msg)
        elif punishment.startswith('mode'):
            msg = ircmsgs.mode(channel, punishment[len('mode'):])
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
コード例 #9
0
ファイル: plugin.py プロジェクト: GLolol/SupyPlugins
 def do381(self, irc, msg):
     self.log.info("OperUp: Received 381 (successful oper up) on %s: %s", irc.network, msg.args[-1])
     if self.registryValue("operModes"):
         self.log.info("OperUp: Opered up on %s, sending user modes %s",
                       irc.network, ''.join(self.registryValue("operModes")))
         irc.sendMsg(ircmsgs.mode(irc.nick,
                                  self.registryValue("operModes")))
コード例 #10
0
 def testAddMsgRemovesOpsProperly(self):
     st = irclib.IrcState()
     st.channels['#foo'] = irclib.ChannelState()
     st.channels['#foo'].ops.add('bar')
     m = ircmsgs.mode('#foo', ('-o', 'bar'))
     st.addMsg(self.irc, m)
     self.failIf('bar' in st.channels['#foo'].ops)
コード例 #11
0
	def banForward(self, irc, msg, channel):
		hostmask = irc.state.nickToHostmask(msg.nick)
		banmaskstyle = conf.supybot.protocols.irc.banmask
		banmask = banmaskstyle.makeBanmask(hostmask)
		irc.queueMsg(ircmsgs.mode(msg.args[0], ("+b", banmask + "$" + channel)))
		self.log.warning("Ban-forwarded %s (%s) from %s to %s.",
				banmask, msg.nick, msg.args[0], channel)
コード例 #12
0
ファイル: plugin.py プロジェクト: GlitterCakes/PoohBot
    def quiet(self, irc, msg, args, channel, nick, expiry):
        """[<channel>] <nick> [<expiry>]

        Quietens <nick> from <channel> for <expiry>.  If <expiry> isn't given,
        the duration is permanent.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        if irc.isNick(nick):
            bannedNick = nick
            try:
                bannedHostmask = irc.state.nickToHostmask(nick)
            except KeyError:
                irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
        else:
            bannedNick = ircutils.nickFromHostmask(nick)
            bannedHostmask = nick
        if not irc.isNick(bannedNick):
            self.log.warning('%q tried to quiet a non nick: %q',
                             msg.prefix, bannedNick)
            raise callbacks.ArgumentError
        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(bannedHostmask)
        if ircutils.strEqual(nick, irc.nick):
            irc.error('I cowardly refuse to quiet myself.', Raise=True)
        thismsg=self.registryValue('message')
        self._sendMsg(irc, ircmsgs.mode(channel, ("+q", banmask)))
        if self.registryValue('SendMsgPvt'):
            self._sendMsg(irc, ircmsgs.privmsg(nick,nick+", "+thismsg ))
        else:
            self._sendMsg(irc, ircmsgs.privmsg(channel,nick+", "+thismsg ))
        def f():
            irc.queueMsg(ircmsgs.mode(channel, ("-q", banmask)))
        if expiry:
        	schedule.addEvent(f, expiry)
コード例 #13
0
ファイル: plugin.py プロジェクト: ProgVal/SupyPlugins
 def do381(self, irc, msg):
     self.log.info("OperUp: Received 381 (successfully opered up) from "
         "network %s." % irc.network)
     if self.registryValue("operModes"):
         self.log.info("OperUp: Opered up on %s, sending user modes %s"
             % (irc.network, ''.join(self.registryValue("operModes"))))
         irc.sendMsg(ircmsgs.mode(irc.nick, 
             self.registryValue("operModes")))
コード例 #14
0
 def do381(self, irc, msg):
     self.log.info("OperUp: Received 381 (successfully opered up) from "
         "network %s.", irc.network)
     if self.registryValue("operModes"):
         self.log.info("OperUp: Opered up on %s, sending user modes %s",
             irc.network, ''.join(self.registryValue("operModes")))
         irc.sendMsg(ircmsgs.mode(irc.nick,
             self.registryValue("operModes")))
コード例 #15
0
 def deoper(self, irc, msg, args):
     """takes no arguments.
     Makes the bot deoper by setting user modes -Oo on itself.
     """
     if irc.nested:
         irc.error("This command cannot be nested.", Raise=True)
     irc.sendMsg(ircmsgs.mode(irc.nick, "-Oo"))
     irc.replySuccess()
コード例 #16
0
ファイル: plugin.py プロジェクト: affix/Fedbot
 def get_bans(self, irc):
     global queue
     for channel in irc.state.channels.keys():
         if not self.registryValue('enabled', channel):
             continue
         if channel not in self.bans:
             self.bans[channel] = []
         queue.queue(ircmsgs.mode(channel, 'b'))
コード例 #17
0
 def deoper(self, irc, msg, args):
     """takes no arguments.
     Makes the bot deoper by setting user modes -Oo on itself.
     """
     if irc.nested:
         irc.error("This command cannot be nested.", Raise=True)
     irc.sendMsg(ircmsgs.mode(irc.nick, "-Oo"))
     irc.replySuccess()
コード例 #18
0
    def moderate(self, irc, msg, args, channel):
        """[<channel>]

        Sets +m on <channel>, making it so only ops and voiced users can
        send messages to the channel.  <channel> is only necessary if the
        message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
コード例 #19
0
    def unlock(self, irc, msg, args, channel):
        """[<channel>]

        Locks the topic (sets the mode +t) in <channel>.  <channel> is only
        necessary if the message isn't sent in the channel itself.
        """
        irc.queueMsg(ircmsgs.mode(channel, '-t'))
        irc.noReply()
コード例 #20
0
ファイル: plugin.py プロジェクト: rostob/Limnoria
    def unmoderate(self, irc, msg, args, channel):
        """[<channel>]

        Sets -m on <channel>, making it so everyone can
        send messages to the channel.  <channel> is only necessary if the
        message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
コード例 #21
0
ファイル: plugin.py プロジェクト: rostob/Limnoria
    def moderate(self, irc, msg, args, channel):
        """[<channel>]

        Sets +m on <channel>, making it so only ops and voiced users can
        send messages to the channel.  <channel> is only necessary if the
        message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
コード例 #22
0
ファイル: plugin.py プロジェクト: rostob/Limnoria
    def mode(self, irc, msg, args, channel, modes):
        """[<channel>] <mode> [<arg> ...]

        Sets the mode in <channel> to <mode>, sending the arguments given.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, modes))
コード例 #23
0
    def unmoderate(self, irc, msg, args, channel):
        """[<channel>]

        Sets -m on <channel>, making it so everyone can
        send messages to the channel.  <channel> is only necessary if the
        message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
コード例 #24
0
    def mode(self, irc, msg, args, channel, modes):
        """[<channel>] <mode> [<arg> ...]

        Sets the mode in <channel> to <mode>, sending the arguments given.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        self._sendMsg(irc, ircmsgs.mode(channel, modes))
コード例 #25
0
    def unlock(self, irc, msg, args, channel):
        """[<channel>]

        Unlocks the topic (sets the mode -t) in <channel>.  <channel> is only
        necessary if the message isn't sent in the channel itself.
        """
        self._checkManageCapabilities(irc, msg, channel)
        irc.queueMsg(ircmsgs.mode(channel, '-t'))
        irc.noReply()
コード例 #26
0
ファイル: plugin.py プロジェクト: ElectroCode/Limnoria
    def unlock(self, irc, msg, args, channel):
        """[<channel>]

        Unlocks the topic (sets the mode -t) in <channel>.  <channel> is only
        necessary if the message isn't sent in the channel itself.
        """
        self._checkManageCapabilities(irc, msg, channel)
        irc.queueMsg(ircmsgs.mode(channel, '-t'))
        irc.noReply()
コード例 #27
0
ファイル: plugin.py プロジェクト: unit193/ubuntuunreg
 def doMode(self, irc, msg):
     channel = msg.args[0]
     mainchan = channel.replace('-unregged', '')
     if (channel.endswith('-unregged') and mainchan in self.registryValue('channels')) and channel in irc.state.channels:
         modes = ircutils.separateModes(msg.args[1:])
         for (mode, value) in modes:
             if mode == '+i':
                 kicks = []
                 for user in irc.state.channels[channel].users:
                     if not (user in irc.state.channels[channel].ops or user in irc.state.channels[channel].voices):
                         kicks.append(user)
                 if 'r' in irc.state.channels[channel].modes:
                     for user in kicks:
                         irc.queueMsg(ircmsgs.IrcMsg('REMOVE %s %s :%s' % (channel, user, self.registryValue('kickMessage') % (mainchan, mainchan))))
                     irc.queueMsg(ircmsgs.mode(channel, '-ir'))
                 else:
                     for user in kicks:
                         irc.queueMsg(ircmsgs.kick(channel, user, self.registryValue('kickMessage') % (mainchan, mainchan)))
                     irc.queueMsg(ircmsgs.mode(channel, '-i'))
コード例 #28
0
    def unlock(self, irc, msg, args, channel):
        """[<channel>]

        Unlocks the topic (sets the mode -t) in <channel>.  <channel> is only
        necessary if the message isn't sent in the channel itself.
        """
        if not self._checkManageCapabilities(irc, msg, channel):
            capabilities = self.registryValue('requireManageCapability')
            irc.errorNoCapability(capabilities, Raise=True)
        irc.queueMsg(ircmsgs.mode(channel, '-t'))
        irc.noReply()
コード例 #29
0
ファイル: plugin.py プロジェクト: kg-bot/SupyBot
 def make_and_join_channel(self, irc, nick):
     channel_length = 15
     channel_characters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
     channel_name_chars = []
     for character in xrange(channel_length):
         channel_name_chars.append(random.choice(channel_characters))
     channel_name = '#%s' % ''.join(channel_name_chars)
     irc.queueMsg(ircmsgs.join(channel_name))
     time.sleep(7)
     irc.queueMsg(ircmsgs.mode(channel_name, '+i'))
     self._invite(irc, nick, channel_name)
コード例 #30
0
ファイル: plugin.py プロジェクト: Elwell/supybot
    def unlock(self, irc, msg, args, channel):
        """[<channel>]

        Unlocks the topic (sets the mode -t) in <channel>.  <channel> is only
        necessary if the message isn't sent in the channel itself.
        """
        if not self._checkManageCapabilities(irc, msg, channel):
            capabilities = self.registryValue('requireManageCapability')
            irc.errorNoCapability(capabilities, Raise=True)
        irc.queueMsg(ircmsgs.mode(channel, '-t'))
        irc.noReply()
コード例 #31
0
    def moderate(self, irc, msg, args, channel, nick):
        """[channel] nick
		Bascule tous les utilisateurs du canal en mode +v excépté 'nick' puis
		passe le canal en mode +m
		"""
        if not channel:
            channel = msg.args[0]
        if channel in irc.state.channels:
            # TODO: Spécifier la liste des nick au différents canaux
            self.nicks_moderated.append(nick)
            self.voice_func(irc, msg, args, channel)
            irc.queueMsg(ircmsgs.devoice(channel, nick))
            #self.removeNick (irc, channel, nick, "Avertissement")
            irc.queueMsg(ircmsgs.mode(channel, ['+m']))
コード例 #32
0
ファイル: plugin.py プロジェクト: WnP/archange
	def moderate (self, irc, msg, args, channel, nick):
		"""[channel] nick
		Bascule tous les utilisateurs du canal en mode +v excépté 'nick' puis
		passe le canal en mode +m
		"""
		if not channel:
			channel = msg.args[0]
		if channel in irc.state.channels:
			# TODO: Spécifier la liste des nick au différents canaux
			self.nicks_moderated.append (nick)
			self.voice_func (irc, msg, args, channel)
			irc.queueMsg (ircmsgs.devoice(channel, nick))
			#self.removeNick (irc, channel, nick, "Avertissement")
			irc.queueMsg (ircmsgs.mode(channel, ['+m']))
コード例 #33
0
ファイル: plugin.py プロジェクト: affix/Fedbot
 def doJoin(self, irc, msg):
     global queue
     for channel in msg.args[0].split(','):
         if msg.nick:
             self.doLog(irc, channel,
                    '*** %s (%s) has joined %s\n' % (msg.nick, msg.prefix.split('!', 1)[1], channel))
         else:
             self.doLog(irc, channel,
                    '*** %s has joined %s\n' % (msg.prefix, channel))
         if not channel in self.bans.keys():
             self.bans[channel] = []
         if msg.prefix.split('!', 1)[0] == irc.nick:
             queue.queue(ircmsgs.mode(channel, 'b'))
     nick = msg.nick.lower() or msg.prefix.lower().split('!', 1)[0]
     self.nicks[nick] = msg.prefix.lower()
コード例 #34
0
ファイル: plugin.py プロジェクト: Affix/Fedbot
    def quiet(self, irc, msg, args, channel, nick, expiry):
        """[<channel>] <nick> [<expiry>]

        Quietens <nick> from <channel> for <expiry>.  If <expiry> isn't given,
        the duration is permanent.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        if ircutils.strEqual(nick, irc.nick):
            irc.error('I cowardly refuse to quiet myself.', Raise=True)
        thismsg=self.registryValue('message')
        self._sendMsg(irc, ircmsgs.mode(channel, ("+q", nick)))
        if self.registryValue('SendMsgPvt'):
            self._sendMsg(irc, ircmsgs.privmsg(nick,nick+", "+thismsg ))
        else:
            self._sendMsg(irc, ircmsgs.privmsg(channel,nick+", "+thismsg ))
        def f():
            irc.queueMsg(ircmsgs.mode(channel, ("-q", nick)))
        schedule.addEvent(f, expiry)
コード例 #35
0
	def stopGame(self,irc,msg,args):
		self.gameMode=0
		x=0
		witness=" "
		while x < 3:
			if self.player[x]['role'] is not "killer":
				witness = "witness "
			else:
				witness = ""
				irc.reply("%s was the %s %swearing a %s shirt."%(self.player['name'][x],self.player[x]['role'],witness,self.player[x]['colour']), prefixNick=False)
				x+=1

		irc.queueMsg(ircmsgs.mode(self.channel, "-m"))
		self._devoice(irc, self.player['joined'])

		self.abort=[]
		self.channel=""
		self.roles={}
		self.roles['sane']=0
		self.roles['deluded']=0
		self.roles['killer']=0

		self.player={}
		self.player['joined']=[]
		self.player['name']=[]

		self.player[0]={}
		self.player[0]['user']=""
		self.player[0]['role']=""
		self.player[0]['colour']=""
		self.player[0]['voted']=[]

		self.player[1]={}
		self.player[1]['user']=""
		self.player[1]['role']=""
		self.player[1]['colour']=""
		self.player[1]['voted']=[]

		self.player[2]={}
		self.player[2]['user']=""
		self.player[2]['role']=""
		self.player[2]['colour']=""
		self.player[2]['voted']=[]
コード例 #36
0
ファイル: plugin.py プロジェクト: nW44b/Limnoria
 def extra_modes():
     try:
         user = ircdb.users.getUser(ircdb.users.getUserId(msg.prefix))
     except KeyError:
         return
     pattern = re.compile("-|\+")
     for item in self.registryValue("extra", channel):
         try:
             username, modes = pattern.split(item, maxsplit=1)
             modes = item[len(username)] + modes
         except ValueError:  # No - or + in item
             log.error(("%r is not a valid item for " "supybot.plugins.AutoMode.extra") % item)
             continue
         if username != user.name:
             continue
         else:
             self.log.info("Scheduling auto-modes %s of %s in %s.", modes, msg.prefix, channel)
             modes = [modes] + ([msg.nick] * len(pattern.sub("", modes)))
             schedule_msg(ircmsgs.mode(channel, modes), lambda: False)
             break
コード例 #37
0
ファイル: plugin.py プロジェクト: affix/Fedbot
    def quiet(self, irc, msg, args, channel, nick, expiry):
        """[<channel>] <nick> [<expiry>]

        Quietens <nick> from <channel> for <expiry>.  If <expiry> isn't given,
        the duration is permanent.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        if ircutils.strEqual(nick, irc.nick):
            irc.error('I cowardly refuse to quiet myself.', Raise=True)
        thismsg = self.registryValue('message')
        self._sendMsg(irc, ircmsgs.mode(channel, ("+q", nick)))
        if self.registryValue('SendMsgPvt'):
            self._sendMsg(irc, ircmsgs.privmsg(nick, nick + ", " + thismsg))
        else:
            self._sendMsg(irc, ircmsgs.privmsg(channel, nick + ", " + thismsg))

        def f():
            irc.queueMsg(ircmsgs.mode(channel, ("-q", nick)))

        schedule.addEvent(f, expiry)
コード例 #38
0
ファイル: plugin.py プロジェクト: tpapaioa/Limnoria
 def extra_modes():
     try:
         user = ircdb.users.getUser(ircdb.users.getUserId(msg.prefix))
     except KeyError:
         return
     pattern = re.compile(r'-|\+')
     for item in self.registryValue('extra', channel, network):
         try:
             username, modes = pattern.split(item, maxsplit=1)
             modes = item[len(username)] + modes
         except ValueError: # No - or + in item
             log.error(('%r is not a valid item for '
                     'supybot.plugins.AutoMode.extra') % item)
             continue
         if username != user.name:
             continue
         else:
             self.log.info('Scheduling auto-modes %s of %s in %s @ %s.',
                           modes, msg.prefix, channel, network)
             modes = [modes] + \
                     ([msg.nick]*len(pattern.sub('', modes)))
             schedule_msg(ircmsgs.mode(channel, modes), lambda :False)
             break
コード例 #39
0
ファイル: plugin.py プロジェクト: GlitterCakes/PoohBot
    def unquiet(self, irc, msg, args, channel, nick):
        """[<channel>] <nick> [<expiry>]

        Quietens <nick> from <channel> for <expiry>.  If <expiry> isn't given,
        the duration is permanent.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        if irc.isNick(nick):
            bannedNick = nick
            try:
                bannedHostmask = irc.state.nickToHostmask(nick)
            except KeyError:
                irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
        else:
            bannedNick = ircutils.nickFromHostmask(nick)
            bannedHostmask = nick
        if not irc.isNick(bannedNick):
            self.log.warning('%q tried to quiet a non nick: %q',
                             msg.prefix, bannedNick)
            raise callbacks.ArgumentError
        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(bannedHostmask)
        irc.queueMsg(ircmsgs.mode(channel, ("-q", banmask)))
コード例 #40
0
def quiet(channel, hostmask, prefix='', msg=None):
    """Returns a MODE to quiet nick on channel."""
    return ircmsgs.mode(channel, ('+q', hostmask), prefix, msg)
コード例 #41
0
ファイル: plugin.py プロジェクト: GlitterCakes/PoohBot
 def f():
     irc.queueMsg(ircmsgs.mode(channel, ("-q", banmask)))
コード例 #42
0
ファイル: test.py プロジェクト: bnrubin/Bantracker
 def deop(self):
     msg = ircmsgs.mode(self.channel, ('-o', self.irc.nick),
                 'Chanserv!service@service')
     self.irc.feedMsg(msg)
コード例 #43
0
ファイル: plugin.py プロジェクト: ProgVal/SupyPlugins
 def deoper(self, irc, msg, args):
     """takes no arguments.
     Makes the bot deoper by setting user modes -Oo on itself.
     """
     irc.sendMsg(ircmsgs.mode(irc.nick, "-Oo"))
     irc.replySuccess()
コード例 #44
0
    def _slot(self, lastItem):
        irc = lastItem.irc
        msg = lastItem.msg
        channel = lastItem.channel
        prefix = lastItem.prefix
        nick = prefix.split('!')[0]
        kind = lastItem.kind

        if not ircutils.isChannel(channel):
                return
        if not self.registryValue('enable', channel):
            return

        try:
            ircdb.users.getUser(msg.prefix) # May raise KeyError
            capability = self.registryValue('exempt')
            if capability:
                if ircdb.checkCapability(msg.prefix,
                        ','.join([channel, capability])):
                    self.log.info('Not punishing %s: they are immune.' %
                            prefix)
                    return
        except KeyError:
            pass
        punishment = self.registryValue('%s.punishment' % kind, channel)
        reason = self.registryValue('%s.kickmessage' % kind, channel)
        if not reason:
            reason = self.registryValue('kickmessage').replace('$kind', kind)

        if punishment == 'kick':
            self._eventCatcher(irc, msg, 'kicked', kicked_prefix=prefix)
        if kind == 'kicked':
            reason = _('You exceeded your kick quota.')

        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(prefix)
        if punishment == 'kick':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment.startswith('ban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)

            if punishment.startswith('ban+'):
                delay = int(punishment[4:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        elif punishment.startswith('kban'):
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)

            if punishment.startswith('kban+'):
                delay = int(punishment[5:])
                unban = functools.partial(irc.queueMsg,
                        ircmsgs.unban(channel, banmask))
                schedule.addEvent(unban, delay + time.time())

        elif punishment.startswith('mode'):
            msg = ircmsgs.mode(channel, punishment[len('mode'):])
            irc.queueMsg(msg)
        elif punishment.startswith('umode'):
            msg = ircmsgs.mode(channel, (punishment[len('umode'):], msg.nick))
            irc.queueMsg(msg)
        elif punishment.startswith('mmode'):
            msg = ircmsgs.mode(channel, (punishment[len('mmode'):], banmask))
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
コード例 #45
0
ファイル: test.py プロジェクト: bnrubin/Bantracker
def quiet(channel, hostmask, prefix='', msg=None):
    """Returns a MODE to quiet nick on channel."""
    return ircmsgs.mode(channel, ('+q', hostmask), prefix, msg)
コード例 #46
0
ファイル: test_ircmsgs.py プロジェクト: ElectroCode/Limnoria
 def testMode(self):
     m = ircmsgs.mode('#foo', ('-b', 'foo!bar@baz'))
     s = str(m)
     self.assertEqual(s, 'MODE #foo -b :foo!bar@baz\r\n')
コード例 #47
0
 def testMode(self):
     m = ircmsgs.mode('#foo', ('-b', 'foo!bar@baz'))
     s = str(m)
     self.assertEqual(s, 'MODE #foo -b :foo!bar@baz\r\n')
コード例 #48
0
ファイル: plugin.py プロジェクト: affix/Fedbot
 def f():
     irc.queueMsg(ircmsgs.mode(channel, ("-q", nick)))
コード例 #49
0
ファイル: plugin.py プロジェクト: Steve-V/bot1st-modules
 def __reloadLists(self, irc, channel):
     msg = ircmsgs.mode(channel, ['+beI'])
     irc.queueMsg(msg)