quick frontend(chat): display a useful message with __unicode__ and __str__

This commit is contained in:
Goffi 2019-03-10 18:02:54 +01:00
commit 3830c1c176

View file

@ -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
)