1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 12:00:11 +02:00

add sending timestamp

This commit is contained in:
holger krekel 2018-09-25 12:53:36 +02:00
parent 5fcbc11bf3
commit 68900edfbc
2 changed files with 32 additions and 1 deletions

View file

@ -3,6 +3,7 @@
from .cutil import as_dc_charpointer, from_dc_charpointer, iter_array
from .capi import lib, ffi
from .types import property_with_doc
from datetime import datetime
import attr
from attr import validators as v
@ -184,9 +185,18 @@ class Message(object):
@property_with_doc
def text(self):
"""unicode representation. """
"""unicode text of this messages. """
return from_dc_charpointer(lib.dc_msg_get_text(self._dc_msg))
@property_with_doc
def time_sent(self):
"""time when the message was sent.
:returns: datetime.datetime() object.
"""
ts = lib.dc_msg_get_timestamp(self._dc_msg)
return datetime.fromtimestamp(ts)
@property
def chat(self):
"""chat this message was posted in.
@ -196,6 +206,14 @@ class Message(object):
chat_id = lib.dc_msg_get_chat_id(self._dc_msg)
return Chat(self._dc_context, chat_id)
def get_sender_contact(self):
"""return the contact of who wrote the message.
:returns: :class:`Contact`` instance
"""
contact_id = lib.dc_msg_get_from_id(self._dc_msg)
return Contact(self._dc_context, contact_id)
@attr.s
class MessageState(object):