From e60c020634b1e1845fe55973e1240cd8faa9cbbb Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 19 Sep 2016 17:40:33 -0700 Subject: [PATCH] relay_clientbot: redo color hashing to be more unique --- plugins/relay_clientbot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/relay_clientbot.py b/plugins/relay_clientbot.py index 5d9351a..749762d 100644 --- a/plugins/relay_clientbot.py +++ b/plugins/relay_clientbot.py @@ -2,6 +2,7 @@ import string import collections import time +import hashlib from pylinkirc import utils, conf, world from pylinkirc.log import log @@ -28,9 +29,10 @@ def color_text(s): (sum of all characters). """ colors = ('02', '03', '04', '05', '06', '07', '08', '09', '10', '11', - '12', '13') - num = sum([ord(char) for char in s]) - num = num % len(colors) + '12', '13', '14', '15') + digest = hashlib.md5(s.encode()).hexdigest() + digest = int(digest, base=16) + num = digest % len(colors) return "\x03%s%s\x03" % (colors[num], s) def cb_relay_core(irc, source, command, args):