]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Put the Irc attributes back where they belong
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 29 Aug 2007 20:39:15 +0000 (20:39 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 29 Aug 2007 20:39:15 +0000 (20:39 +0000)
lib/rbot/core/utils/extends.rb
lib/rbot/message.rb

index 31a348a94ff8594e756a5b29cc55c4d5bb7551a7..e0c781b194cba78910028f156c2ea735b80f1fe0 100644 (file)
@@ -227,79 +227,6 @@ end
 
 module ::Irc
 
-  # Define standard IRC attriubtes (not so standard actually,
-  # but the closest thing we have ...)
-  Bold = "\002"
-  Underline = "\037"
-  Reverse = "\026"
-  Italic = "\011"
-  NormalText = "\017"
-
-  # Color is prefixed by \003 and followed by optional
-  # foreground and background specifications, two-digits-max
-  # numbers separated by a comma. One of the two parts
-  # must be present.
-  Color = "\003"
-  ColorRx = /#{Color}\d?\d?(?:,\d\d?)?/
-
-  # Standard color codes
-  ColorCode = {
-    :black      => 1,
-    :blue       => 2,
-    :navyblue   => 2,
-    :navy_blue  => 2,
-    :green      => 3,
-    :red        => 4,
-    :brown      => 5,
-    :purple     => 6,
-    :olive      => 7,
-    :yellow     => 8,
-    :limegreen  => 9,
-    :lime_green => 9,
-    :teal       => 10,
-    :aqualight  => 11,
-    :aqua_light => 11,
-    :royal_blue => 12,
-    :hotpink    => 13,
-    :hot_pink   => 13,
-    :darkgray   => 14,
-    :dark_gray  => 14,
-    :lightgray  => 15,
-    :light_gray => 15,
-    :white      => 16
-  }
-
-  # Convert a String or Symbol into a color number
-  def Irc.find_color(data)
-    if Integer === data
-      data
-    else
-      f = if String === data
-            data.intern
-          else
-            data
-          end
-      if ColorCode.key?(f)
-        ColorCode[f] 
-      else
-        0
-      end
-    end
-  end
-
-  # Insert the full color code for a given
-  # foreground/background combination.
-  def Irc.color(fg=nil,bg=nil)
-    str = Color.dup
-    if fg
-     str << Irc.find_color(fg).to_s
-    end
-    if bg
-      str << "," << Irc.find_color(bg).to_s
-    end
-    return str
-  end
-
 
   class BasicUserMessage
 
index 75427a9eea83a6c7f38a68446651e9b4711f3b32..42042b88a2884b2d367ba5a3292cfed5cc87baf0 100644 (file)
@@ -14,6 +14,79 @@ module Irc
     :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
   )
 
+  # Define standard IRC attriubtes (not so standard actually,
+  # but the closest thing we have ...)
+  Bold = "\002"
+  Underline = "\037"
+  Reverse = "\026"
+  Italic = "\011"
+  NormalText = "\017"
+
+  # Color is prefixed by \003 and followed by optional
+  # foreground and background specifications, two-digits-max
+  # numbers separated by a comma. One of the two parts
+  # must be present.
+  Color = "\003"
+  ColorRx = /#{Color}\d?\d?(?:,\d\d?)?/
+
+  # Standard color codes
+  ColorCode = {
+    :black      => 1,
+    :blue       => 2,
+    :navyblue   => 2,
+    :navy_blue  => 2,
+    :green      => 3,
+    :red        => 4,
+    :brown      => 5,
+    :purple     => 6,
+    :olive      => 7,
+    :yellow     => 8,
+    :limegreen  => 9,
+    :lime_green => 9,
+    :teal       => 10,
+    :aqualight  => 11,
+    :aqua_light => 11,
+    :royal_blue => 12,
+    :hotpink    => 13,
+    :hot_pink   => 13,
+    :darkgray   => 14,
+    :dark_gray  => 14,
+    :lightgray  => 15,
+    :light_gray => 15,
+    :white      => 16
+  }
+
+  # Convert a String or Symbol into a color number
+  def Irc.find_color(data)
+    if Integer === data
+      data
+    else
+      f = if String === data
+            data.intern
+          else
+            data
+          end
+      if ColorCode.key?(f)
+        ColorCode[f] 
+      else
+        0
+      end
+    end
+  end
+
+  # Insert the full color code for a given
+  # foreground/background combination.
+  def Irc.color(fg=nil,bg=nil)
+    str = Color.dup
+    if fg
+     str << Irc.find_color(fg).to_s
+    end
+    if bg
+      str << "," << Irc.find_color(bg).to_s
+    end
+    return str
+  end
+
   # base user message class, all user messages derive from this
   # (a user message is defined as having a source hostmask, a target
   # nick/channel and a message part)