~reedwade/wee-matter

661a0d033b016f7ca913d5d065639405e7a305cf — Stacy Harper 2 months ago 04a0a6c
Make nick color consistent on multiple sessions
1 files changed, 3 insertions(+), 1 deletions(-)

M wee_matter/server.py
M wee_matter/server.py => wee_matter/server.py +3 -1
@@ 3,6 3,7 @@ import weechat
import wee_matter
import json
import re
import hashlib
from typing import NamedTuple

servers = {}


@@ 110,7 111,8 @@ def color_for_username(username):
    ).split(",")

    nick_color_count = len(nick_colors)
    color_id = hash(username) % nick_color_count
    m = hashlib.sha256(username.encode('utf-8'))
    color_id = int(m.hexdigest(), 16) % nick_color_count

    return nick_colors[color_id]