summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-10 15:16:24 +0200
committermathieui <mathieui@mathieui.net>2020-05-23 16:10:13 +0200
commitea438438f2c397958be8171029bd673b17c35c16 (patch)
tree02c2dd133feafdbf7bc3ed211737d7193fd4258b
parent4c1ab027ac03ae3f0925eab03f43a5ad79d906d5 (diff)
downloadpoezio-ea438438f2c397958be8171029bd673b17c35c16.tar.gz
poezio-ea438438f2c397958be8171029bd673b17c35c16.tar.bz2
poezio-ea438438f2c397958be8171029bd673b17c35c16.tar.xz
poezio-ea438438f2c397958be8171029bd673b17c35c16.zip
Add specific types for own leave and join
-rw-r--r--poezio/tabs/muctab.py25
-rw-r--r--poezio/ui/types.py8
2 files changed, 26 insertions, 7 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index d16ac58a..f5d1c700 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -40,7 +40,14 @@ from poezio.roster import roster
from poezio.theming import get_theme, dump_tuple
from poezio.user import User
from poezio.core.structs import Completion, Status
-from poezio.ui.types import BaseMessage, Message, InfoMessage, StatusMessage
+from poezio.ui.types import (
+ BaseMessage,
+ InfoMessage,
+ Message,
+ MucOwnJoinMessage,
+ MucOwnLeaveMessage,
+ StatusMessage,
+)
log = logging.getLogger(__name__)
@@ -200,7 +207,7 @@ class MucTab(ChatTab):
'color_spec': spec_col,
'nick': self.own_nick,
}
- self.add_message(InfoMessage(msg), typ=2)
+ self.add_message(MucOwnLeaveMessage(msg), typ=2)
self.disconnect()
muc.leave_groupchat(self.core.xmpp, self.jid.bare, self.own_nick,
message)
@@ -567,7 +574,7 @@ class MucTab(ChatTab):
'nick_col': color,
'info_col': info_col,
}
- self.add_message(InfoMessage(enable_message), typ=2)
+ self.add_message(MucOwnJoinMessage(enable_message), typ=2)
self.core.enable_private_tabs(self.jid.bare, enable_message)
if '201' in status_codes:
self.add_message(
@@ -651,7 +658,7 @@ class MucTab(ChatTab):
def on_non_member_kicked(self):
"""We have been kicked because the MUC is members-only"""
self.add_message(
- InfoMessage(
+ MucOwnLeaveMessage(
'You have been kicked because you '
'are not a member and the room is now members-only.'
),
@@ -661,7 +668,7 @@ class MucTab(ChatTab):
def on_muc_shutdown(self):
"""We have been kicked because the MUC service is shutting down"""
self.add_message(
- InfoMessage(
+ MucOwnLeaveMessage(
'You have been kicked because the'
' MUC service is shutting down.'
),
@@ -759,6 +766,7 @@ class MucTab(ChatTab):
"""
When someone is banned from a muc
"""
+ cls = InfoMessage
self.users.remove(user)
by = presence.xml.find('{%s}x/{%s}item/{%s}actor' %
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
@@ -774,6 +782,7 @@ class MucTab(ChatTab):
char_kick = theme.CHAR_KICK
if from_nick == self.own_nick: # we are banned
+ cls = MucOwnLeaveMessage
if by:
kick_msg = ('\x191}%(spec)s \x193}You\x19%(info_col)s}'
' have been banned by \x194}%(by)s') % {
@@ -834,12 +843,13 @@ class MucTab(ChatTab):
'reason': reason.text,
'info_col': info_col
}
- self.add_message(InfoMessage(kick_msg), typ=2)
+ self.add_message(cls(kick_msg), typ=2)
def on_user_kicked(self, presence, user, from_nick):
"""
When someone is kicked from a muc
"""
+ cls = InfoMessage
self.users.remove(user)
actor_elem = presence.xml.find('{%s}x/{%s}item/{%s}actor' %
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
@@ -852,6 +862,7 @@ class MucTab(ChatTab):
if actor_elem is not None:
by = actor_elem.get('nick') or actor_elem.get('jid')
if from_nick == self.own_nick: # we are kicked
+ cls = MucOwnLeaveMessage
if by:
kick_msg = ('\x191}%(spec)s \x193}You\x19'
'%(info_col)s} have been kicked'
@@ -912,7 +923,7 @@ class MucTab(ChatTab):
'reason': reason.text,
'info_col': info_col
}
- self.add_message(InfoMessage(kick_msg), typ=2)
+ self.add_message(cls(kick_msg), typ=2)
def on_user_leave_groupchat(self,
user: User,
diff --git a/poezio/ui/types.py b/poezio/ui/types.py
index ae72b6b9..34924112 100644
--- a/poezio/ui/types.py
+++ b/poezio/ui/types.py
@@ -33,6 +33,14 @@ class InfoMessage(BaseMessage):
super().__init__(txt=txt, identifier=identifier, time=time)
+class MucOwnLeaveMessage(InfoMessage):
+ """Status message displayed on our room leave/kick/ban"""
+
+
+class MucOwnJoinMessage(InfoMessage):
+ """Status message displayed on our room join"""
+
+
class XMLLog(BaseMessage):
"""XML Log message"""
__slots__ = ('txt', 'time', 'identifier', 'incoming')