本文整理汇总了Python中supybot.ircdb.isAntiCapability函数的典型用法代码示例。如果您正苦于以下问题:Python isAntiCapability函数的具体用法?Python isAntiCapability怎么用?Python isAntiCapability使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isAntiCapability函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
def add(self, irc, msg, args, user, capability):
"""<name|hostmask> <capability>
Gives the user specified by <name> (or the user to whom <hostmask>
currently maps) the specified capability <capability>
"""
# Ok, the concepts that are important with capabilities:
#
### 1) No user should be able to elevate their privilege to owner.
### 2) Admin users are *not* superior to #channel.ops, and don't
### have God-like powers over channels.
### 3) We assume that Admin users are two things: non-malicious and
### and greedy for power. So they'll try to elevate their
### privilege to owner, but they won't try to crash the bot for
### no reason.
# Thus, the owner capability can't be given in the bot. Admin
# users can only give out capabilities they have themselves (which
# will depend on supybot.capabilities and its child default) but
# generally means they can't mess with channel capabilities.
if ircutils.strEqual(capability, 'owner'):
irc.error(_('The "owner" capability can\'t be added in the '
'bot. Use the supybot-adduser program (or edit the '
'users.conf file yourself) to add an owner '
'capability.'))
return
if ircdb.isAntiCapability(capability) or \
ircdb.checkCapability(msg.prefix, capability):
user.addCapability(capability)
ircdb.users.setUser(user)
irc.replySuccess()
else:
irc.error(_('You can\'t add capabilities you don\'t have.'))
示例2: remove
def remove(self, irc, msg, args, user, capability):
"""<name|hostmask> <capability>
Takes from the user specified by <name> (or the user to whom
<hostmask> currently maps) the specified capability <capability>
"""
if ircdb.checkCapability(msg.prefix, capability) or ircdb.isAntiCapability(capability):
try:
user.removeCapability(capability)
ircdb.users.setUser(user)
irc.replySuccess()
except KeyError:
irc.error(_("That user doesn't have that capability."))
else:
s = _("You can't remove capabilities you don't have.")
irc.error(s)
示例3: defaultcapability
def defaultcapability(self, irc, msg, args, action, capability):
"""{add|remove} <capability>
Adds or removes (according to the first argument) <capability> from the
default capabilities given to users (the configuration variable
supybot.capabilities stores these).
"""
if action == "add":
conf.supybot.capabilities().add(capability)
irc.replySuccess()
elif action == "remove":
try:
conf.supybot.capabilities().remove(capability)
irc.replySuccess()
except KeyError:
if ircdb.isAntiCapability(capability):
irc.error("That capability wasn't in " "supybot.capabilities.")
else:
anticap = ircdb.makeAntiCapability(capability)
conf.supybot.capabilities().add(anticap)
irc.replySuccess()
示例4: testIsAntiCapability
def testIsAntiCapability(self):
self.failIf(ircdb.isAntiCapability('foo'))
self.failIf(ircdb.isAntiCapability('#foo,bar'))
self.failUnless(ircdb.isAntiCapability('-foo'))
self.failUnless(ircdb.isAntiCapability('#foo,-bar'))
self.failUnless(ircdb.isAntiCapability('#foo.bar,-baz'))