Created
September 30, 2012 07:00
-
-
Save fowlmouth/3806113 to your computer and use it in GitHub Desktop.
irc colorizer
This file contains hidden or 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
import math, os, strutils | |
randomize() | |
proc color(c: string; res: var string; fg = random(30), bg = random(30)) = | |
res.add '\3' | |
res.add($fg) | |
res.add ',' | |
res.add($bg) | |
res.add c | |
var | |
s = "" | |
colorizeWord = "" | |
nColors = 15 | |
for i in 1..paramCount(): | |
var s = paramStr(i) | |
if i == 1 and s[0] == '-': | |
nColors = parseInt(s[1..high(s)]) | |
else: | |
colorizeWord.add paramStr(i) | |
if i < paramCount(): | |
colorizeWord.add ' ' | |
for i in 0..nColors - 1: color(colorizeWord, s) | |
echo(s) |
This file contains hidden or 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
words = 15 | |
text = ( | |
ARGV[0] =~ /-(\d+)/ ? (words = $1.to_i; ARGV[1..-1]) : ARGV | |
).join' ' | |
puts words.times.map{"\3#{rand 30},#{rand 30}#{text}"}.join'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment