matrix-python 1.4.6a0__py3-none-any.whl → 1.4.7a0__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.
matrix/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.4.6a0'
22
- __version_tuple__ = version_tuple = (1, 4, 6, 'a0')
21
+ __version__ = version = '1.4.7a0'
22
+ __version_tuple__ = version_tuple = (1, 4, 7, 'a0')
23
23
 
24
24
  __commit_id__ = commit_id = None
matrix/bot.py CHANGED
@@ -184,10 +184,6 @@ class Bot(Registry):
184
184
  await handler(error)
185
185
  return
186
186
 
187
- if self._fallback_error_handler:
188
- await self._fallback_error_handler(error)
189
- return
190
-
191
187
  await self._dispatch("on_error", error)
192
188
 
193
189
  async def on_command(self, _ctx: Context) -> None:
@@ -326,15 +322,19 @@ class Bot(Registry):
326
322
 
327
323
  async def _process_commands(self, room: Room, event: Event) -> None:
328
324
  """Parse and execute commands"""
329
- ctx = await self._build_context(room, event)
325
+ try:
326
+ ctx = await self._build_context(room, event)
330
327
 
331
- if ctx.command:
332
- for check in self._checks:
333
- if not await check(ctx):
334
- raise CheckError(ctx.command, check)
328
+ if ctx.command:
329
+ for check in self._checks:
330
+ if not await check(ctx):
331
+ raise CheckError(ctx.command, check)
335
332
 
336
- await self._on_command(ctx)
337
- await ctx.command(ctx)
333
+ await self._on_command(ctx)
334
+ await ctx.command(ctx)
335
+ except Exception as error:
336
+ ctx = Context(bot=self, room=room, event=event)
337
+ await self._on_command_error(ctx, error)
338
338
 
339
339
  async def _build_context(self, matrix_room: Room, event: Event) -> Context:
340
340
  room = self.get_room(matrix_room.room_id)
matrix/registry.py CHANGED
@@ -65,7 +65,6 @@ class Registry:
65
65
 
66
66
  self._event_handlers: Dict[Type[Event], List[Callback]] = defaultdict(list)
67
67
  self._hook_handlers: Dict[str, List[Callback]] = defaultdict(list)
68
- self._fallback_error_handler: Optional[ErrorCallback] = None
69
68
  self._error_handlers: Dict[type[Exception], ErrorCallback] = {}
70
69
  self._command_error_handlers: Dict[type[Exception], CommandErrorCallback] = {}
71
70
 
@@ -378,14 +377,15 @@ class Registry:
378
377
  ```
379
378
  """
380
379
 
380
+ if not exception:
381
+ exception = Exception
382
+
381
383
  def wrapper(func: ErrorCallback) -> ErrorCallback:
382
384
  if not inspect.iscoroutinefunction(func):
383
385
  raise TypeError("Error handlers must be coroutines")
384
386
 
385
- if exception:
386
- self._error_handlers[exception] = func
387
- else:
388
- self._fallback_error_handler = func
387
+ self._error_handlers[exception] = func
388
+
389
389
  logger.debug(
390
390
  "registered error handler '%s' on %s",
391
391
  func.__name__,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrix-python
3
- Version: 1.4.6a0
3
+ Version: 1.4.7a0
4
4
  Summary: An easy-to-use Matrix bot framework designed for quick development and minimal setup
5
5
  Author: Simon Roy, Chris Dedman Rollet
6
6
  Maintainer-email: Code Society Lab <admin@codesociety.xyz>
@@ -1,6 +1,6 @@
1
1
  matrix/__init__.py,sha256=g8yEFjELnnwlvOKns-Ug6LgOezkjAFZ-Opt7esbBHKg,728
2
- matrix/_version.py,sha256=rxov6PXTQVt5rKd2h-A8n5ETLEXZ52KLdqbL608ZU2s,528
3
- matrix/bot.py,sha256=NpCZQMHr6rD4DDYDywQErE4fCMW1KZrU0lOF2ZIzuAc,11910
2
+ matrix/_version.py,sha256=cIY61sFj4baHEv-2SFzhHnMonmSbAkIpGKrCbxZ8dPU,528
3
+ matrix/bot.py,sha256=tbcn1Ra025I9plM-gf0NpzPKSTBlYe0_L8_RLO8w9GM,11984
4
4
  matrix/checks.py,sha256=F_7432_OcFO-im4fRAj62MUsyv1mXywT4OsGC_7xbBQ,486
5
5
  matrix/command.py,sha256=GrP3WsT07sKehGX7PHfnT7gRX22d99877VPd0X2ViEw,10514
6
6
  matrix/config.py,sha256=JW_BBs-msIhtv1AGebZumLsx4td-Gp-NZaNYPJxRsEo,3680
@@ -11,14 +11,14 @@ matrix/extension.py,sha256=RbCx58CdRXF8kGUgS-ec1aZdd-K5hQedhCCQ0-YR4Vg,2272
11
11
  matrix/group.py,sha256=TRIX7PE3lcB2ZWu3xY2W2OAmE_a8-i2zHNBYnX5uj28,3691
12
12
  matrix/message.py,sha256=w6pu86goylxdrX5fgXPUMB_tW0bOFIk6tKy6qkXTjl4,5136
13
13
  matrix/protocols.py,sha256=nFb4tLanwtrKWoIhZ96xMwXPjD3RF5ITca_yXtakXC4,166
14
- matrix/registry.py,sha256=jxXg_f_pVl6nuwLdVOIjWJ9Yl9hDJSLwoChnnr3ztNs,12753
14
+ matrix/registry.py,sha256=PgdmbBADS-yqdFdj9x3QSsVfefx8Li848CU_UBbqCLQ,12646
15
15
  matrix/room.py,sha256=PBuMWQo8mKy2d2XIeMbBlVBTnnqZjOPPGpKLp4K1AVM,14038
16
16
  matrix/scheduler.py,sha256=EXsL9i8IDXhcpdW8lti0BR5XcIgkmud4iwOPaqcE9Gw,1727
17
17
  matrix/types.py,sha256=UFjC7p8RAf7piEPvp2X3NuWdqBwkM9Yc3He7KWb9icc,384
18
18
  matrix/help/__init__.py,sha256=1u7V7T_-VgYDeQCTXsc4y8Fo-8gJhOqYJq2U3cUjMWg,168
19
19
  matrix/help/help_command.py,sha256=xCLmKklw74LEMjbUfgQR9eaPMFvi3sPtDw2n2pnAnVQ,12800
20
20
  matrix/help/pagination.py,sha256=sJk0wC46sFHf7xl7WsGRAUc4FC7b9hPqmwQDmvcjwgM,2717
21
- matrix_python-1.4.6a0.dist-info/METADATA,sha256=_LnIZv4FZ76G_ncBzjfbwhb0B2ahf4vkMWrvXR1Jf4c,44672
22
- matrix_python-1.4.6a0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
- matrix_python-1.4.6a0.dist-info/top_level.txt,sha256=BvHVM9c7-5SLzg-1OCRpHKgqAubWhRN1e38e6coHs-g,7
24
- matrix_python-1.4.6a0.dist-info/RECORD,,
21
+ matrix_python-1.4.7a0.dist-info/METADATA,sha256=i0D7FpTrWeuERNEsaKTyljaqwmO6UF11pGf97xr2sgY,44672
22
+ matrix_python-1.4.7a0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
+ matrix_python-1.4.7a0.dist-info/top_level.txt,sha256=BvHVM9c7-5SLzg-1OCRpHKgqAubWhRN1e38e6coHs-g,7
24
+ matrix_python-1.4.7a0.dist-info/RECORD,,