]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/message.rb
message.rb: fix "I'm Stupid(TM)" bug in [1100]
[user/henk/code/ruby/rbot.git] / lib / rbot / message.rb
index 41658c6b29c8a1a83edac35146c40374504c1fe8..9881503c3f10a074a7f8ff0aff4ae988dadbe69b 100644 (file)
@@ -4,20 +4,27 @@
 # :title: IRC message datastructures
 
 module Irc
-  BotConfig.register BotConfigArrayValue.new('core.address_prefix',
-    :default => [], :wizard => true,
-    :desc => "what non nick-matching prefixes should the bot respond to as if addressed (e.g !, so that '!foo' is treated like 'rbot: foo')"
-  )
 
-  BotConfig.register BotConfigBooleanValue.new('core.reply_with_nick',
-    :default => false, :wizard => true,
-    :desc => "if true, the bot will prepend the nick to what he has to say when replying (e.g. 'markey: you can't do that!')"
-  )
 
-  BotConfig.register BotConfigStringValue.new('core.nick_postfix',
-    :default => ':', :wizard => true,
-    :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
-  )
+  class Bot
+    module Config
+      Config.register ArrayValue.new('core.address_prefix',
+        :default => [], :wizard => true,
+        :desc => "what non nick-matching prefixes should the bot respond to as if addressed (e.g !, so that '!foo' is treated like 'rbot: foo')"
+      )
+
+      Config.register BooleanValue.new('core.reply_with_nick',
+        :default => false, :wizard => true,
+        :desc => "if true, the bot will prepend the nick to what he has to say when replying (e.g. 'markey: you can't do that!')"
+      )
+
+      Config.register StringValue.new('core.nick_postfix',
+        :default => ':', :wizard => true,
+        :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
+      )
+    end
+  end
+
 
   # Define standard IRC attriubtes (not so standard actually,
   # but the closest thing we have ...)
@@ -164,6 +171,13 @@ module Irc
       "#{@source.user}@#{@source.host}" rescue @source.to_s
     end
 
+    # Access the botuser corresponding to the source, if any
+    #
+    def botuser
+      source.botuser rescue @bot.auth.everyone
+    end
+
+
     # Was the message from an identified user?
     def identified?
       return @identified