topic now checks for +t mode before denying topic changes, and also allows halfops in addition to ops.

default required capabilities for topic changes (if topic is +t and user is not an op or halfop), are chan,op and chan,halfop
thanks jemfinch for the suggestions.
This commit is contained in:
Daniel Folkinshteyn 2010-04-11 12:48:08 -04:00
parent 8e84da8391
commit c4e5dbbe0b
3 changed files with 6 additions and 2 deletions

View File

@ -64,7 +64,7 @@ conf.registerChannelValue(Topic.undo, 'max',
registry.NonNegativeInteger(10, """Determines the number of previous registry.NonNegativeInteger(10, """Determines the number of previous
topics to keep around in case the undo command is called.""")) topics to keep around in case the undo command is called."""))
conf.registerChannelValue(Topic, 'requireManageCapability', conf.registerChannelValue(Topic, 'requireManageCapability',
registry.String('admin; channel,op', registry.String('channel,op; channel,halfop',
"""Determines the """Determines the
capabilities required (if any) to make any topic changes, capabilities required (if any) to make any topic changes,
(everything except for read-only operations). Use 'channel,capab' for (everything except for read-only operations). Use 'channel,capab' for

View File

@ -173,7 +173,7 @@ class Topic(callbacks.Plugin):
manually anyway. manually anyway.
""" """
c = irc.state.channels[channel] c = irc.state.channels[channel]
if msg.nick in c.ops: if msg.nick in c.ops or msg.nick in c.halfops or 't' not in c.modes:
return True return True
capabilities = self.registryValue('requireManageCapability') capabilities = self.registryValue('requireManageCapability')
if capabilities: if capabilities:

View File

@ -73,6 +73,10 @@ class TopicTestCase(ChannelPluginTestCase):
def testManageCapabilities(self): def testManageCapabilities(self):
try: try:
self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+o', self.nick),
prefix=self.prefix))
self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+t'),
prefix=self.prefix))
world.testing = False world.testing = False
origuser = self.prefix origuser = self.prefix
self.prefix = 'stuff!stuff@stuff' self.prefix = 'stuff!stuff@stuff'