mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
Merge pull request #974 from GLolol/topic-allow-separator
Topic: remove limitation forbidding the topic separator in topic.add
This commit is contained in:
commit
cb441da644
@ -79,6 +79,11 @@ conf.registerChannelValue(Topic, 'requireManageCapability',
|
|||||||
channel-level capabilities.
|
channel-level capabilities.
|
||||||
Note that absence of an explicit anticapability means user has
|
Note that absence of an explicit anticapability means user has
|
||||||
capability.""")))
|
capability.""")))
|
||||||
|
conf.registerChannelValue(Topic, 'allowSeparatorinTopics',
|
||||||
|
registry.Boolean(True, _("""Determines whether the bot will allow
|
||||||
|
topics containing the defined separator to be used. You may want
|
||||||
|
to disable this if you are signing all topics by nick (see the 'format'
|
||||||
|
option for ways to adjust this).""")))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -48,6 +48,7 @@ _ = PluginInternationalization('Topic')
|
|||||||
|
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
|
|
||||||
|
|
||||||
def canChangeTopic(irc, msg, args, state):
|
def canChangeTopic(irc, msg, args, state):
|
||||||
assert not state.channel
|
assert not state.channel
|
||||||
callConverter('channel', irc, msg, args, state)
|
callConverter('channel', irc, msg, args, state)
|
||||||
@ -60,9 +61,11 @@ def canChangeTopic(irc, msg, args, state):
|
|||||||
state.error(format(_('I can\'t change the topic, I\'m not (half)opped '
|
state.error(format(_('I can\'t change the topic, I\'m not (half)opped '
|
||||||
'and %s is +t.'), state.channel), Raise=True)
|
'and %s is +t.'), state.channel), Raise=True)
|
||||||
|
|
||||||
|
|
||||||
def getTopic(irc, msg, args, state, format=True):
|
def getTopic(irc, msg, args, state, format=True):
|
||||||
separator = state.cb.registryValue('separator', state.channel)
|
separator = state.cb.registryValue('separator', state.channel)
|
||||||
if separator in args[0]:
|
if separator in args[0] and not \
|
||||||
|
state.cb.registryValue('allowSeparatorinTopics', state.channel):
|
||||||
state.errorInvalid('topic', args[0],
|
state.errorInvalid('topic', args[0],
|
||||||
format(_('The topic must not include %q.'),
|
format(_('The topic must not include %q.'),
|
||||||
separator))
|
separator))
|
||||||
@ -73,6 +76,7 @@ def getTopic(irc, msg, args, state, format=True):
|
|||||||
topic = ircutils.standardSubstitute(irc, msg, formatter, env)
|
topic = ircutils.standardSubstitute(irc, msg, formatter, env)
|
||||||
state.args.append(topic)
|
state.args.append(topic)
|
||||||
|
|
||||||
|
|
||||||
def getTopicNumber(irc, msg, args, state):
|
def getTopicNumber(irc, msg, args, state):
|
||||||
def error(s):
|
def error(s):
|
||||||
state.errorInvalid(_('topic number'), s)
|
state.errorInvalid(_('topic number'), s)
|
||||||
@ -103,15 +107,19 @@ addConverter('topic', getTopic)
|
|||||||
addConverter('topicNumber', getTopicNumber)
|
addConverter('topicNumber', getTopicNumber)
|
||||||
addConverter('canChangeTopic', canChangeTopic)
|
addConverter('canChangeTopic', canChangeTopic)
|
||||||
|
|
||||||
|
|
||||||
def splitTopic(topic, separator):
|
def splitTopic(topic, separator):
|
||||||
return list(filter(None, topic.split(separator)))
|
return list(filter(None, topic.split(separator)))
|
||||||
|
|
||||||
datadir = conf.supybot.directories.data()
|
datadir = conf.supybot.directories.data()
|
||||||
filename = conf.supybot.directories.data.dirize('Topic.pickle')
|
filename = conf.supybot.directories.data.dirize('Topic.pickle')
|
||||||
|
|
||||||
|
|
||||||
class Topic(callbacks.Plugin):
|
class Topic(callbacks.Plugin):
|
||||||
|
|
||||||
"""This plugin allows you to use many topic-related functions,
|
"""This plugin allows you to use many topic-related functions,
|
||||||
such as Add, Undo, and Remove."""
|
such as Add, Undo, and Remove."""
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Topic, self)
|
self.__parent = super(Topic, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
@ -233,7 +241,8 @@ class Topic(callbacks.Plugin):
|
|||||||
if capabilities:
|
if capabilities:
|
||||||
for capability in re.split(r'\s*;\s*', capabilities):
|
for capability in re.split(r'\s*;\s*', capabilities):
|
||||||
if capability.startswith('channel,'):
|
if capability.startswith('channel,'):
|
||||||
capability = ircdb.makeChannelCapability(channel, capability[8:])
|
capability = ircdb.makeChannelCapability(
|
||||||
|
channel, capability[8:])
|
||||||
if capability and ircdb.checkCapability(msg.prefix, capability):
|
if capability and ircdb.checkCapability(msg.prefix, capability):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user