poezio/user: rework change_color to only log when necessary
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6224f650d3
commit
627f751e0c
1 changed files with 6 additions and 4 deletions
|
@ -83,13 +83,15 @@ class User:
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
|
|
||||||
def change_color(self, color_name: Optional[str], deterministic=False):
|
def change_color(self, color_name: Optional[str], deterministic=False):
|
||||||
color = xhtml.colors.get(color_name)
|
if color_name is None:
|
||||||
if color is None:
|
|
||||||
log.error('Unknown color "%s"', color_name)
|
|
||||||
if deterministic:
|
if deterministic:
|
||||||
self.set_deterministic_color()
|
self.set_deterministic_color()
|
||||||
else:
|
else:
|
||||||
self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
|
self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
|
||||||
|
else:
|
||||||
|
color = xhtml.colors.get(color_name)
|
||||||
|
if color is None:
|
||||||
|
log.error('Unknown color "%s"', color_name)
|
||||||
else:
|
else:
|
||||||
self.color = (color, -1)
|
self.color = (color, -1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue