mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-10-17 17:37:22 +02:00
Let's notice when we can't change the topic.
This commit is contained in:
parent
547137dc1c
commit
9f14d126ce
@ -93,12 +93,21 @@ class Topic(callbacks.Privmsg):
|
|||||||
newTopic = self._joinTopic(channel, topics)
|
newTopic = self._joinTopic(channel, topics)
|
||||||
irc.queueMsg(ircmsgs.topic(channel, newTopic))
|
irc.queueMsg(ircmsgs.topic(channel, newTopic))
|
||||||
|
|
||||||
|
def _canChangeTopic(self, irc, channel):
|
||||||
|
c = irc.state.channels[channel]
|
||||||
|
if irc.nick not in c.ops and 't' in c.modes:
|
||||||
|
irc.error('I can\'t change the topic, I\'m not opped and %s '
|
||||||
|
'is +t.' % channel, Raise=True)
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def add(self, irc, msg, args, channel):
|
def add(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <topic>
|
"""[<channel>] <topic>
|
||||||
|
|
||||||
Adds <topic> to the topics for <channel>. <channel> is only necessary
|
Adds <topic> to the topics for <channel>. <channel> is only necessary
|
||||||
if the message isn't sent in the channel itself.
|
if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
topic = privmsgs.getArgs(args)
|
topic = privmsgs.getArgs(args)
|
||||||
separator = self.registryValue('separator', channel)
|
separator = self.registryValue('separator', channel)
|
||||||
if separator in topic:
|
if separator in topic:
|
||||||
@ -117,6 +126,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
Shuffles the topics in <channel>. <channel> is only necessary if the
|
Shuffles the topics in <channel>. <channel> is only necessary if the
|
||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
newtopic = irc.state.getTopic(channel)
|
newtopic = irc.state.getTopic(channel)
|
||||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||||
if len(topics) == 0 or len(topics) == 1:
|
if len(topics) == 0 or len(topics) == 1:
|
||||||
@ -139,6 +149,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
<channel> is only necessary if the message isn't sent in the channel
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
itself.
|
itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||||
num = len(topics)
|
num = len(topics)
|
||||||
if num == 0 or num == 1:
|
if num == 0 or num == 1:
|
||||||
@ -226,6 +237,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
s/regexp/replacement/flags. <channel> is only necessary if the message
|
s/regexp/replacement/flags. <channel> is only necessary if the message
|
||||||
isn't sent in the channel itself.
|
isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
(number, regexp) = privmsgs.getArgs(args, required=2)
|
(number, regexp) = privmsgs.getArgs(args, required=2)
|
||||||
try:
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
@ -265,6 +277,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
to topics starting the from the end of the topic. <channel> is only
|
to topics starting the from the end of the topic. <channel> is only
|
||||||
necessary if the message isn't sent in the channel itself.
|
necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
try:
|
try:
|
||||||
number = int(privmsgs.getArgs(args))
|
number = int(privmsgs.getArgs(args))
|
||||||
if number > 0:
|
if number > 0:
|
||||||
@ -314,6 +327,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
Restores the topic to the last topic set by the bot. <channel> is only
|
Restores the topic to the last topic set by the bot. <channel> is only
|
||||||
necessary if the message isn't sent in the channel itself.
|
necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
|
self._canChangeTopic(irc, channel)
|
||||||
try:
|
try:
|
||||||
topics = self.lastTopics[channel]
|
topics = self.lastTopics[channel]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user