Skip to content

Instantly share code, notes, and snippets.

@FirstWhack
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FirstWhack/9743785 to your computer and use it in GitHub Desktop.
Save FirstWhack/9743785 to your computer and use it in GitHub Desktop.
Supports `-g` flag and strips all others (I expect people to try other flags even though they don't exist)
'use strict';
module.exports = function(bot, IO) {
function color ( args ) {
var outType, base, param;
if ( args.match( /-g/ ) ) { //the only flag for this is g(gradient)
outType = 'gradient=';
} else outType = 'color=';
base = 'http://jhawins.tk/colors.php?';
param = args.toLowerCase()
.replace( /-[a-z]*/, '' )//strip all flags
.match( /([a-z0-9]+)+/g );
args.directreply( base + outType + param + '#.png' );
}
bot.addCommand({
name : 'color',
permissions : {
del : 'NONE'
},
description : 'Displays the' +
'color(s) passed in as RGB, hexadecimal' +
'or hex-shorthand or standard color names' +
'(if it works in CSS it should work here). ' +
' `/color color0[ color1[ ...]]`' +
'use -g for gradient'
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment