summaryrefslogtreecommitdiff
path: root/poezio
diff options
context:
space:
mode:
Diffstat (limited to 'poezio')
-rw-r--r--poezio/core/core.py6
-rw-r--r--poezio/mam.py19
-rwxr-xr-xpoezio/theming.py2
3 files changed, 19 insertions, 8 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index 973c9103..3ad15719 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -543,6 +543,12 @@ class Core:
default_tab.on_gain_focus()
self.tabs.append(default_tab)
self.information('Welcome to poezio!', 'Info')
+ if curses.COLORS < 256:
+ self.information(
+ 'Your terminal does not appear to support 256 colors, the UI'
+ ' colors will probably be ugly',
+ 'Error',
+ )
if firstrun:
self.information(
'It seems that it is the first time you start poezio.\n'
diff --git a/poezio/mam.py b/poezio/mam.py
index 371b34dd..31ca2f0c 100644
--- a/poezio/mam.py
+++ b/poezio/mam.py
@@ -46,8 +46,9 @@ def make_line(
tab: tabs.ChatTab,
text: str,
time: datetime,
- nick: str,
+ jid: JID,
identifier: str = '',
+ deterministic: bool = True,
) -> Message:
"""Adds a textual entry in the TextBuffer"""
@@ -55,9 +56,8 @@ def make_line(
time = time.replace(tzinfo=timezone.utc).astimezone(tz=None)
time = time.replace(tzinfo=None)
- deterministic = config.get_by_tabname('deterministic_nick_colors', tab.jid.bare)
if isinstance(tab, tabs.MucTab):
- nick = nick.split('/')[1]
+ nick = jid.resource
user = tab.get_user_by_name(nick)
if deterministic:
if user:
@@ -76,11 +76,12 @@ def make_line(
color = xhtml.colors.get(color)
color = (color, -1)
else:
- if nick.split('/')[0] == tab.core.xmpp.boundjid.bare:
+ if jid.bare == tab.core.xmpp.boundjid.bare:
+ nick = tab.core.own_nick
color = get_theme().COLOR_OWN_NICK
else:
color = get_theme().COLOR_REMOTE_USER
- nick = tab.get_nick()
+ nick = tab.get_nick()
return Message(
txt=text,
identifier=identifier,
@@ -133,7 +134,7 @@ def _parse_message(msg: SMessage) -> Dict:
message = forwarded['stanza']
return {
'time': forwarded['delay']['stamp'],
- 'nick': str(message['from']),
+ 'jid': message['from'],
'text': message['body'],
'identifier': message['origin-id']
}
@@ -147,13 +148,17 @@ async def retrieve_messages(tab: tabs.ChatTab,
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, **args))
+ msgs.append(make_line(tab, deterministic=deterministic, **args))
for msg in reversed(msgs):
to_add.append(msg)
msg_count += 1
diff --git a/poezio/theming.py b/poezio/theming.py
index fc34ae39..6f1d8226 100755
--- a/poezio/theming.py
+++ b/poezio/theming.py
@@ -448,7 +448,7 @@ def to_curses_attr(
colors = color_tuple
bold = False
- if curses.COLORS != 256:
+ if curses.COLORS < 256:
# We are not in a term supporting 256 colors, so we convert
# colors to numbers between -1 and 8
colors = (color_256_to_16(colors[0]), color_256_to_16(colors[1]))