]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
note: added config option to privmsg all notes
authorJay Thomas <degradinglight@gmail.com>
Sun, 28 Apr 2013 02:21:19 +0000 (22:21 -0400)
committerJay Thomas <degradinglight@gmail.com>
Sun, 28 Apr 2013 02:21:19 +0000 (22:21 -0400)
data/rbot/plugins/note.rb

index 8b6e5272124e530b59efda7d80532fcda40d80b3..25d122a13b56a71e2abeb02c6c1e232f43f7fcd1 100644 (file)
@@ -12,6 +12,10 @@ 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
@@ -41,14 +45,17 @@ class NotePlugin < Plugin
       priv = []
       @registry[nick].each do |n|
         s = "[#{n.time.strftime('%H:%M')}] <#{n.from}> #{n.text}"
-        (n.private ? priv : pub).push s
+        unless n.private or @bot.config['note.private_message']
+          pub << s
+        else
+          priv << 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