Skip to content

Commit

Permalink
build(deps): update chaosvm and aioqzone
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Dec 1, 2023
1 parent c7197b9 commit 13c737d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Qzone3TG"
version = "0.9.6.dev3"
version = "0.9.6.dev4"
description = "Forward Qzone feeds to telegram."
authors = ["aioqzone <zzzzss990315@gmail.com>"]
readme = "README.md"
Expand Down
13 changes: 11 additions & 2 deletions src/qzone3tg/app/base/_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def add_hb_impls(self: BaseApp):
last_fail_cause: BaseException | None = None

def is_exc_similar(exc1: BaseException, exc2: BaseException) -> bool:
match (exc1):
match exc1:
case ClientResponseError() if isinstance(exc2, ClientResponseError):
return (
exc1.code == exc2.code
Expand All @@ -99,6 +99,13 @@ def is_exc_similar(exc1: BaseException, exc2: BaseException) -> bool:
case _:
return exc1 == exc2

def friendly_exc_str(exc: BaseException) -> str:
match exc:
case ClientResponseError():
return f"{exc.__class__.__name__}({exc.status}: {exc.message})"
case _:
return str(exc)

@self.qzone.hb_failed.add_impl
async def HeartbeatFailed(exc: BaseException):
# unpack wrapped exceptions
Expand All @@ -117,7 +124,9 @@ async def HeartbeatFailed(exc: BaseException):

self.timers["hb"].pause()
self.log.warning(f"因{exc.__class__.__name__}暂停心跳")
await self.bot.send_message(self.admin, **Text("心跳已暂停", Pre(str(exc))).as_kwargs())
await self.bot.send_message(
self.admin, **Text("心跳已暂停", Pre(friendly_exc_str(exc))).as_kwargs()
)

@self.qzone.hb_refresh.add_impl
async def HeartbeatRefresh(num: int):
Expand Down

0 comments on commit 13c737d

Please sign in to comment.