From ce741a1f0e5dfc49b6a5ce333c35fc99fe1dbf62 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 28 Mar 2003 17:30:10 +0000 Subject: [PATCH] Added changetopic --- plugins/Topic.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/Topic.py b/plugins/Topic.py index c54d226ec..690bf13e6 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -87,6 +87,31 @@ class Topic(callbacks.Privmsg): else: irc.error(msg, conf.replyNoCapability % capability) + def changetopic(self, irc, msg, args): + "[] " + channel = privmsgs.getChannel(msg, args) + (number, regexp, replacement) = privmsgs.getArgs(args, needed=3) + try: + number = int(number) + r = re.compile(regexp, re.I) + except ValueError: + irc.error(msg, 'The argument must be a number.') + return + except sre_constants.error, e: + irc.error(msg, debug.exnToString(e)) + return + topics = irc.state.getTopic(channel).split(self.topicSeparator) + topic = topics.pop(number) + (topic, name) = self.topicUnformatter.match(topic).groups() + if name != ircdb.users.getUserName(msg.prefix) and \ + not ircdb.checkCapabilities(msg.prfix, ('op', 'admin')): + irc.error(msg, 'You can only modify your own topics.') + return + newTopic = self.topicFormatter % (r.sub(replacement, topic), name) + topics.insert(number, newTopic) + newTopic = self.topicSeparator.join(topics) + irc.queueMsg(ircmsgs.topic(channel, newTopic)) + def removetopic(self, irc, msg, args): "[] (if not sent in the channel itself) " channel = privmsgs.getChannel(msg, args)