Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding colors

  • Loading branch information...
commit 69bbc72a0b7ad64443f94cb6a717a5dd78ffc589 1 parent f19bb4e
@wraithan wraithan authored
Showing with 69 additions and 1 deletion.
  1. +39 −0 API.md
  2. +27 −0 lib/colors.js
  3. +3 −1 lib/irc.js
View
39 API.md
@@ -247,3 +247,42 @@ described above.
### Client.disconnect(message)
Disconnects from the IRC server sending the specified parting message.
+
+irc.colors
+------------------------------------
+
+This contains the set of colors available and a function to wrap text in a color.
+
+The following color choices are available:
+
+ {
+ white: '\u000300',
+ black: '\u000301',
+ dark_blue: '\u000302',
+ dark_green: '\u000303',
+ light_red: '\u000304',
+ dark_red: '\u000305',
+ magenta: '\u000306',
+ orange: '\u000307',
+ yellow: '\u000308',
+ light_green: '\u000309',
+ cyan: '\u000310',
+ light_cyan: '\u000311',
+ light_blue: '\u000312',
+ light_magenta: '\u000313',
+ gray: '\u000314',
+ light_gray: '\u000315',
+ reset: '\u000f',
+ }
+
+### irc.colors.codes
+
+An object containing the above colors.
+
+### irc.colors.wrap(color, text [, reset_color])
+
+Takes a color by name, text, and optionally what color to return.
+
+`color` is the name of the color as a string
+`text` is the text you want wrapped
+`reset_color` is the color you want set in the end, defaults to `reset`
View
27 lib/colors.js
@@ -0,0 +1,27 @@
+codes = {
+ white: '\u000300',
+ black: '\u000301',
+ dark_blue: '\u000302',
+ dark_green: '\u000303',
+ light_red: '\u000304',
+ dark_red: '\u000305',
+ magenta: '\u000306',
+ orange: '\u000307',
+ yellow: '\u000308',
+ light_green: '\u000309',
+ cyan: '\u000310',
+ light_cyan: '\u000311',
+ light_blue: '\u000312',
+ light_magenta: '\u000313',
+ gray: '\u000314',
+ light_gray: '\u000315',
+ reset: '\u000f',
+};
+exports.codes = codes;
+
+function wrap(color, text, reset_color) {
+ reset_color = typeof(a) != 'undefined' ? a : 'reset';

what exactly is a? won't it always be undefined?

@damianb
damianb added a note

@aeosynth judging by context, probably should be reset_color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return codes[color] + text + codes[reset_color];
+};
+exports.wrap = wrap;
+
View
4 lib/irc.js
@@ -18,11 +18,13 @@
*/
exports.Client = Client;
-
var net = require('net');
var tls = require('tls');
var util = require('util');
+var colors = require('./colors');
+exports.colors = colors;
+
const replyFor = { // {{{
"200" : {
"name" : "rpl_tracelink",
@aeosynth

what exactly is a? won't it always be undefined?

@damianb

@aeosynth judging by context, probably should be reset_color.

Please sign in to comment.
Something went wrong with that request. Please try again.