Created
May 28, 2019 21:48
-
-
Save Wolf480pl/ed04bf9400948eedd0da0adc129e9dd7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python2 | |
import sys | |
irccolors = (19, 20, 22, 24, 25, 26, 27, 28, 29) | |
ansicolors_gnome = ("32", "31", "35", "93", "92", "36", "96", "94", "95") | |
ansicolors_linux = ("0;32", "0;31", "0;35", "1;33", "1;32", "0;36", "1;36", "1;34", "0;35" ) | |
colors = irccolors | |
ircformat = "{0}" | |
ansiformat = "\x1b[{0}m{1}" | |
format = ircformat #TODO | |
def color_of (nick): | |
total = sum(ord(char) for char in nick) | |
total %= len(colors) | |
return colors[total] | |
i = 1 | |
if sys.argv[1] == "-a": | |
colors = ansicolors_linux | |
format = ansiformat | |
i += 1 | |
elif sys.argv[1] == "-g": | |
colors = ansicolors_gnome | |
format = ansiformat | |
i += 1 | |
nick=sys.argv[i] | |
print format.format(color_of(nick), nick) | |
#print "\x1b[" + color_of(nick) + "m" + nick | |
#print color_of(nick) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment