poezio/user: rework change_color to only log when necessary

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-10-09 15:11:01 +02:00
parent 6224f650d3
commit 627f751e0c
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -83,15 +83,17 @@ class User:
self.nick = nick
def change_color(self, color_name: Optional[str], deterministic=False):
color = xhtml.colors.get(color_name)
if color is None:
log.error('Unknown color "%s"', color_name)
if color_name is None:
if deterministic:
self.set_deterministic_color()
else:
self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
else:
self.color = (color, -1)
color = xhtml.colors.get(color_name)
if color is None:
log.error('Unknown color "%s"', color_name)
else:
self.color = (color, -1)
def set_last_talked(self, time: datetime):
"""