diff --git a/plugins/Topic/config.py b/plugins/Topic/config.py index dbef35a33..3ddfff93b 100644 --- a/plugins/Topic/config.py +++ b/plugins/Topic/config.py @@ -66,12 +66,11 @@ conf.registerChannelValue(Topic.undo, 'max', registry.NonNegativeInteger(10, _("""Determines the number of previous topics to keep around in case the undo command is called."""))) conf.registerChannelValue(Topic, 'requireManageCapability', - registry.String('channel,op; channel,halfop', - _("""Determines the + registry.String('admin; channel,op', _("""Determines the 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 channel-level capabilities. - Note that absence of an explicit anticapability means user has + Note that absence of an explicit anticapability means user has capability."""))) diff --git a/plugins/Topic/plugin.py b/plugins/Topic/plugin.py index 0e2d299f0..221919b6b 100644 --- a/plugins/Topic/plugin.py +++ b/plugins/Topic/plugin.py @@ -46,6 +46,7 @@ import supybot.callbacks as callbacks from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Topic') +import supybot.ircdb as ircdb def canChangeTopic(irc, msg, args, state): assert not state.channel @@ -207,7 +208,6 @@ class Topic(callbacks.Plugin): irc.queueMsg(ircmsgs.topic(channel, newTopic)) irc.noReply() - @internationalizeDocstring def _checkManageCapabilities(self, irc, msg, channel): """Check if the user has any of the required capabilities to manage the channel topic. @@ -219,7 +219,7 @@ class Topic(callbacks.Plugin): 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: + if msg.nick in c.ops: return True capabilities = self.registryValue('requireManageCapability') if capabilities: @@ -403,6 +403,9 @@ class Topic(callbacks.Plugin): index into the topics. is only necessary if the message isn't sent in the channel itself. """ + if not self._checkManageCapabilities(irc, msg, channel): + capabilities = self.registryValue('requireManageCapability') + irc.errorNoCapability(capabilities, Raise=True) topics = self._splitTopic(irc.state.getTopic(channel), channel) irc.reply(topics[number]) get = wrap(get, ['inChannel', 'topicNumber']) diff --git a/plugins/Topic/test.py b/plugins/Topic/test.py index 83adcfaee..bb41662da 100644 --- a/plugins/Topic/test.py +++ b/plugins/Topic/test.py @@ -70,18 +70,14 @@ class TopicTestCase(ChannelPluginTestCase): self.assertEqual(m.command, 'TOPIC') self.assertEqual(m.args[0], self.channel) self.assertEqual(m.args[1], 'foo (test) || bar (test)') - + def testManageCapabilities(self): 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 origuser = self.prefix self.prefix = 'stuff!stuff@stuff' self.assertNotError('register nottester stuff', private=True) - + self.assertError('topic add foo') origconf = conf.supybot.plugins.Topic.requireManageCapability() conf.supybot.plugins.Topic.requireManageCapability.setValue('') @@ -90,7 +86,7 @@ class TopicTestCase(ChannelPluginTestCase): world.testing = True self.prefix = origuser conf.supybot.plugins.Topic.requireManageCapability.setValue(origconf) - + def testInsert(self): m = self.getMsg('topic add foo') self.assertEqual(m.args[1], 'foo (test)')