mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 10:42:55 +01:00
Topic: run autopep8 on plugin.py
This commit is contained in:
parent
4f38958b70
commit
cef54fcfa3
@ -49,6 +49,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)
|
||||||
@ -61,6 +62,7 @@ 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] and not \
|
if separator in args[0] and not \
|
||||||
@ -75,6 +77,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)
|
||||||
@ -105,15 +108,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)
|
||||||
@ -167,13 +174,13 @@ class Topic(callbacks.Plugin):
|
|||||||
stack = self.undos.setdefault(channel, [])
|
stack = self.undos.setdefault(channel, [])
|
||||||
stack.append(topics)
|
stack.append(topics)
|
||||||
maxLen = self.registryValue('undo.max', channel)
|
maxLen = self.registryValue('undo.max', channel)
|
||||||
del stack[:len(stack)-maxLen]
|
del stack[:len(stack) - maxLen]
|
||||||
|
|
||||||
def _addRedo(self, channel, topics):
|
def _addRedo(self, channel, topics):
|
||||||
stack = self.redos.setdefault(channel, [])
|
stack = self.redos.setdefault(channel, [])
|
||||||
stack.append(topics)
|
stack.append(topics)
|
||||||
maxLen = self.registryValue('undo.max', channel)
|
maxLen = self.registryValue('undo.max', channel)
|
||||||
del stack[:len(stack)-maxLen]
|
del stack[:len(stack) - maxLen]
|
||||||
|
|
||||||
def _getUndo(self, channel):
|
def _getUndo(self, channel):
|
||||||
try:
|
try:
|
||||||
@ -235,7 +242,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
|
||||||
@ -405,7 +413,7 @@ class Topic(callbacks.Plugin):
|
|||||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||||
L = []
|
L = []
|
||||||
for (i, t) in enumerate(topics):
|
for (i, t) in enumerate(topics):
|
||||||
L.append(format(_('%i: %s'), i+1, utils.str.ellipsisify(t, 30)))
|
L.append(format(_('%i: %s'), i + 1, utils.str.ellipsisify(t, 30)))
|
||||||
s = utils.str.commaAndify(L)
|
s = utils.str.commaAndify(L)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
list = wrap(list, ['inChannel'])
|
list = wrap(list, ['inChannel'])
|
||||||
|
Loading…
Reference in New Issue
Block a user