deltachat-rpc-client 1.156.2__py3-none-any.whl → 1.157.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
+ from pathlib import Path
5
+ from tempfile import TemporaryDirectory
4
6
  from typing import TYPE_CHECKING, Optional, Union
5
7
  from warnings import warn
6
8
 
@@ -38,6 +40,16 @@ class Account:
38
40
  """Remove the account."""
39
41
  self._rpc.remove_account(self.id)
40
42
 
43
+ def clone(self) -> "Account":
44
+ """Clone given account."""
45
+ with TemporaryDirectory() as tmp_dir:
46
+ tmp_path = Path(tmp_dir)
47
+ self.export_backup(tmp_path)
48
+ files = list(tmp_path.glob("*.tar"))
49
+ new_account = self.manager.add_account()
50
+ new_account.import_backup(files[0])
51
+ return new_account
52
+
41
53
  def start_io(self) -> None:
42
54
  """Start the account I/O."""
43
55
  self._rpc.start_io(self.id)
@@ -83,6 +95,10 @@ class Account:
83
95
  return self.get_config("selfavatar")
84
96
 
85
97
  def check_qr(self, qr):
98
+ """Parse QR code contents.
99
+
100
+ This function takes the raw text scanned
101
+ and checks what can be done with it."""
86
102
  return self._rpc.check_qr(self.id, qr)
87
103
 
88
104
  def set_config_from_qr(self, qr: str):
@@ -118,11 +134,28 @@ class Account:
118
134
  obj = obj.get_snapshot().address
119
135
  return Contact(self, self._rpc.create_contact(self.id, obj, name))
120
136
 
137
+ def make_vcard(self, contacts: list[Contact]) -> str:
138
+ """Create vCard with the given contacts."""
139
+ assert all(contact.account == self for contact in contacts)
140
+ contact_ids = [contact.id for contact in contacts]
141
+ return self._rpc.make_vcard(self.id, contact_ids)
142
+
143
+ def import_vcard(self, vcard: str) -> list[Contact]:
144
+ """Import vCard.
145
+
146
+ Return created or modified contacts in the order they appear in vCard."""
147
+ contact_ids = self._rpc.import_vcard_contents(self.id, vcard)
148
+ return [Contact(self, contact_id) for contact_id in contact_ids]
149
+
121
150
  def create_chat(self, account: "Account") -> Chat:
122
- addr = account.get_config("addr")
123
- contact = self.create_contact(addr)
151
+ vcard = account.self_contact.make_vcard()
152
+ [contact] = self.import_vcard(vcard)
124
153
  return contact.create_chat()
125
154
 
155
+ def get_device_chat(self) -> Chat:
156
+ """Return device chat."""
157
+ return self.device_contact.create_chat()
158
+
126
159
  def get_contact_by_id(self, contact_id: int) -> Contact:
127
160
  """Return Contact instance for the given contact ID."""
128
161
  return Contact(self, contact_id)
@@ -183,6 +216,11 @@ class Account:
183
216
  """This account's identity as a Contact."""
184
217
  return Contact(self, SpecialContactId.SELF)
185
218
 
219
+ @property
220
+ def device_contact(self) -> Chat:
221
+ """This account's device contact."""
222
+ return Contact(self, SpecialContactId.DEVICE)
223
+
186
224
  def get_chatlist(
187
225
  self,
188
226
  query: Optional[str] = None,
@@ -308,6 +346,13 @@ class Account:
308
346
  if event.kind == EventType.MSGS_CHANGED:
309
347
  return event
310
348
 
349
+ def wait_for_msgs_noticed_event(self):
350
+ """Wait for messages noticed event and return it."""
351
+ while True:
352
+ event = self.wait_for_event()
353
+ if event.kind == EventType.MSGS_NOTICED:
354
+ return event
355
+
311
356
  def wait_for_incoming_msg(self):
312
357
  """Wait for incoming message and return it.
313
358
 
@@ -66,4 +66,4 @@ class Contact:
66
66
  )
67
67
 
68
68
  def make_vcard(self) -> str:
69
- return self._rpc.make_vcard(self.account.id, [self.id])
69
+ return self.account.make_vcard([self])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: deltachat-rpc-client
3
- Version: 1.156.2
3
+ Version: 1.157.1
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: Intended Audience :: Developers
@@ -1,19 +1,19 @@
1
1
  deltachat_rpc_client/__init__.py,sha256=L19BWnRu9TMF--jQ7e5Asgme951WGsldrTknW86KyTg,566
2
2
  deltachat_rpc_client/_utils.py,sha256=pLOV_pxS2MRreLtq-5rnKJp-BP0m8T4LcbJ8N7Xy-D0,6304
3
- deltachat_rpc_client/account.py,sha256=8x2EQJR0ZsGY0_yDvLtESdcoykhyqyMYwGD0u4Kroz4,14175
3
+ deltachat_rpc_client/account.py,sha256=FGZrM-BdnL6h7P9h1F_svVwYXF94uCm2JmtdjnPR4Lc,15886
4
4
  deltachat_rpc_client/chat.py,sha256=1pbuEBWBjZDD9qQ3U1hY5jozzx0MSs9Ybpw33reA2MU,11208
5
5
  deltachat_rpc_client/client.py,sha256=yyXt2USkBeTsqNxtXZNNUqdsPVkqEUHYf7C-5JFmX7s,7043
6
6
  deltachat_rpc_client/const.py,sha256=geXY_H-JHn2HLsYPAAWbwnX5LOksU7zqDZh3AOwmUpg,5577
7
- deltachat_rpc_client/contact.py,sha256=oa7EbyYIsIVK3N-L772qSmYuwr1JQGsr2K5vOjEy9AY,1983
7
+ deltachat_rpc_client/contact.py,sha256=kbqVI93V7-VSCjH8Hfm5M9a62HMnOjBKuw_g6iJN7w8,1966
8
8
  deltachat_rpc_client/deltachat.py,sha256=c22_2GX71we6JwQ4yjP-S89mrUYPPbEb3rrPwHHeXt4,1538
9
9
  deltachat_rpc_client/events.py,sha256=qYgydsbuWYxQ1PO5ms-D8I5aHpTIiQ6Fg9p23QTvqf0,9877
10
10
  deltachat_rpc_client/message.py,sha256=LVgQTzgaTS-24NPqSLYjgCtyz9PiTPWQgO0c_j9tIs4,3021
11
11
  deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
12
12
  deltachat_rpc_client/pytestplugin.py,sha256=zRRxsSBvzpbRUxSmKjd7EKZbosAb60Ew53Yu5W7W4Nc,4055
13
13
  deltachat_rpc_client/rpc.py,sha256=7RIdyEDwOXU0ACU0LanVqTT1RuIDci5iDr7dNEDE_tE,6554
14
- deltachat_rpc_client-1.156.2.dist-info/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
- deltachat_rpc_client-1.156.2.dist-info/METADATA,sha256=b3d9COKpAAugzuiTwJJHf1GMW_XtQ1Wsrz6nsrK0I88,2153
16
- deltachat_rpc_client-1.156.2.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
17
- deltachat_rpc_client-1.156.2.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
- deltachat_rpc_client-1.156.2.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
- deltachat_rpc_client-1.156.2.dist-info/RECORD,,
14
+ deltachat_rpc_client-1.157.1.dist-info/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
+ deltachat_rpc_client-1.157.1.dist-info/METADATA,sha256=xfneJEioraZngBSBu7iBVo9Oqh1EGOa_VY6zyTZZPRQ,2153
16
+ deltachat_rpc_client-1.157.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
17
+ deltachat_rpc_client-1.157.1.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
+ deltachat_rpc_client-1.157.1.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
+ deltachat_rpc_client-1.157.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5