]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/message.rb
basics botmodule: use #to_s to stringify multiword parameters
[user/henk/code/ruby/rbot.git] / lib / rbot / message.rb
index 62ba746921c5d3ad9c3be29fbb2deaa32011a8b8..3292cb8323a1f9aad8c638c25a69059002a40fda 100644 (file)
@@ -14,10 +14,11 @@ module Irc
     :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
   )
 
-  Color = "\003"
   Bold = "\002"
   Underline = "\037"
   Reverse = "\026"
+  Color = "\003"
+  ColorRx = /#{Color}\d\d?(?:,\d\d?)?/
 
   # base user message class, all user messages derive from this
   # (a user message is defined as having a source hostmask, a target
@@ -65,7 +66,7 @@ module Irc
 
       @identified = false
       if @msg_wants_id && @server.capabilities[:"identify-msg"]
-        if @message =~ /([-+])(.*)/
+        if @message =~ /^([-+])(.*)/
           @identified = ($1=="+")
           @message = $2
         else
@@ -112,7 +113,7 @@ module Irc
     # strip mIRC colour escapes from a string
     def BasicUserMessage.stripcolour(string)
       return "" unless string
-      ret = string.gsub(/\cC\d\d?(?:,\d\d?)?/, "")
+      ret = string.gsub(ColorRx, "")
       #ret.tr!("\x00-\x1f", "")
       ret
     end