def __repr__(self): readable = { 'call_log': { 'miss': "Missed Call", }, 'e2e_notification': { 'encrypt': "Messages now Encrypted" }, 'gp2': { 'invite': "Joined an invite link", 'create': "Created group", 'add': "Added to group", 'remove': "Removed from group", 'leave': "Left the group" } } sender = "" if not self.sender else ( "from " + str(safe_str(self.sender.get_safe_name()))) return "<NotificationMessage - {type} {recip} {sender} at {timestamp}>".format( type=readable[self.type][self.subtype], sender=sender, timestamp=self.timestamp, recip="" if not hasattr(self, 'recipients') else "".join( [safe_str(x.get_safe_name()) for x in self.recipients]), )
def __repr__(self): return "<GeoMessage - {type} from {sender} at {timestamp} ({lat}, {lng})>".format( type=self.type, sender=safe_str(self.sender.get_safe_name()), timestamp=self.timestamp, lat=self.latitude, lng=self.longitude)
def __init__(self, js_obj, driver=None): """ Constructor :param js_obj: Raw JS message obj :type js_obj: dict """ super(Message, self).__init__(js_obj, driver) self.id = js_obj["id"] self.type = js_obj["type"] self.sender = Contact(js_obj["sender"], driver) if js_obj["sender"] else False self.timestamp = datetime.fromtimestamp(js_obj["timestamp"]) self.chat_id = js_obj['chatId'] if js_obj["content"]: self.content = js_obj["content"] self.safe_content = safe_str(self.content[0:25]) + '...' elif self.type == 'revoked': self.content = '' self.safe_content = '...'
def __repr__(self): return "<Message - {type} from {sender} at {timestamp}: {content}>".format( type=self.type, sender=safe_str(self.sender.get_safe_name()), timestamp=self.timestamp, content=self.safe_content)
def __repr__(self): safe_chat_name = safe_str(self.chat.name) return "<MessageGroup - {num} {messages} in {chat}>".format( num=len(self.messages), messages="message" if len(self.messages) == 1 else "messages", chat=safe_chat_name)
def __repr__(self): return "<VCardMessage - {type} from {sender} at {timestamp} ({contacts})>".format( type=self.type, sender=safe_str(self.sender.get_safe_name()), timestamp=self.timestamp, contacts=self.contacts)
def __repr__(self): return "<MediaMessage - {type} from {sender} at {timestamp} ({filename})>".format( type=self.type, sender=safe_str(self.sender.get_safe_name()), timestamp=self.timestamp, filename=self.filename)