summaryrefslogtreecommitdiff
path: root/poezio/core
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-31 23:14:39 +0200
committermathieui <mathieui@mathieui.net>2021-04-02 22:22:30 +0200
commitf56811d5466d4b23f6bfc71b88cb6cdbc4090e29 (patch)
tree506778c58581b0f37b690fcd4b98fc0e94d3c3c3 /poezio/core
parentbbc22fc8bc99be8c84272efa591487a33ef12fc4 (diff)
downloadpoezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.gz
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.bz2
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.xz
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.zip
logging: Remove the "typ" passing when adding or logging messages
Diffstat (limited to 'poezio/core')
-rw-r--r--poezio/core/core.py16
-rw-r--r--poezio/core/handlers.py58
2 files changed, 40 insertions, 34 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index f41eb363..5ea8978f 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -71,7 +71,11 @@ from poezio.core.structs import (
POSSIBLE_SHOW,
)
-from poezio.ui.types import Message, InfoMessage
+from poezio.ui.types import (
+ Message,
+ InfoMessage,
+ PersistentInfoMessage,
+)
log = logging.getLogger(__name__)
@@ -1328,7 +1332,7 @@ class Core:
"""
tab = self.tabs.by_name_and_class(jid, tabs.ConversationTab)
if tab is not None:
- tab.add_message(InfoMessage(msg), typ=2)
+ tab.add_message(PersistentInfoMessage(msg))
if self.tabs.current_tab is tab:
self.refresh_window()
@@ -1743,12 +1747,11 @@ class Core:
nickname='Error',
nick_color=get_theme().COLOR_ERROR_MSG,
),
- typ=2,
)
code = error['error']['code']
if code == '401':
msg = 'To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)'
- tab.add_message(InfoMessage(msg), typ=2)
+ tab.add_message(PersistentInfoMessage(msg))
if code == '409':
if config.getstr('alternative_nickname') != '':
if not tab.joined:
@@ -1757,11 +1760,10 @@ class Core:
else:
if not tab.joined:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'You can join the room with another nick, '
'by typing "/join /other_nick"'
- ),
- typ=2,
+ )
)
self.refresh_window()
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 5fffbef8..55792cbd 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -38,7 +38,13 @@ from poezio.logger import logger
from poezio.roster import roster
from poezio.text_buffer import CorrectionError, AckError
from poezio.theming import dump_tuple, get_theme
-from poezio.ui.types import XMLLog, Message as PMessage, BaseMessage, InfoMessage
+from poezio.ui.types import (
+ XMLLog,
+ Message as PMessage,
+ BaseMessage,
+ InfoMessage,
+ PersistentInfoMessage,
+)
from poezio.core.commands import dumb_callback
@@ -318,7 +324,7 @@ class HandlerCore:
error = '\x19%s}%s\x19o' % (dump_tuple(get_theme().COLOR_CHAR_NACK),
error_msg)
if not tab.nack_message('\n' + error, message['id'], message['to']):
- tab.add_message(InfoMessage(error), typ=0)
+ tab.add_message(InfoMessage(error))
self.core.refresh_window()
def on_normal_message(self, message):
@@ -421,8 +427,7 @@ class HandlerCore:
history=delayed,
identifier=message['id'],
jid=jid,
- ),
- typ=1,
+ )
)
if not own and 'private' in config.getlist('beep_on'):
@@ -627,7 +632,7 @@ class HandlerCore:
identifier=message['id'],
)
typ = 2
- tab.add_message(ui_msg, typ)
+ tab.add_message(ui_msg)
if highlight:
self.core.events.trigger('highlight', message, tab)
@@ -723,8 +728,7 @@ class HandlerCore:
user=user,
identifier=message['id'],
jid=message['from'],
- ),
- typ=1,
+ )
)
if sent:
tab.set_last_sent_message(message, correct=replaced)
@@ -1214,53 +1218,53 @@ class HandlerCore:
if show_unavailable or hide_unavailable or non_priv or logging_off\
or non_anon or semi_anon or full_anon:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: A configuration change not privacy-related occurred.'
),
- typ=2)
+ )
modif = True
if show_unavailable:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: The unavailable members are now shown.'
),
- typ=2)
+ )
elif hide_unavailable:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: The unavailable members are now hidden.',
),
- typ=2)
+ )
if non_anon:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)' % info_col
),
- typ=2)
+ )
elif semi_anon:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: The room is now semi-anonymous. (moderators-only JID)',
),
- typ=2)
+ )
elif full_anon:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: The room is now fully anonymous.',
),
- typ=2)
+ )
if logging_on:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'\x191}Warning: \x19%(info_col)s}This room is publicly logged' % info_col
),
- typ=2)
+ )
elif logging_off:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
'Info: This room is not logged anymore.',
),
- typ=2)
+ )
if modif:
self.core.refresh_window()
@@ -1303,18 +1307,18 @@ class HandlerCore:
if nick_from:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
"%(user)s set the subject to: \x19%(text_col)s}%(subject)s" % fmt,
time=time,
),
- typ=2)
+ )
else:
tab.add_message(
- InfoMessage(
+ PersistentInfoMessage(
"The subject is: \x19%(text_col)s}%(subject)s" % fmt,
time=time,
),
- typ=2)
+ )
tab.topic = subject
tab.topic_from = nick_from
if self.core.tabs.by_name_and_class(