- def topicaddat(m, num, txt)
- channel = m.channel.downcase
- topic = @bot.channels[m.channel].topic.to_s
- topicarray = topic.split(SEPARATOR)
+ def topicsep(m, ch, txt)
+ return if !@bot.auth.allow?("topic::edit::separator", m.source, m.replyto)
+ if txt
+ sep = txt.strip
+ if sep != ""
+ setsep(ch, sep)
+ end
+ end
+ m.reply "Topic separator set to #{getsep(ch)}"
+ end
+
+ def setsep(ch, sep)
+ raise unless ch.class <= Irc::Channel
+ # TODO multiserver
+ k = ch.downcase
+
+ if @registry.has_key?(k)
+ data = @registry[k]
+ else
+ data = Hash.new
+ end
+
+ oldsep = getsep(ch)
+ topic = ch.topic.text
+ topicarray = topic.split(/\s+#{Regexp.escape(oldsep)}\s*/)
+
+ if sep != oldsep and topicarray.length > 0
+ newtopic = topicarray.join(" #{sep} ")
+ @bot.topic ch, newtopic
+ end
+
+ data[:separator] = sep
+ @registry[k] = data
+ end
+
+ def getsep(ch)
+ raise unless ch.class <= Irc::Channel
+ # TODO multiserver
+ k = ch.downcase
+
+ if @registry.has_key?(k)
+ if @registry[k].has_key?(:separator)
+ return @registry[k][:separator]
+ end
+ end
+ return @separator
+ end
+
+ def topicaddat(m, channel, num, txt)
+ return if !@bot.auth.allow?("topic::edit::add", m.source, m.replyto)
+ sep = getsep(channel)
+ topic = channel.topic.to_s
+ topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)