Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created September 30, 2012 07:00
Show Gist options
  • Save fowlmouth/3806113 to your computer and use it in GitHub Desktop.
Save fowlmouth/3806113 to your computer and use it in GitHub Desktop.
irc colorizer
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)
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