• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ircmsgs.ban函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了ban函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: _ban

 def _ban(self, irc, nick, channel):
     try:
         hostmask = irc.state.nickToHostmask(nick)
     except KeyError:
         return
     (nick, user, host) = ircutils.splitHostmask(hostmask)
     user = self._fnUser.sub('*', user)
     banmask = ircutils.joinHostmask('*', user, host)
     if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
         return
     irc.queueMsg(ircmsgs.ban(channel, banmask))
     irc.queueMsg(ircmsgs.kick(channel, nick))
     expiry = self.registryValue('autokban.timeout', channel)
     if expiry > 0:
         expiry += time.time()
         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:D0MF,项目名称:supybot-plugins-1,代码行数:20,代码来源:plugin.py


示例17: doPrivmsg

    def doPrivmsg(self, irc, msg):
        """This is called everytime an IRC message is recieved."""
        (recipients,text) = msg.args
        for channel in recipients.split(','):
            if irc.isChannel(channel):
                enable = self.registryValue('enable',channel=channel)
                if not enable:
                        return
                maxKick = self.registryValue('maxKick',channel=channel)
                self.queueKick.enqueue(msg)
                if self.queueKick.len(msg) > 4:
                    #self.queueKick.reset(msg)
                    self.queueBan.enqueue(msg)
                    maxKickBeforeBan = self.registryValue('maxKickToBan',channel=channel)
                    reason = self.registryValue('reasonKick',channel=channel)
                    if self.queueBan.len(msg) > maxKickBeforeBan:
                        #self.queueBan.reset(msg)
                        self.queueLongBan.enqueue(msg)
                        maxBanToLongBan = self.registryValue('maxBanToLongBan',channel=channel)
                        duration = int(0)
                        if self.queueLongBan.len(msg) > maxBanToLongBan:
                            #self.queueLongBan.reset(msg)
                            duration = int(self.registryValue('durationLongBan',channel=channel))
                        else:
                            duration = int(self.registryValue('durationBan',channel=channel))
                        hostmask = irc.state.nickToHostmask(msg.nick)
                        (nick, user, host) = ircutils.splitHostmask(hostmask)
                        banmask = ircutils.joinHostmask('*', '*', host)
                        irc.sendMsg(ircmsgs.ban(channel,banmask))
                        if duration > 0:
                            def ub():
                                if channel in irc.state.channels and banmask in irc.state.channels[channel].bans:
                                    irc.queueMsg(ircmsgs.unban(channel, banmask))
                            schedule.addEvent(ub,time.time()+duration)
                        reason = self.registryValue('reasonBan',channel=channel)
#                        reason = reason % utils.timeElapsed(duration)
#                        irc.sendMsg(ircmsgs.IrcMsg('remove %s %s : %s' % (channel, msg.nick, reason)))
                        irc.reply('remove %s %s : %s' % (channel, msg.nick, reason))
                    self.log.info('remove %s %s : %s' % (channel, msg.nick, reason))
                    irc.sendMsg(ircmsgs.kick(channel, msg.nick, reason))
开发者ID:Affix,项目名称:Fedbot,代码行数:40,代码来源:plugin.py


示例18: inFilter

    def inFilter(self, irc, msg):
        self.filtering = True
        # We need to check for bad words here rather than in doPrivmsg because
        # messages don't get to doPrivmsg is the user is ignored.
        if msg.command == 'PRIVMSG':
            self.updateRegexp()
            s = ircutils.stripFormatting(msg.args[1])
            channel = msg.args[0]
            if ircutils.isChannel(channel) and self.registryValue('kickban', channel):
                if self.regexp.search(s):
                    if irc.nick in irc.state.channels[channel].ops:
                        message = self.registryValue('kickban.message', channel)
                        bannedHostmask = irc.state.nickToHostmask(msg.nick)
                        banmaskstyle = conf.supybot.protocols.irc.banmask
                        banmask = banmaskstyle.makeBanmask(bannedHostmask)
                        irc.queueMsg(ircmsgs.ban(channel, banmask))
                        irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
                        expiry = self.registryValue('kickban.banexpire', channel)
                        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,time.time()+expiry)
                    else:
                        self.log.warning('Should kickban %s from %s, but not opped.',
                                         msg.nick, channel)

            else: 
                if ircutils.isChannel(channel) and self.registryValue('kick', channel):
                 if self.regexp.search(s):
                    if irc.nick in irc.state.channels[channel].ops:
                        message = self.registryValue('kick.message', channel)
                        irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
                    else:
                        self.log.warning('Should kick %s from %s, but not opped.',
                                         msg.nick, channel)
        return msg
开发者ID:Affix,项目名称:Fedbot,代码行数:38,代码来源:plugin.py


示例19: 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)
         try:
             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)
                     def dismiss():
                         """Determines whether or not a mode has already
                         been applied."""
                         l = getattr(irc.state.channels[channel], type+'s')
                         return (msg.nick in l)
                     msgmaker = getattr(ircmsgs, type)
                     schedule_msg(msgmaker(channel, msg.nick),
                             dismiss)
                     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
         except KeyError:
             pass
     def schedule_msg(msg, dismiss):
         def f():
             if not dismiss():
                 irc.queueMsg(msg)
             else:
                 self.log.info('Dismissing auto-mode for %s.' % msg.nick)
         delay = self.registryValue('delay', channel)
         if delay:
             schedule.addEvent(f, time.time() + delay)
         else:
             f()
     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
     try:
         do('op')
         if 'h' in irc.state.supported['prefix']:
             do('halfop')
         do('voice')
     except Continue:
         return
     finally:
         extra_modes()
     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:GlitterCakes,项目名称:PoohBot,代码行数:89,代码来源:plugin.py


示例20: assertBan

 def assertBan(self, query, hostmask, **kwargs):
     m = self.getMsg(query, **kwargs)
     self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
开发者ID:4poc,项目名称:competitionbot,代码行数:3,代码来源:test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ircmsgs.isAction函数代码示例发布时间:2022-05-27
下一篇:
Python ircdb.makeChannelCapability函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap