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


Python ircdb.checkCapability函数代码示例

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


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

示例1: bombsenabled

    def bombsenabled(self, irc, msg, args, channel, value):
        """[value]

        Sets the value of the allowBombs config value for the channel. Restricted to users with channel timebombadmin capability."""
        statusDescription = "are currently"
        if value:
            # tmp = ircdb.channels.getChannel(channel).defaultAllow - problems with multithreading?
            # ircdb.channels.getChannel(channel).defaultAllow = False
            hasCap = ircdb.checkCapability(msg.prefix, "timebombadmin")
            if (channel == "#powder" or channel == "#powder-dev") and not ircdb.checkCapability(msg.prefix, "admin"):
                irc.error("You need the admin capability to do that")
                return
            # ircdb.channels.getChannel(channel).defaultAllow = tmp

            if hasCap:
                oldValue = self.registryValue("allowBombs", channel)
                try:
                    conf.supybot.plugins.Timebomb.allowBombs.get(channel).set(value)
                except registry.InvalidRegistryValue:
                    irc.error("Value must be either True or False (or On or Off)")
                    return
                if self.registryValue("allowBombs", channel) == oldValue:
                    statusDescription = "were already"
                else:
                    statusDescription = "have now been"
            else:
                irc.error("You need the timebombadmin capability to do that")
                return

        if self.registryValue("allowBombs", channel):
            irc.reply("Timebombs {} enabled in{}".format(statusDescription, channel))
        else:
            irc.reply("Timebombs {} disabled in{}".format(statusDescription, channel))
开发者ID:Brilliant-Minds,项目名称:Limnoria-Plugins,代码行数:33,代码来源:plugin.py

示例2: getUser

 def getUser(self, **kw):
     """ will return a user object tagged with a hostmask for use or None
     """
     if 'protocol' not in kw:
         raise KeyError, 'Need a protocol name'
     else:
         user = None
         if 'username' not in kw:
             raise KeyError, 'Need a username'
         try:
             user = ircdb.users.getUser(kw['username'])
         except KeyError:
             return False
         cap = self.registryValue('capability')
         pcap = self.registryValue('%s.capability' % kw['protocol'])
         if cap:
             if not ircdb.checkCapability(kw['username'], cap):
                 return False
         if pcap:
             if not ircdb.checkCapability(kw['username'], pcap):
                 return False
         if 'password' in kw:
             if not user.checkPassword(kw['password']):
                 return False
         elif 'blob' in kw:
             if not self.checkKey(kw['username'], kw['blob']):
                 return False
         else:
             return False
         user.gwhm = self.buildHostmask(kw['username'], kw['protocol'],
                 kw['peer'])
         user.addAuth(user.gwhm)
         return user
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:33,代码来源:plugin.py

示例3: doPrivmsg

 def doPrivmsg(self, irc, msg):
     assert self is irc.callbacks[0], \
            'Owner isn\'t first callback: %r' % irc.callbacks
     if ircmsgs.isCtcp(msg):
         return
     s = callbacks.addressed(irc.nick, msg)
     if s:
         ignored = ircdb.checkIgnored(msg.prefix)
         if ignored:
             self.log.info('Ignoring command from %s.', msg.prefix)
             return
         maximum = conf.supybot.abuse.flood.command.maximum()
         self.commands.enqueue(msg)
         if conf.supybot.abuse.flood.command() \
            and self.commands.len(msg) > maximum \
            and not ircdb.checkCapability(msg.prefix, 'owner') \
            and not ircdb.checkCapability(msg.prefix, 'admin'):
             punishment = conf.supybot.abuse.flood.command.punishment()
             banmask = ircutils.banmask(msg.prefix)
             self.log.info('Ignoring %s for %s seconds due to an apparent '
                           'command flood.', banmask, punishment)
             ircdb.ignores.add(banmask, time.time() + punishment)
             irc.reply('You\'ve given me %s commands within the last '
                       'minute; I\'m now ignoring you for %s. Try #fedora-botgames.' %
                       (maximum,
                        utils.timeElapsed(punishment, seconds=False)))
             return
         try:
             tokens = callbacks.tokenize(s, channel=msg.args[0])
             self.Proxy(irc, msg, tokens)
         except SyntaxError, e:
             irc.queueMsg(callbacks.error(msg, str(e)))
开发者ID:Affix,项目名称:Fedbot,代码行数:32,代码来源:plugin.py

示例4: 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

示例5: _kban

 def _kban(self, irc, msg, args, bannedNick, reason):
 # Check that they're not trying to make us kickban ourself.
     channel = msg.args[0]
     if not irc.isNick(bannedNick[0]):
         self.log.warning('%q tried to kban a non nick: %q',
                          msg.prefix, bannedNick)
         raise callbacks.ArgumentError
     elif bannedNick == irc.nick:
         self.log.warning('%q tried to make me kban myself.', msg.prefix)
         irc.error('I cowardly refuse to kickban myself.')
         return
     if not reason:
         reason = msg.nick
     try:
         bannedHostmask = irc.state.nickToHostmask(bannedNick)
     except KeyError:
         irc.error(format('I haven\'t seen %s.', bannedNick), Raise=True)
     capability = ircdb.makeChannelCapability(channel, 'op')
     banmaskstyle = conf.supybot.protocols.irc.banmask
     banmask = banmaskstyle.makeBanmask(bannedHostmask, ["host", "user"])
     # Check (again) that they're not trying to make us kickban ourself.
     if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
         if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
             self.log.warning('%q tried to make me kban myself.',msg.prefix)
             irc.error('I cowardly refuse to ban myself.')
             return
         else:
             self.log.warning('Using exact hostmask since banmask would '
                              'ban myself.')
             banmask = bannedHostmask
     # Now, let's actually get to it.  Check to make sure they have
     # #channel,op and the bannee doesn't have #channel,op; or that the
     # bannee and the banner are both the same person.
     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)
     if bannedNick == msg.nick:
         doBan()
     elif ircdb.checkCapability(msg.prefix, capability):
         if ircdb.checkCapability(bannedHostmask, capability):
             self.log.warning('%s tried to ban %q, but both have %s',
                              msg.prefix, bannedHostmask, capability)
             irc.error(format('%s has %s too, you can\'t ban him/her/it.',
                              bannedNick, capability))
         else:
             doBan()
     else:
         self.log.warning('%q attempted kban without %s',
                          msg.prefix, capability)
         irc.errorNoCapability(capability)
         exact,nick,user,host
开发者ID:kyl191,项目名称:aurora,代码行数:58,代码来源:plugin.py

示例6: votes

 def votes(self, irc, msg, args, channel, pid):
     """[channel] <id>
     Retrieves the vote count for a poll.
     """
     if channel and msg.args[0] in irc.state.channels:
         if msg.args[0] != channel:
             if ircdb.checkCapability(msg.prefix, 'admin') or ircdb.checkCapability(msg.prefix, 'owner'):
                 irc.error("Not Implemented")
             else:
                 irc.errorInvalid('argument', channel)
         elif msg.args[0] == channel:
             irc.error("Not Implemented")
开发者ID:IotaSpencer,项目名称:supyplugins,代码行数:12,代码来源:plugin.py

示例7: do

        def do(type):
            cap = ircdb.makeChannelCapability(channel, type)
            cap_auto = ircdb.makeChannelCapability(channel, "auto" + type)
            try:
                apply_mode = ircdb.checkCapability(
                    msg.prefix,
                    cap,
                    ignoreOwner=not self.registryValue("owner"),
                    ignoreChannelOp=True,
                    ignoreDefaultAllow=True,
                )
            except KeyError:
                apply_mode = False
            if self.registryValue("alternativeCapabilities", channel):
                try:
                    override = ircdb.checkCapability(
                        msg.prefix,
                        cap_auto,
                        ignoreOwner=not self.registryValue("owner"),
                        ignoreChannelOp=True,
                        ignoreDefaultAllow=True,
                    )
                except KeyError:
                    override = False
            else:
                override = False
            if apply_mode or override:
                if override or 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
开发者ID:nW44b,项目名称:Limnoria,代码行数:50,代码来源:plugin.py

示例8: newpoll

    def newpoll(self, irc, msg, args, channel, interval, answers, question):
        """<number of minutes for announce interval> <"answer,answer,..."> question
        Creates a new poll with the given question and answers. <channel> is
        only necessary if the message isn't sent in the channel itself."""

        capability = ircdb.makeChannelCapability(channel, 'op')
        if not ircdb.checkCapability(msg.prefix, capability):
            irc.error('Need ops')
            return

        db = self.getDb(channel)
        cursor = db.cursor()
        self._execute_query(cursor, 'INSERT INTO polls VALUES (?,?,?,?,?)', None, datetime.datetime.now(), 1, None, question)
        pollid = cursor.lastrowid

        # used to add choices into db. each choice represented by character, starting at capital A (code 65)
        def genAnswers():
            for i, answer in enumerate(answers, start=65):
                yield pollid, chr(i), answer

        cursor.executemany('INSERT INTO choices VALUES (?,?,?)', genAnswers())

        db.commit()

        irc.reply('Started new poll #%s' % pollid)

        # function called by schedule event. can not have args
        def runPoll():
            self._runPoll(irc, channel, pollid)

        # start schedule. will announce poll/choices to channel at interval
        schedule.addPeriodicEvent(runPoll, interval*60, name='%s_poll_%s' % (channel, pollid))
        self.poll_schedules.append('%s_poll_%s' % (channel, pollid))
开发者ID:tz18,项目名称:Supybot-Polls,代码行数:33,代码来源:plugin.py

示例9: _preCheck

 def _preCheck(self, irc, msg, target, action):
     if self.registryValue('requireRegistration', target):
         try:
             foo = ircdb.users.getUser(msg.prefix)
         except KeyError:
             irc.errorNotRegistered(Raise=True)
     capability = self.registryValue('requireCapability', target)
     if capability:
         if not ircdb.checkCapability(msg.prefix, capability):
             irc.errorNoCapability(capability, Raise=True)
     if irc.isChannel(target):
         if self.registryValue('requirePresenceInChannel', target) and \
            msg.nick not in irc.state.channels[target].users:
             irc.error(format(_('You must be in %s to %q in there.'),
                              target, action), Raise=True)
         c = ircdb.channels.getChannel(target)
         if c.lobotomized:
             irc.error(format(_('I\'m lobotomized in %s.'), target),
                       Raise=True)
         if not c._checkCapability(self.name()):
             irc.error(_('That channel has set its capabilities so as to '
                       'disallow the use of this plugin.'), Raise=True)
     elif action == 'say' and not self.registryValue('allowPrivateTarget'):
         irc.error(format(_('%q cannot be used to send private messages.'),
                          action),
                   Raise=True)
开发者ID:4poc,项目名称:competitionbot,代码行数:26,代码来源:plugin.py

示例10: checkAndAct

	def checkAndAct (self,irc,prefix,chan,kind,items,text,msg):
		protected = ircdb.makeChannelCapability(chan.name, 'protected')
		if ircdb.checkCapability(prefix, protected):
			return
		for pattern in list(items.keys()):
			item = chan.kinds[kind][pattern]
			if item.enable == '1':
				for match in re.finditer(item.re, text):
					if match:
						act = item.action
						account = ''
						gecos = ''
						if prefix.split('!')[0] in chan.nicks:
							(prefix,account,gecos) = chan.nicks[prefix.split('!')[0]]
						act = act.replace('$nick',prefix.split('!')[0])
						act = act.replace('$hostmask',prefix)
						act = act.replace('$account',account)
						act = act.replace('$username',gecos)
						act = act.replace('$id',str(item.uid))
						act = act.replace('$channel',chan.name)
						act = act.replace('$*',text)
						if act.find(' :') != -1:
							a = text.split(' :')
							if len(a) > 1:
							    act = act.replace('$text',text.split(' :')[1])
						for (i, j) in enumerate(match.groups()):
							act = re.sub(r'\$' + str(i+1), match.group(i+1), act)
						self.act(irc,msg,chan.name,act,item.owner)
						break
开发者ID:ncoevoet,项目名称:ChanReg,代码行数:29,代码来源:plugin.py

示例11: _checkManageCapabilities

    def _checkManageCapabilities(self, irc, msg, channel):
        """Check if the user has any of the required capabilities to manage
        the channel topic.

        The list of required capabilities is in requireManageCapability
        channel config.

        Also allow if the user is a chanop. Since they can change the topic
        manually anyway.
        """
        c = irc.state.channels[channel]
        if msg.nick in c.ops or msg.nick in c.halfops or 't' not in c.modes:
            return True
        capabilities = self.registryValue('requireManageCapability', channel)
        if capabilities:
            for capability in re.split(r'\s*;\s*', capabilities):
                if capability.startswith('channel,'):
                    capability = ircdb.makeChannelCapability(
                        channel, capability[8:])
                if capability and ircdb.checkCapability(msg.prefix, capability):
                    return
            capabilities = self.registryValue('requireManageCapability',
                    channel)
            irc.errorNoCapability(capabilities, Raise=True)
        else:
            return
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:26,代码来源:plugin.py

示例12: voice

    def voice(self, irc, msg, args, channel, nicks):
        """[<channel>] [<nick> ...]

        If you have the #channel,voice capability, this will voice all the
        <nick>s you provide.  If you don't provide any <nick>s, this will
        voice you. <channel> is only necessary if the message isn't sent in the
        channel itself.
        """
        if nicks:
            if len(nicks) == 1 and msg.nick in nicks:
                capability = "voice"
            else:
                capability = "op"
        else:
            nicks = [msg.nick]
            capability = "voice"
        capability = ircdb.makeChannelCapability(channel, capability)
        if ircdb.checkCapability(msg.prefix, capability):

            def f(L):
                return ircmsgs.voices(channel, L)

            self._sendMsgs(irc, nicks, f)
        else:
            irc.errorNoCapability(capability)
开发者ID:fbesser,项目名称:Limnoria,代码行数:25,代码来源:plugin.py

示例13: add

 def add(self, channel, user, id, option):
     db = self._getDb(channel)
     cursor = db.cursor()
     # Only the poll starter or an admin can add options
     cursor.execute("""SELECT started_by FROM polls
                       WHERE id=%s""",
                       id)
     if cursor.rowcount == 0:
         raise dbi.NoRecordError
     if not ((user.id == cursor.fetchone()[0]) or
             (ircdb.checkCapability(user.id, 'admin'))):
         raise PollError, \
                 'That poll isn\'t yours and you aren\'t an admin.'
     # and NOBODY can add options once a poll has votes
     cursor.execute("""SELECT COUNT(user_id) FROM votes
                       WHERE poll_id=%s""",
                       id)
     if int(cursor.fetchone()[0]) != 0:
         raise PollError, 'Cannot add options to a poll with votes.'
     # Get the next highest id
     cursor.execute("""SELECT MAX(id)+1 FROM options
                       WHERE poll_id=%s""",
                       id)
     option_id = cursor.fetchone()[0] or 1
     cursor.execute("""INSERT INTO options VALUES
                       (%s, %s, %s)""",
                       option_id, id, option)
     db.commit()
开发者ID:Latinx,项目名称:supybot,代码行数:28,代码来源:plugin.py

示例14: boosterset

    def boosterset(self, irc, msg, args, text):
        """<booster>

        Sets a new booster"""
        channell = msg.args[0]
        network = irc.network
        nick = msg.nick
        global targett
        global boosterr
        #if nick in self.registryValue('blacklist').split(' '):
             #irc.error("You've been blacklisted!", Raise=True
        if msg.args[0] in self.registryValue('channels').split(' '):
            global targett
        else: irc.error('Not a valid channel! Please contact Vlad', Raise=True)
        if nick in irc.state.channels[channell].ops:
            capability='ops'
            if not ircdb.checkCapability(msg.prefix, capability):
                irc.errorNoCapability(capability, Raise=True)
            
            target_line = linecache.getline(channell+network, 1).rstrip("\n")
            booster_line = linecache.getline(channell+network, 2).rstrip("\n")
            reason_line = linecache.getline(channell+network, 3).rstrip("\n")
            boosterrx = text
            oldfile = open(channell+network, 'w')
            oldfile.write(target_line+"\n")
            oldfile.write(boosterrx+"\n")
            oldfile.flush()
            linecache.clearcache()
            irc.reply('Done.')
开发者ID:Vl4dTheImpaler,项目名称:supybot-plugins,代码行数:29,代码来源:plugin.py

示例15: tell

    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if irc.nested:
            irc.error("This command cannot be nested.", Raise=True)
        if target.lower() == "me":
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error("Dude, just give the command.  No need for the tell.")
            return
        if not ircutils.isNick(target):
            irc.errorInvalid("nick", target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error("You just told me, why should I tell myself?", Raise=True)
        if target not in irc.state.nicksToHostmasks and not ircdb.checkCapability(msg.prefix, "owner"):
            # We'll let owners do this.
            s = "I haven't seen %s, I'll let you do the telling." % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = "* %s %s" % (irc.nick, text)
        s = "%s wants me to tell you: %s" % (msg.nick, text)
        irc.replySuccess()
        irc.reply(s, to=target, private=True)
开发者ID:krattai,项目名称:AEBL,代码行数:27,代码来源:plugin.py


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