deltachat-rpc-client 2.37.0__py3-none-any.whl → 2.39.0__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.
@@ -44,8 +44,13 @@ class AttrDict(dict):
44
44
  super().__setattr__(attr, val)
45
45
 
46
46
 
47
+ def _forever(_event: AttrDict) -> bool:
48
+ return False
49
+
50
+
47
51
  def run_client_cli(
48
52
  hooks: Optional[Iterable[Tuple[Callable, Union[type, "EventFilter"]]]] = None,
53
+ until: Callable[[AttrDict], bool] = _forever,
49
54
  argv: Optional[list] = None,
50
55
  **kwargs,
51
56
  ) -> None:
@@ -55,10 +60,11 @@ def run_client_cli(
55
60
  """
56
61
  from .client import Client
57
62
 
58
- _run_cli(Client, hooks, argv, **kwargs)
63
+ _run_cli(Client, until, hooks, argv, **kwargs)
59
64
 
60
65
 
61
66
  def run_bot_cli(
67
+ until: Callable[[AttrDict], bool] = _forever,
62
68
  hooks: Optional[Iterable[Tuple[Callable, Union[type, "EventFilter"]]]] = None,
63
69
  argv: Optional[list] = None,
64
70
  **kwargs,
@@ -69,11 +75,12 @@ def run_bot_cli(
69
75
  """
70
76
  from .client import Bot
71
77
 
72
- _run_cli(Bot, hooks, argv, **kwargs)
78
+ _run_cli(Bot, until, hooks, argv, **kwargs)
73
79
 
74
80
 
75
81
  def _run_cli(
76
82
  client_type: Type["Client"],
83
+ until: Callable[[AttrDict], bool] = _forever,
77
84
  hooks: Optional[Iterable[Tuple[Callable, Union[type, "EventFilter"]]]] = None,
78
85
  argv: Optional[list] = None,
79
86
  **kwargs,
@@ -111,7 +118,7 @@ def _run_cli(
111
118
  kwargs={"email": args.email, "password": args.password},
112
119
  )
113
120
  configure_thread.start()
114
- client.run_forever()
121
+ client.run_until(until)
115
122
 
116
123
 
117
124
  def extract_addr(text: str) -> str:
@@ -14,6 +14,7 @@ from typing import (
14
14
 
15
15
  from ._utils import (
16
16
  AttrDict,
17
+ _forever,
17
18
  parse_system_add_remove,
18
19
  parse_system_image_changed,
19
20
  parse_system_title_changed,
@@ -91,19 +92,28 @@ class Client:
91
92
 
92
93
  def run_forever(self) -> None:
93
94
  """Process events forever."""
94
- self.run_until(lambda _: False)
95
+ self.run_until(_forever)
95
96
 
96
97
  def run_until(self, func: Callable[[AttrDict], bool]) -> AttrDict:
97
- """Process events until the given callable evaluates to True.
98
-
99
- The callable should accept an AttrDict object representing the
100
- last processed event. The event is returned when the callable
101
- evaluates to True.
102
- """
98
+ """Start the event processing loop."""
103
99
  self.logger.debug("Listening to incoming events...")
104
100
  if self.is_configured():
105
101
  self.account.start_io()
106
102
  self._process_messages() # Process old messages.
103
+ return self._process_events(until_func=func) # Loop over incoming events
104
+
105
+ def _process_events(
106
+ self,
107
+ until_func: Callable[[AttrDict], bool],
108
+ until_event: EventType = False,
109
+ ) -> AttrDict:
110
+ """Process events until the given callable evaluates to True,
111
+ or until a certain event happens.
112
+
113
+ The until_func callable should accept an AttrDict object representing
114
+ the last processed event. The event is returned when the callable
115
+ evaluates to True.
116
+ """
107
117
  while True:
108
118
  event = self.account.wait_for_event()
109
119
  event["kind"] = EventType(event.kind)
@@ -112,10 +122,13 @@ class Client:
112
122
  if event.kind == EventType.INCOMING_MSG:
113
123
  self._process_messages()
114
124
 
115
- stop = func(event)
125
+ stop = until_func(event)
116
126
  if stop:
117
127
  return event
118
128
 
129
+ if event.kind == until_event:
130
+ return event
131
+
119
132
  def _on_event(self, event: AttrDict, filter_type: Type[EventFilter] = RawEvent) -> None:
120
133
  for hook, evfilter in self._hooks.get(filter_type, []):
121
134
  if evfilter.filter(event):
@@ -44,6 +44,14 @@ class Message:
44
44
  read_receipts = self._rpc.get_message_read_receipts(self.account.id, self.id)
45
45
  return [AttrDict(read_receipt) for read_receipt in read_receipts]
46
46
 
47
+ def get_read_receipt_count(self) -> int:
48
+ """
49
+ Returns count of read receipts on message.
50
+
51
+ This view count is meant as a feedback measure for the channel owner only.
52
+ """
53
+ return self._rpc.get_message_read_receipt_count(self.account.id, self.id)
54
+
47
55
  def get_reactions(self) -> Optional[AttrDict]:
48
56
  """Get message reactions."""
49
57
  reactions = self._rpc.get_message_reactions(self.account.id, self.id)
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import logging
5
6
  import os
6
7
  import pathlib
7
8
  import platform
@@ -204,14 +205,13 @@ def log():
204
205
 
205
206
  class Printer:
206
207
  def section(self, msg: str) -> None:
207
- print()
208
- print("=" * 10, msg, "=" * 10)
208
+ logging.info("\n%s %s %s", "=" * 10, msg, "=" * 10)
209
209
 
210
210
  def step(self, msg: str) -> None:
211
- print("-" * 5, "step " + msg, "-" * 5)
211
+ logging.info("%s step %s %s", "-" * 5, msg, "-" * 5)
212
212
 
213
213
  def indent(self, msg: str) -> None:
214
- print(" " + msg)
214
+ logging.info(" " + msg)
215
215
 
216
216
  return Printer()
217
217
 
@@ -261,7 +261,7 @@ def get_core_python_env(tmp_path_factory):
261
261
  envs[core_version] = venv
262
262
  python = find_path(venv, "python")
263
263
  rpc_server_path = find_path(venv, "deltachat-rpc-server")
264
- print(f"python={python}\nrpc_server={rpc_server_path}")
264
+ logging.info(f"Paths:\npython={python}\nrpc_server={rpc_server_path}")
265
265
  return python, rpc_server_path
266
266
 
267
267
  return get_versioned_venv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deltachat-rpc-client
3
- Version: 2.37.0
3
+ Version: 2.39.0
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
5
  License-Expression: MPL-2.0
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -1,19 +1,19 @@
1
1
  deltachat_rpc_client/__init__.py,sha256=zroJARiq9HBi7Ln03KlICOUJHSjm3CGIFkHfXILEdOQ,567
2
- deltachat_rpc_client/_utils.py,sha256=v0iWVSa6S-s078GgnnhflCRhA9pfWI-CfK8mjZ4zjXc,6393
2
+ deltachat_rpc_client/_utils.py,sha256=IQD23hEWPQ7A43Bx3bt4MhXy5DJiVFT-UHUDz-hpo0g,6619
3
3
  deltachat_rpc_client/account.py,sha256=CNUwmWNdWlaEXuDHy0Xld7EFnNaBrMk_BORkVeNIql4,19549
4
4
  deltachat_rpc_client/chat.py,sha256=NWFekpJaHh21GLNev0_5YhbPLPz72TTwXlmJ8fDAfgk,11957
5
- deltachat_rpc_client/client.py,sha256=6eP_lH5z7G5Sy7vDRNfKNY3dkUqJqKZDVyCGjynsuW8,7181
5
+ deltachat_rpc_client/client.py,sha256=ddCq5ln2xHy5_-NjjjOI8yO_Ee8oeTXKyiwhCkUIvwk,7595
6
6
  deltachat_rpc_client/const.py,sha256=fnM377RkqOf4rM_jhy-O8dK-MbFLXQYtvprsvVWg2YI,6722
7
7
  deltachat_rpc_client/contact.py,sha256=NLh1XNnD_LQf27pNcVgqNN97Gbv190VSCuEyjjce4L4,1893
8
8
  deltachat_rpc_client/deltachat.py,sha256=-6SqQAS8_mMWLBP3U1HvFsNIpcAPYBlmqF8R6Bt90YQ,1894
9
9
  deltachat_rpc_client/events.py,sha256=Y45LoGlQy0i1U-LhoqF9njqJWA8v4b-XHfXZ4VOr1TQ,10205
10
- deltachat_rpc_client/message.py,sha256=xA3rLUOPkakqr7kW3JORVYLKHQxvggBqgrXPnDK1a0s,5156
10
+ deltachat_rpc_client/message.py,sha256=q9vxYTAvgIfbV9v8uupj5t_jpSVcSx3BJwYHlpMJ8z8,5443
11
11
  deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
12
- deltachat_rpc_client/pytestplugin.py,sha256=ptQg9BMtNqTmFY3-InFVMRmeRqQBGym7wgdORSaOEk0,10804
12
+ deltachat_rpc_client/pytestplugin.py,sha256=9zO9hLj1SSSgKfYq4pB2rci_rIONoLdT6nt32WRD13o,10856
13
13
  deltachat_rpc_client/rpc.py,sha256=V26Z6rSjwAIWinPft5jnJIQrQg6lnlqLVf9BPWgz6iE,6318
14
- deltachat_rpc_client-2.37.0.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
- deltachat_rpc_client-2.37.0.dist-info/METADATA,sha256=SchuU9hW51Iwi6bsGziD15Xsfc16BCg5qTOG2jGODQo,2274
16
- deltachat_rpc_client-2.37.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- deltachat_rpc_client-2.37.0.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
- deltachat_rpc_client-2.37.0.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
- deltachat_rpc_client-2.37.0.dist-info/RECORD,,
14
+ deltachat_rpc_client-2.39.0.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
+ deltachat_rpc_client-2.39.0.dist-info/METADATA,sha256=yrUopf_3k3iGqFH_KHyma9TwmK3tuhWtE_8Gu4K7efk,2274
16
+ deltachat_rpc_client-2.39.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
17
+ deltachat_rpc_client-2.39.0.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
+ deltachat_rpc_client-2.39.0.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
+ deltachat_rpc_client-2.39.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5