3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

relay_clientbot: redo color hashing to be more unique

This commit is contained in:
James Lu 2016-09-19 17:40:33 -07:00
parent fe5a40d632
commit e60c020634

View File

@ -2,6 +2,7 @@
import string import string
import collections import collections
import time import time
import hashlib
from pylinkirc import utils, conf, world from pylinkirc import utils, conf, world
from pylinkirc.log import log from pylinkirc.log import log
@ -28,9 +29,10 @@ def color_text(s):
(sum of all characters). (sum of all characters).
""" """
colors = ('02', '03', '04', '05', '06', '07', '08', '09', '10', '11', colors = ('02', '03', '04', '05', '06', '07', '08', '09', '10', '11',
'12', '13') '12', '13', '14', '15')
num = sum([ord(char) for char in s]) digest = hashlib.md5(s.encode()).hexdigest()
num = num % len(colors) digest = int(digest, base=16)
num = digest % len(colors)
return "\x03%s%s\x03" % (colors[num], s) return "\x03%s%s\x03" % (colors[num], s)
def cb_relay_core(irc, source, command, args): def cb_relay_core(irc, source, command, args):