Last active
August 29, 2015 13:57
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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