mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
change Topic to have a default required capability set, for all write operations.
by default, now only allows chanops, and users with admin or channel,op capability to change topics
This commit is contained in:
parent
7ec1ca2070
commit
c0986e1122
@ -66,8 +66,7 @@ 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
|
||||
channel-level capabilities.
|
||||
|
@ -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. <channel> 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'])
|
||||
|
@ -73,10 +73,6 @@ class TopicTestCase(ChannelPluginTestCase):
|
||||
|
||||
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'
|
||||
|
Loading…
Reference in New Issue
Block a user