1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

make chats objects grow equality operators, probably we rather want to move to "attr" which handles all of this.

This commit is contained in:
holger krekel 2018-09-09 12:56:14 +02:00
parent 194bd82b8c
commit 0aed6355c3
2 changed files with 18 additions and 1 deletions

View file

@ -104,6 +104,15 @@ class Chat:
self.dc_context = dc_context
self.id = chat_id
def __eq__(self, other_chat):
return (
self.dc_context == getattr(other_chat, "dc_context", None) and
self.id == getattr(other_chat, "id", None)
)
def __ne__(self, other_chat):
return not self == other_chat
def send_text_message(self, msg):
""" return ID of the message in this chat.
'msg' should be unicode"""
@ -122,6 +131,11 @@ class Message:
def text(self):
return ffi_unicode(capi.lib.dc_msg_get_text(self.dc_msg))
@property
def chat(self):
chat_id = capi.lib.dc_msg_get_chat_id(self.dc_msg)
return Chat(self.dc_context, chat_id)
class Account:
def __init__(self, db_path, _logid=None):