mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
Add rfe #1004006, {add,remove,{un,}set}capability can accept multiple capabilities.
This commit is contained in:
parent
4f09fad147
commit
7f22a1c9b6
@ -568,47 +568,53 @@ class Channel(callbacks.Privmsg):
|
|||||||
ignores = privmsgs.checkChannelCapability(ignores, 'op')
|
ignores = privmsgs.checkChannelCapability(ignores, 'op')
|
||||||
|
|
||||||
def addcapability(self, irc, msg, args, channel):
|
def addcapability(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <name|hostmask> <capability>
|
"""[<channel>] <name|hostmask> <capability> [<capability> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will give the user
|
If you have the #channel,op capability, this will give the user
|
||||||
currently identified as <name> (or the user to whom <hostmask> maps)
|
currently identified as <name> (or the user to whom <hostmask> maps)
|
||||||
the capability <capability> in the channel. <channel> is only necessary
|
the capability <capability> in the channel. <channel> is only necessary
|
||||||
if the message isn't sent in the channel itself.
|
if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
(name, capability) = privmsgs.getArgs(args, 2)
|
(name, capabilities) = privmsgs.getArgs(args, 2)
|
||||||
capability = ircdb.makeChannelCapability(channel, capability)
|
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(name)
|
id = ircdb.users.getUserId(name)
|
||||||
user = ircdb.users.getUser(id)
|
user = ircdb.users.getUser(id)
|
||||||
user.addCapability(capability)
|
|
||||||
ircdb.users.setUser(id, user)
|
|
||||||
irc.replySuccess()
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.errorNoUser()
|
irc.errorNoUser()
|
||||||
|
for c in capability.split():
|
||||||
|
c = ircdb.makeChannelCapability(channel, c)
|
||||||
|
user.addCapability(c)
|
||||||
|
ircdb.users.setUser(id, user)
|
||||||
|
irc.replySuccess()
|
||||||
addcapability = privmsgs.checkChannelCapability(addcapability,'op')
|
addcapability = privmsgs.checkChannelCapability(addcapability,'op')
|
||||||
|
|
||||||
def removecapability(self, irc, msg, args, channel):
|
def removecapability(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <name|hostmask> <capability>
|
"""[<channel>] <name|hostmask> <capability> [<capability> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will take from the user
|
If you have the #channel,op capability, this will take from the user
|
||||||
currently identified as <name> (or the user to whom <hostmask> maps)
|
currently identified as <name> (or the user to whom <hostmask> maps)
|
||||||
the capability <capability> in the channel. <channel> is only necessary
|
the capability <capability> in the channel. <channel> is only necessary
|
||||||
if the message isn't sent in the channel itself.
|
if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
(name, capability) = privmsgs.getArgs(args, 2)
|
(name, capabilities) = privmsgs.getArgs(args, 2)
|
||||||
capability = ircdb.makeChannelCapability(channel, capability)
|
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(name)
|
id = ircdb.users.getUserId(name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.errorNoUser()
|
irc.errorNoUser()
|
||||||
return
|
return
|
||||||
user = ircdb.users.getUser(id)
|
user = ircdb.users.getUser(id)
|
||||||
try:
|
fail = []
|
||||||
user.removeCapability(capability)
|
for c in capabilities.split():
|
||||||
except KeyError:
|
cap = ircdb.makeChannelCapability(channel, c)
|
||||||
irc.error('That user doesn\'t have the %s capability.'%capability)
|
try:
|
||||||
return
|
user.removeCapability(cap)
|
||||||
|
except KeyError:
|
||||||
|
fail.append(c)
|
||||||
ircdb.users.setUser(id, user)
|
ircdb.users.setUser(id, user)
|
||||||
|
if fail:
|
||||||
|
irc.error('That user didn\'t have the %s %s.' %
|
||||||
|
(utils.commaAndify(fail),
|
||||||
|
utils.pluralize('capability', len(fail))), Raise=True)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
removecapability = privmsgs.checkChannelCapability(removecapability, 'op')
|
removecapability = privmsgs.checkChannelCapability(removecapability, 'op')
|
||||||
|
|
||||||
@ -637,35 +643,42 @@ class Channel(callbacks.Privmsg):
|
|||||||
privmsgs.checkChannelCapability(setdefaultcapability, 'op')
|
privmsgs.checkChannelCapability(setdefaultcapability, 'op')
|
||||||
|
|
||||||
def setcapability(self, irc, msg, args, channel):
|
def setcapability(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <capability>
|
"""[<channel>] <capability> [<capability> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will add the channel
|
If you have the #channel,op capability, this will add the channel
|
||||||
capability <capability> for all users in the channel. <channel> is
|
capability <capability> for all users in the channel. <channel> is
|
||||||
only necessary if the message isn't sent in the channel itself.
|
only necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
capability = privmsgs.getArgs(args)
|
capabilities = privmsgs.getArgs(args)
|
||||||
c = ircdb.channels.getChannel(channel)
|
chan = ircdb.channels.getChannel(channel)
|
||||||
c.addCapability(capability)
|
for c in capabilities.split():
|
||||||
ircdb.channels.setChannel(channel, c)
|
chan.addCapability(c)
|
||||||
|
ircdb.channels.setChannel(channel, chan)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
setcapability = privmsgs.checkChannelCapability(setcapability, 'op')
|
setcapability = privmsgs.checkChannelCapability(setcapability, 'op')
|
||||||
|
|
||||||
def unsetcapability(self, irc, msg, args, channel):
|
def unsetcapability(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <capability>
|
"""[<channel>] <capability> [<capability> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will unset the channel
|
If you have the #channel,op capability, this will unset the channel
|
||||||
capability <capability> so each user's specific capability or the
|
capability <capability> so each user's specific capability or the
|
||||||
channel default capability will take precedence. <channel> is only
|
channel default capability will take precedence. <channel> is only
|
||||||
necessary if the message isn't sent in the channel itself.
|
necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
capability = privmsgs.getArgs(args)
|
capabilities = privmsgs.getArgs(args)
|
||||||
c = ircdb.channels.getChannel(channel)
|
chan = ircdb.channels.getChannel(channel)
|
||||||
try:
|
fail = []
|
||||||
c.removeCapability(capability)
|
for c in capabilities.split():
|
||||||
ircdb.channels.setChannel(channel, c)
|
try:
|
||||||
irc.replySuccess()
|
chan.removeCapability(c)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('I do not know about that channel capability.')
|
fail.append(c)
|
||||||
|
ircdb.channels.setChannel(channel, chan)
|
||||||
|
if fail:
|
||||||
|
irc.error('I do not know about the %s %s.' %
|
||||||
|
(utils.commaAndify(fail),
|
||||||
|
utils.pluralize('capability', len(fail))), Raise=True)
|
||||||
|
irc.replySuccess()
|
||||||
unsetcapability = privmsgs.checkChannelCapability(unsetcapability, 'op')
|
unsetcapability = privmsgs.checkChannelCapability(unsetcapability, 'op')
|
||||||
|
|
||||||
def capabilities(self, irc, msg, args):
|
def capabilities(self, irc, msg, args):
|
||||||
|
@ -59,6 +59,10 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('channel setcapability -foo')
|
self.assertNotError('channel setcapability -foo')
|
||||||
self.assertNotError('channel unsetcapability -foo')
|
self.assertNotError('channel unsetcapability -foo')
|
||||||
self.assertError('channel unsetcapability -foo')
|
self.assertError('channel unsetcapability -foo')
|
||||||
|
self.assertNotError('channel setcapability -foo bar baz')
|
||||||
|
self.assertRegexp('channel capabilities', 'baz')
|
||||||
|
self.assertNotError('channel unsetcapability -foo baz')
|
||||||
|
self.assertError('channel unsetcapability baz')
|
||||||
|
|
||||||
def testUnban(self):
|
def testUnban(self):
|
||||||
self.assertError('unban foo!bar@baz')
|
self.assertError('unban foo!bar@baz')
|
||||||
|
Loading…
Reference in New Issue
Block a user