From 3830c1c176289b09d1edffb9e864a2d38b7c757e Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 10 Mar 2019 18:02:54 +0100 Subject: [PATCH] quick frontend(chat): display a useful message with __unicode__ and __str__ --- sat_frontends/quick_frontend/quick_chat.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sat_frontends/quick_frontend/quick_chat.py b/sat_frontends/quick_frontend/quick_chat.py index b5dbb2aa..a3b4f519 100644 --- a/sat_frontends/quick_frontend/quick_chat.py +++ b/sat_frontends/quick_frontend/quick_chat.py @@ -85,6 +85,16 @@ class Message(object): self.handleMe() self.widgets = set() # widgets linked to this message + def __unicode__(self): + return u"Message<{mess_type}> [{time}]{nick}> {message}".format( + mess_type=self.type, + time=self.time_text, + nick=self.nick, + message=self.main_message) + + def __str__(self): + return self.__unicode__().encode('utf-8', 'ignore') + @property def host(self): return self.parent.host @@ -328,7 +338,7 @@ class QuickChat(quick_widgets.QuickWidget): ## Widget management ## - def __str__(self): + def __unicode__(self): return u"Chat Widget [target: {}, type: {}, profile: {}]".format( self.target, self.type, self.profile )