]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/topic.rb
No-parameter commands in the topic plugin weren't recognized anymore. Fix it
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / topic.rb
index 0b266851a2faca929d1ced357b6ca340e90c6ede..9b6ffdb47e0b46af21875efff7f2bb4d55a028ec 100755 (executable)
@@ -45,10 +45,13 @@ class TopicPlugin < Plugin
       ch = m.channel
     else
       ch = m.server.get_channel(param[:channel])
       ch = m.channel
     else
       ch = m.server.get_channel(param[:channel])
-      return m.reply "I am not in channel #{ch}" unless ch
+      unless ch
+        m.reply("I am not in channel #{param[:channel]}")
+        return
+      end
     end
     cmd = param[:command]
     end
     cmd = param[:command]
-    txt = param[:text].join(" ")
+    txt = param[:text].to_s
 
     case cmd
     when /^a(dd|ppend)$/
 
     case cmd
     when /^a(dd|ppend)$/
@@ -91,6 +94,7 @@ class TopicPlugin < Plugin
   end
 
   def topicsep(m, ch, txt)
   end
 
   def topicsep(m, ch, txt)
+    return if !@bot.auth.allow?("topic::edit::separator", m.source, m.replyto)
     if txt
       sep = txt.strip
       if sep != ""
     if txt
       sep = txt.strip
       if sep != ""
@@ -138,6 +142,7 @@ class TopicPlugin < Plugin
   end
 
   def topicaddat(m, channel, num, txt)
   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*/)
     sep = getsep(channel)
     topic = channel.topic.to_s
     topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
@@ -155,6 +160,7 @@ class TopicPlugin < Plugin
   end
 
   def topicdel(m, channel, num)
   end
 
   def topicdel(m, channel, num)
+    return if !@bot.auth.allow?("topic::edit::del", m.source, m.replyto)
     sep = getsep(channel)
     topic = channel.topic.to_s
     topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
     sep = getsep(channel)
     topic = channel.topic.to_s
     topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
@@ -164,7 +170,7 @@ class TopicPlugin < Plugin
   end
 
   def learntopic(m, channel)
   end
 
   def learntopic(m, channel)
-    return if !@bot.auth.allow?("learntopic", m.source, m.replyto)
+    return if !@bot.auth.allow?("topic::store::store", m.source, m.replyto)
     topic = channel.topic.to_s
     k = channel.downcase
     if @registry.has_key?(k)
     topic = channel.topic.to_s
     k = channel.downcase
     if @registry.has_key?(k)
@@ -178,9 +184,9 @@ class TopicPlugin < Plugin
   end
 
   def replacetopic(m, channel, num, txt)
   end
 
   def replacetopic(m, channel, num, txt)
-    return if !@bot.auth.allow?("topic", m.source, m.replyto)
+    return if !@bot.auth.allow?("topic::edit::replace", m.source, m.replyto)
     sep = getsep(channel)
     sep = getsep(channel)
-    topic = @bot.channels[channel].topic.to_s
+    topic = channel.topic.to_s
     topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
     topicarray[num] = txt
     newtopic = topicarray.join(" #{sep} ")
     topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
     topicarray[num] = txt
     newtopic = topicarray.join(" #{sep} ")
@@ -188,23 +194,28 @@ class TopicPlugin < Plugin
   end
 
   def restoretopic(m, channel)
   end
 
   def restoretopic(m, channel)
+    return if !@bot.auth.allow?("topic::store::restore", m.source, m.replyto)
     return if !@bot.auth.allow?("restoretopic", m.source, m.replyto)
     k = channel.downcase
     if @registry.has_key?(k) && @registry[k].has_key?(:topic)
       topic = @registry[k][:topic]
     return if !@bot.auth.allow?("restoretopic", m.source, m.replyto)
     k = channel.downcase
     if @registry.has_key?(k) && @registry[k].has_key?(:topic)
       topic = @registry[k][:topic]
-      @bot.topic channel, topic
+      topicset(m, channel, topic)
     else
       m.reply "I don't remember any topic for this channel"
     end
   end
 
   def topicset(m, channel, text)
     else
       m.reply "I don't remember any topic for this channel"
     end
   end
 
   def topicset(m, channel, text)
-    return if !@bot.auth.allow?("topic", m.source, m.replyto)
+    return if !@bot.auth.allow?("topic::edit::replace", m.source, m.replyto)
     @bot.topic channel, text
   end
 
 end
 plugin = TopicPlugin.new
     @bot.topic channel, text
   end
 
 end
 plugin = TopicPlugin.new
-plugin.map 'topic :command *text', :action => 'handletopic', :public => true, :private => false
-plugin.map 'topic :channel :command *text', :action => 'handletopic', :public => false, :private => true
+
+plugin.map 'topic :command [*text]', :action => 'handletopic', :public => true, :private => false
+plugin.map 'topic :channel :command [*text]', :action => 'handletopic', :public => false, :private => true
+
+plugin.default_auth('*', false)
+