add utils.irc.hash_colorize() to color a string by the string's hash
This commit is contained in:
parent
dc52200af8
commit
2ad8623eb3
1 changed files with 5 additions and 0 deletions
|
@ -41,6 +41,11 @@ def color(s: str, foreground: consts.IRCColor,
|
||||||
return "%s%s%s%s%s" % (consts.COLOR, foreground_s, background_s, s,
|
return "%s%s%s%s%s" % (consts.COLOR, foreground_s, background_s, s,
|
||||||
consts.COLOR)
|
consts.COLOR)
|
||||||
|
|
||||||
|
HASH_COLORS = list(range(2, 16))
|
||||||
|
def hash_colorize(s: str):
|
||||||
|
code = hash(s)%len(HASH_COLORS)
|
||||||
|
return color(s, consts.COLOR_CODES[code])
|
||||||
|
|
||||||
def bold(s: str) -> str:
|
def bold(s: str) -> str:
|
||||||
return "%s%s%s" % (consts.BOLD, s, consts.BOLD)
|
return "%s%s%s" % (consts.BOLD, s, consts.BOLD)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue