]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Minor message optimizations
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 20 Feb 2007 23:01:14 +0000 (23:01 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 20 Feb 2007 23:01:14 +0000 (23:01 +0000)
lib/rbot/message.rb

index 62ba746921c5d3ad9c3be29fbb2deaa32011a8b8..f96515ffccaba090978ae95ea7a2158427a6d1ea 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
@@ -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