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


Python ircmsgs.ban函数代码示例

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


在下文中一共展示了ban函数的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

        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

示例2: testBan

 def testBan(self):
     channel = '#osu'
     ban = '*!*@*.edu'
     exception = '*!*@*ohio-state.edu'
     noException = ircmsgs.ban(channel, ban)
     self.assertEqual(ircutils.separateModes(noException.args[1:]),
                      [('+b', ban)])
     withException = ircmsgs.ban(channel, ban, exception)
     self.assertEqual(ircutils.separateModes(withException.args[1:]),
                      [('+b', ban), ('+e', exception)])
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:10,代码来源:test_ircmsgs.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

        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

示例4: doPrivmsg

 def doPrivmsg(self, irc, msg):
     channel, text = msg.args
     text = text.lower()
     if '#' in channel:
         #print self.regex
         #irc.reply('testing %s against %s' % (text, self._regexString))
         if self.regex.match(text):
             try:
                 hostmask = irc.state.nickToHostmask(msg.nick)
             except KeyError:
                 return
             (nick, user, host) = ircutils.splitHostmask(hostmask)
             user = self._fnUser.sub('*', user)
             banmask = ircutils.joinHostmask('*', user, msg.host)
             if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
                 return
             irc.queueMsg(ban(channel, banmask, 'For swearing. 5 minute timeout'))
             irc.queueMsg(kick(channel, msg.nick, 'For swearing'))
             def unBan():
                 if channel in irc.state.channels and \
                    banmask in irc.state.channels[channel].bans:
                     irc.queueMsg(unban(channel, banmask))
             schedule.addEvent(unBan, time.time()+300)
         elif 'fag' in text.split():
             try:
                 hostmask = irc.state.nickToHostmask(msg.nick)
             except KeyError:
                 return
             (nick, user, host) = ircutils.splitHostmask(hostmask)
             irc.reply('No thanks %s I don\'t smoke' % user)
     return msg
开发者ID:chan-jesus,项目名称:no-cussing-supybot-plugin,代码行数:31,代码来源:plugin.py

示例5: saveLast

	def saveLast(self,irc,msg,match):
		r".+"
		channel = msg.args[0]

		try: self.buffer[channel]
		except: self.buffer[channel]=[]

# Stuff for multikick
		if channel in self.kickuser:
			for each in self.kickuser[channel]:
				if each in msg.nick.lower() and not self.kickuser[channel][each]['num'] <= 0:
					irc.queueMsg(ircmsgs.ban(msg.args[0], msg.nick))
					irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, "{}".format(self.kickuser[channel][each]['msg'].replace('#n',str(self.kickuser[channel][each]['num'])))))
					self.kickuser[channel][each]['num']-=1
					def un():
						irc.queueMsg(ircmsgs.unban(msg.args[0],msg.nick))
					schedule.addEvent(un,time.time()+random.randint(10,60)) # 30,120
# END
		line = match.group(0).replace('\x01ACTION','*').strip('\x01')

		if msg.nick.lower() in self.annoyUser:
			def fu():
				irc.queueMsg(ircmsgs.IrcMsg('NOTICE {} :\x02\x03{},{}{}'.format(msg.nick,random.randint(0,15),random.randint(0,15),line)))
			schedule.addEvent(fu,time.time()+random.randint(2,60))

		if re.match(r"^u[/].*[/].*[/].*$", match.group(0)) or re.match(r"^s[/].*[/].*$", match.group(0)):
			return 1
		self.buffer[channel].insert(0,[msg.nick,line])
		if len(self.buffer[channel]) > self.buffsize: self.buffer[channel].pop(self.buffsize)
		return 1
开发者ID:jacksonmj,项目名称:StewieGriffin,代码行数:30,代码来源:plugin.py

示例6: floodPunish

	def floodPunish(self, irc, msg, floodType, dummy = False):
		channel = msg.args[0]

		if (not irc.nick in irc.state.channels[channel].ops) and\
		   (not irc.nick in irc.state.channels[channel].halfops):
			self.log.warning("%s flooded in %s, but not opped.",\
				msg.nick, channel)
			return

		if msg.nick in self.immunities:
			self.log.debug("Not punnishing %s, they are immune.",
				msg.nick)
			return

		if msg.nick in irc.state.channels[channel].ops or\
		   msg.nick in irc.state.channels[channel].halfops or\
		   msg.nick in irc.state.channels[channel].voices:
			self.log.debug("%s flooded in %s. But"\
				+ " I will not punish them because they have"\
				+ " special access.", msg.nick, channel)
			return

		if ircdb.checkCapability(msg.prefix, 'trusted') or\
		   ircdb.checkCapability(msg.prefix, 'admin') or\
		   ircdb.checkCapability(msg.prefix, channel + ',op'):
			self.log.debug("%s flooded in %s. But"\
				+ " I will not punish them because they are"\
				+ " trusted.", msg.nick, channel)
			return

		if msg.host in self.offenses and self.offenses[msg.host] > 2:
			hostmask = irc.state.nickToHostmask(msg.nick)
			banmaskstyle = conf.supybot.protocols.irc.banmask
			banmask = banmaskstyle.makeBanmask(hostmask)
			if not dummy:
				irc.queueMsg(ircmsgs.ban(channel, banmask))
			self.log.warning("Banned %s (%s) from %s for repeated"\
				+ " flooding.", banmask, msg.nick, channel)

		reason = floodType + " flood detected."
		if floodType == "Paste":
			reason += " Use a pastebin like pastebin.ubuntu.com or gist.github.com."

		if not dummy:
			irc.queueMsg(ircmsgs.kick(channel, msg.nick, reason))

		self.log.warning("Kicked %s from %s for %s flooding.",\
				msg.nick, channel, floodType)

		# Don't schedule the same nick twice
		if not (msg.host in self.offenses):
			schedule.addEvent(self.clearOffenses, time.time()+300,
					args=[msg.host])
			self.offenses[msg.host] = 0 # Incremented below
		self.offenses[msg.host] += 1

		self.immunities[msg.nick] = True
		schedule.addEvent(self.unImmunify, time.time()+3,
				args=[msg.nick])
开发者ID:ShadowNinja,项目名称:Limnoria-plugins,代码行数:59,代码来源:plugin.py

示例7: doBan

 def doBan():
     irc.queueMsg(ircmsgs.ban(channel, banmask))
     if expiry > 0:
         def f():
             if channel in irc.state.channels and \
                banmask in irc.state.channels[channel].bans:
                 irc.queueMsg(ircmsgs.unban(channel, banmask))
         schedule.addEvent(f, expiry)
开发者ID:Affix,项目名称:Fedbot,代码行数:8,代码来源:plugin.py

示例8: doBan

 def doBan():
     if irc.state.channels[channel].isOp(bannedNick):
         irc.queueMsg(ircmsgs.deop(channel, bannedNick))
     irc.queueMsg(ircmsgs.ban(channel, banmask))
     irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
     def f():
         if channel in irc.state.channels and \
            banmask in irc.state.channels[channel].bans:
             irc.queueMsg(ircmsgs.unban(channel, banmask))
     schedule.addEvent(f, 3600)
开发者ID:kyl191,项目名称:aurora,代码行数:10,代码来源:plugin.py

示例9: doJoin

 def doJoin(self, irc, msg):
     channel = msg.args[0]
     if ircutils.strEqual(irc.nick, msg.nick):
         return
     if not self.registryValue('enable', channel):
         return
     fallthrough = self.registryValue('fallthrough', channel)
     def do(type):
         cap = ircdb.makeChannelCapability(channel, type)
         if ircdb.checkCapability(msg.prefix, cap,
                 ignoreOwner=not self.registryValue('owner')):
             if self.registryValue(type, channel):
                 self.log.info('Scheduling auto-%s of %s in %s.',
                               type, msg.prefix, channel)
                 msgmaker = getattr(ircmsgs, type)
                 schedule_msg(msgmaker(channel, msg.nick))
                 raise Continue # Even if fallthrough, let's only do one.
             elif not fallthrough:
                 self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s'
                                ' is not enabled in %s, refusing to fall '
                                'through.', msg.prefix, cap, type, channel)
                 raise Continue
     def schedule_msg(msg):
         def f():
             irc.queueMsg(msg)
         delay = self.registryValue('delay', channel)
         if delay:
             schedule.addEvent(f, time.time() + delay)
         else:
             f()
     try:
         do('op')
         if 'h' in irc.state.supported['prefix']:
             do('halfop')
         do('voice')
     except Continue:
         return
     c = ircdb.channels.getChannel(channel)
     if c.checkBan(msg.prefix) and self.registryValue('ban', channel):
         period = self.registryValue('ban.period', channel)
         if period:
             def unban():
                 try:
                     if msg.prefix in irc.state.channels[channel].bans:
                         irc.queueMsg(ircmsgs.unban(channel, msg.prefix))
                 except KeyError:
                     # We're not in the channel anymore.
                     pass
             schedule.addEvent(unban, time.time()+period)
         banmask =conf.supybot.protocols.irc.banmask.makeBanmask(msg.prefix)
         irc.queueMsg(ircmsgs.ban(channel, banmask))
         irc.queueMsg(ircmsgs.kick(channel, msg.nick))
开发者ID:boamaod,项目名称:Limnoria,代码行数:52,代码来源:plugin.py

示例10: banNick

	def banNick (self, irc, channel, nick, period):
		# Inspiré de la fonction kban du plugin Channel
		banmask = irc.state.nickToHostmask(nick)
		if irc.state.channels[channel].isOp(nick):
			return
		else:
			irc.sendMsg(ircmsgs.ban(channel, banmask))
			if period > 0:
				def f():
					if channel in irc.state.channels and \
					   banmask in irc.state.channels[channel].bans:
						irc.sendMsg(ircmsgs.unban(channel, banmask))
				schedule.addEvent(f, time.time () + period)
开发者ID:WnP,项目名称:archange,代码行数:13,代码来源:plugin.py

示例11: _remove_kebab

    def _remove_kebab(self, irc, channel, target):
        prefix = irc.state.nickToHostmask(target)
        host = ircutils.hostFromHostmask(prefix)
        hostmask = "*!*@%s" % host

        irc.queueMsg(ircmsgs.ban(channel, hostmask))
        if target in irc.state.channels[channel].users:
            irc.queueMsg(ircmsgs.kick(channel, target, "Das Volk hat entschieden."))

        def unban():
            irc.queueMsg(ircmsgs.unban(channel, hostmask))

        schedule.addEvent(unban, time.time() + int(self.registryValue("ban_duration")))
开发者ID:buckket,项目名称:supybot-scherbengericht,代码行数:13,代码来源:plugin.py

示例12: feedBan

 def feedBan(self, hostmask, prefix='', channel=None, mode='b'):
     if not channel:
         channel = self.channel
     if not prefix:
         prefix = '[email protected]'
     if mode == 'b':
         ban = ircmsgs.ban(channel, hostmask, prefix=prefix)
     elif mode == 'q':
         ban = quiet(channel, hostmask, prefix=prefix)
     elif mode == 'k':
         ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix)
     elif mode == 'p':
         ban = ircmsgs.part(channel, prefix=hostmask,
                 s='requested by %s (kthxbye!)' %prefix[:prefix.find('!')])
     self.irc.feedMsg(ban)
     return ban
开发者ID:bnrubin,项目名称:Bantracker,代码行数:16,代码来源:test.py

示例13: doJoin

    def doJoin(self, irc, msg):
        channel = msg.args[0]
        if not self.registryValue('enable', channel):
            return
        nick, ident, host = ircutils.splitHostmask(msg.prefix)

        fd = utils.web.getUrlFd('http://rbls.org/%s' % host)
        line = ' '
        while line and not line.startswith('<title>'):
            line = fd.readline()
        if not line:
            return
        if 'is listed in' in line:
            irc.queueMsg(ircmsgs.ban(channel, '*!*@%s' % host))
            irc.queueMsg(ircmsgs.kick(channel, nick))
        else:
            assert 'is not listed' in line
开发者ID:AlanBell,项目名称:Supybot-plugins,代码行数:17,代码来源:plugin.py

示例14: rroulette

    def rroulette(self, irc, msg, args, spin):
        """[spin]

        Fires the revolver.  If the bullet was in the chamber, you're dead.
        Tell me to spin the chambers and I will.
        """
        if spin:
            self._rouletteBullet = random.randrange(0, 6)
            irc.reply('*SPIN* Are you feeling lucky?', prefixNick=False)
            return
        channel = msg.args[0]
        if self._rouletteChamber == self._rouletteBullet:
            self._rouletteBullet = random.randrange(0, 6)
            self._rouletteChamber = random.randrange(0, 6)
            if irc.nick in irc.state.channels[channel].ops or irc.nick in irc.state.channels[channel].halfops:
                try:
                    bannedHostmask = irc.state.nickToHostmask(msg.nick)
                except KeyError:
                    irc.error(format('I haven\'t seen %s.', msg.nick), Raise=True)
                banmaskstyle = conf.supybot.protocols.irc.banmask
                banmask = banmaskstyle.makeBanmask(bannedHostmask, ["nick", "host"])
                if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
                    if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
                        self.log.warning('%q played rroulette, but he\'s got the same hostmask as me, strangely enough.',msg.prefix)
                        irc.error('I\'m not playing this game.')
                        return
                    else:
                        self.log.warning('Using exact hostmask since banmask would '
                        'ban myself.')
                        banmask = bannedHostmask
                        def f():
                            if channel in irc.state.channels and banmask in irc.state.channels[channel].bans:
                                irc.queueMsg(ircmsgs.unban(channel, banmask))
                        schedule.addEvent(f, 60)
                irc.queueMsg(ircmsgs.ban(channel, banmask))
                irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'BANG!'))
            else:
                irc.reply('*BANG* Hey, who put a blank in here?!',
                prefixNick=False)
                irc.reply('reloads and spins the chambers.', action=True)
        else:
            irc.reply('*click*')
            self._rouletteChamber += 1
            self._rouletteChamber %= 6
开发者ID:kyl191,项目名称:aurora,代码行数:44,代码来源:plugin.py

示例15: _punishRelayers

 def _punishRelayers(self, msg):
     assert self._checkRelayMsg(msg), 'Punishing without checking.'
     who = msg.prefix
     channel = msg.args[0]
     def notPunishing(irc, s, *args):
         self.log.info('Not punishing %s in %s on %s: %s.',
                       msg.prefix, channel, irc.network, s, *args)
     for irc in world.ircs:
         if channel in irc.state.channels:
             if irc.nick in irc.state.channels[channel].ops:
                 if who in irc.state.channels[channel].bans:
                     notPunishing(irc, 'already banned')
                 else:
                     self.log.info('Punishing %s in %s on %s for relaying.',
                                   who, channel, irc.network)
                     irc.sendMsg(ircmsgs.ban(channel, who))
                     kmsg = _('You seem to be relaying, punk.')
                     irc.sendMsg(ircmsgs.kick(channel, msg.nick, kmsg))
             else:
                 notPunishing(irc, 'not opped')
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:20,代码来源:plugin.py


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