- @bot.topic channel, newtopic
- end
-
- def restoretopic(m, channel)
- return if !@bot.auth.allow?("restoretopic", m.source, m.replyto)
- if @registry.has_key?(channel) && @registry[channel].has_key?(:topic)
- topic = @registry[channel][:topic]
- @bot.topic channel, topic
+ changetopic(m, ch, newtopic)
+ end
+
+ def restoretopic(m, ch)
+ return if !@bot.auth.allow?("topic::store::restore", m.source, m.replyto)
+ k = ch.downcase
+ if @registry.has_key?(k) && @registry[k].has_key?(:topic)
+ topic = @registry[k][:topic]
+ topicset(m, ch, topic)
+ else
+ m.reply "I don't remember any topic for #{ch}"
+ end
+ end
+
+ def topicset(m, ch, text)
+ return if !@bot.auth.allow?("topic::edit::replace", m.source, m.replyto)
+ changetopic(m, ch, text)
+ end
+
+ # This method changes the topic on channel +ch+ to +text+, storing
+ # the previous topic for undo
+ def changetopic(m, ch, text)
+ k = ch.downcase
+ if @registry.has_key?(k)
+ data = @registry[k]