当前位置: 首页>>代码示例>>Python>>正文


Python ircmsgs.mode函数代码示例

本文整理汇总了Python中supybot.ircmsgs.mode函数的典型用法代码示例。如果您正苦于以下问题:Python mode函数的具体用法?Python mode怎么用?Python mode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _slot

    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)
开发者ID:TameTimmah,项目名称:Supybot-plugins,代码行数:54,代码来源:plugin.py

示例2: quiet

    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)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:35,代码来源:plugin.py

示例3: _slot

    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)
开发者ID:v2k,项目名称:Supybot-plugins,代码行数:35,代码来源:plugin.py

示例4: testAddMsgRemovesOpsProperly

 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)
开发者ID:krattai,项目名称:AEBL,代码行数:7,代码来源:test_irclib.py

示例5: banForward

	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)
开发者ID:ShadowNinja,项目名称:Limnoria-plugins,代码行数:7,代码来源:plugin.py

示例6: do381

 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")))
开发者ID:GLolol,项目名称:SupyPlugins,代码行数:7,代码来源:plugin.py

示例7: do381

 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")))
开发者ID:ProgVal,项目名称:SupyPlugins,代码行数:8,代码来源:plugin.py

示例8: deoper

 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()
开发者ID:liam-middlebrook,项目名称:SupyPlugins,代码行数:8,代码来源:plugin.py

示例9: get_bans

 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'))
开发者ID:Affix,项目名称:Fedbot,代码行数:8,代码来源:plugin.py

示例10: unlock

    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()
开发者ID:Kefkius,项目名称:mazabot,代码行数:8,代码来源:plugin.py

示例11: unlock

    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()
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:9,代码来源:plugin.py

示例12: unlock

    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()
开发者ID:Elwell,项目名称:supybot,代码行数:11,代码来源:plugin.py

示例13: make_and_join_channel

 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)
开发者ID:kg-bot,项目名称:SupyBot,代码行数:11,代码来源:plugin.py

示例14: moderate

	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']))
开发者ID:WnP,项目名称:archange,代码行数:14,代码来源:plugin.py

示例15: doJoin

 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()
开发者ID:Affix,项目名称:Fedbot,代码行数:15,代码来源:plugin.py


注:本文中的supybot.ircmsgs.mode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。