MCPcopy Create free account
hub / github.com/chatmail/core / Chat

Class Chat

python/src/deltachat/chat.py:21–509  ·  view source on GitHub ↗

Chat object which manages members and through which you can send and retrieve messages. You obtain instances of it through :class:`deltachat.account.Account`.

Source from the content-addressed store, hash-verified

19
20
21class Chat:
22 """Chat object which manages members and through which you can send and retrieve messages.
23
24 You obtain instances of it through :class:`deltachat.account.Account`.
25 """
26
27 def __init__(self, account, id: int) -> None:
28 from .account import Account
29
30 assert isinstance(account, Account), repr(account)
31 self.account = account
32 self.id = id
33
34 def __eq__(self, other) -> bool:
35 if other is None:
36 return False
37 return self.id == getattr(other, "id", None) and self.account._dc_context == other.account._dc_context
38
39 def __ne__(self, other) -> bool:
40 return not self == other
41
42 def __repr__(self) -> str:
43 return f"<Chat id={self.id} name={self.get_name()}>"
44
45 @property
46 def _dc_chat(self):
47 return ffi.gc(lib.dc_get_chat(self.account._dc_context, self.id), lib.dc_chat_unref)
48
49 def delete(self) -> None:
50 """Delete this chat and all its messages.
51
52 Note:
53
54 - does not delete messages on server
55 - the chat or contact is not blocked, new message will arrive
56 """
57 lib.dc_delete_chat(self.account._dc_context, self.id)
58
59 def block(self) -> None:
60 """Block this chat."""
61 lib.dc_block_chat(self.account._dc_context, self.id)
62
63 def accept(self) -> None:
64 """Accept this contact request chat."""
65 lib.dc_accept_chat(self.account._dc_context, self.id)
66
67 # ------ chat status/metadata API ------------------------------
68
69 def is_group(self) -> bool:
70 """Return True if this chat is a group chat.
71
72 :returns: True if chat is a group-chat, False otherwise
73 """
74 return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_GROUP
75
76 def is_single(self) -> bool:
77 """Return True if this chat is a single/direct chat, False otherwise."""
78 return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_SINGLE

Callers 7

create_group_chatMethod · 0.70
get_chatsMethod · 0.70
get_chat_by_idMethod · 0.70
qr_setup_contactMethod · 0.70
qr_join_chatMethod · 0.70
create_chatMethod · 0.70
chatMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected