diff options
author | mathieui <mathieui@mathieui.net> | 2021-02-17 21:43:43 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-02-17 22:04:20 +0100 |
commit | ee8a3c11210d1b5a14fdb9c9a760e100c79b3d93 (patch) | |
tree | 4979a2b06c8d51f176eb8dc7002aba6fe8b7e0ee /poezio/mam.py | |
parent | 5a9e143c53ce6958a09737c8ed8d57924fc9206f (diff) | |
download | poezio-ee8a3c11210d1b5a14fdb9c9a760e100c79b3d93.tar.gz poezio-ee8a3c11210d1b5a14fdb9c9a760e100c79b3d93.tar.bz2 poezio-ee8a3c11210d1b5a14fdb9c9a760e100c79b3d93.tar.xz poezio-ee8a3c11210d1b5a14fdb9c9a760e100c79b3d93.zip |
muc: remove non-deterministic nick colors
Diffstat (limited to 'poezio/mam.py')
-rw-r--r-- | poezio/mam.py | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/poezio/mam.py b/poezio/mam.py index b40ddc4d..468d12e7 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -48,7 +48,6 @@ def make_line( time: datetime, jid: JID, identifier: str = '', - deterministic: bool = True, ) -> Message: """Adds a textual entry in the TextBuffer""" @@ -59,22 +58,17 @@ def make_line( if isinstance(tab, tabs.MucTab): nick = jid.resource user = tab.get_user_by_name(nick) - if deterministic: - if user: - color = user.color - else: - theme = get_theme() - if theme.ccg_palette: - fg_color = colors.ccg_text_to_color(theme.ccg_palette, nick) - color = fg_color, -1 - else: - mod = len(theme.LIST_COLOR_NICKNAMES) - nick_pos = int(md5(nick.encode('utf-8')).hexdigest(), 16) % mod - color = theme.LIST_COLOR_NICKNAMES[nick_pos] + if user: + color = user.color else: - color = random.choice(list(xhtml.colors)) - color = xhtml.colors.get(color) - color = (color, -1) + theme = get_theme() + if theme.ccg_palette: + fg_color = colors.ccg_text_to_color(theme.ccg_palette, nick) + color = fg_color, -1 + else: + mod = len(theme.LIST_COLOR_NICKNAMES) + nick_pos = int(md5(nick.encode('utf-8')).hexdigest(), 16) % mod + color = theme.LIST_COLOR_NICKNAMES[nick_pos] else: if jid.bare == tab.core.xmpp.boundjid.bare: nick = tab.core.own_nick @@ -144,21 +138,16 @@ async def retrieve_messages(tab: tabs.ChatTab, results: AsyncIterable[SMessage], amount: int = 100) -> List[BaseMessage]: """Run the MAM query and put messages in order""" - text_buffer = tab._text_buffer msg_count = 0 msgs = [] to_add = [] - deterministic = config.get_by_tabname( - 'deterministic_nick_colors', - tab.jid.bare - ) try: async for rsm in results: for msg in rsm['mam']['results']: if msg['mam_result']['forwarded']['stanza'] \ .xml.find('{%s}%s' % ('jabber:client', 'body')) is not None: args = _parse_message(msg) - msgs.append(make_line(tab, deterministic=deterministic, **args)) + msgs.append(make_line(tab, **args)) for msg in reversed(msgs): to_add.append(msg) msg_count += 1 |