]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/note.rb
plugin(hangman): fixes word generator closes #9
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / note.rb
index 8b6e5272124e530b59efda7d80532fcda40d80b3..e0a7be293a05a192375e4aed7e03cebe72ad347c 100644 (file)
@@ -12,12 +12,16 @@ class NotePlugin < Plugin
 
   Note = Struct.new('Note', :time, :from, :private, :text)
 
+  Config.register Config::BooleanValue.new 'note.private_message',
+    :default => false,
+    :desc => 'Send all notes in private messages instead of channel messages.'
+
   def initialize
     super
     return if @registry.length < 1
     debug 'Checking registry for old-formatted notes...'
     n = 0
-    @registry.dup.each_key do |key|
+    @registry.keys.each do |key|
       unless key == key.downcase
         @registry[key.downcase] = @registry[key] + (@registry[key.downcase] || [])
         @registry.delete key
@@ -40,15 +44,18 @@ class NotePlugin < Plugin
       pub = []
       priv = []
       @registry[nick].each do |n|
-        s = "[#{n.time.strftime('%H:%M')}] <#{n.from}> #{n.text}"
-        (n.private ? priv : pub).push s
+        s = "[#{n.time.strftime('%b-%e %H:%M')}] <#{n.from}> #{n.text}"
+        if n.private or @bot.config['note.private_message']
+          priv << s
+        else
+          pub << s
+        end
       end
-      if !pub.empty?
+      unless pub.empty?
         @bot.say m.replyto, "#{m.sourcenick}, you have notes! " +
           pub.join(' ')
       end
-
-      if !priv.empty?
+      unless priv.empty?
         @bot.say m.sourcenick, 'you have notes! ' + priv.join(' ')
       end
       @registry.delete nick