From 992df0852fdb7984acb465170b973a19c5c6b4fa Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Thu, 4 Jul 2024 08:00:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Misskey:=20=E3=82=AF=E3=83=AC=E3=83=87?= =?UTF-8?q?=E3=83=B3=E3=82=B7=E3=83=A3=E3=83=AB=E5=8F=96=E5=BE=97=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E4=B8=80=E5=9B=9E=E3=81=A0=E3=81=91=E8=A1=8C?= =?UTF-8?q?=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/run.py b/run.py index 36ae7374a1..3001949b6c 100644 --- a/run.py +++ b/run.py @@ -193,6 +193,17 @@ def main(): elif conf.MODE == "misskey": misskey_client = Misskey(conf.MISSKEY_DOMAIN, i=conf.MISSKEY_API_TOKEN) + for i in range(10): + try: + cred = misskey_client.i() + break + except ReadTimeout as e: + if i < 9: + logger.exception(e) + time.sleep(1) + else: + raise e + async def misskey_runner(): while True: try: @@ -223,29 +234,18 @@ async def misskey_runner(): mentions = note.get("mentions") if ( host is None or host == conf.MISSKEY_DOMAIN - ) and mentions: - cred = None - - for i in range(10): - try: - cred = misskey_client.i() - break - except ReadTimeout as e: - logger.exception(e) - time.sleep(1) - - if cred is not None and cred["id"] in mentions: - client = MisskeyClient(misskey_client, note) - client.add_waiting_reaction() - try: - analyze.analyze_message( - note["text"] - .replace("\xa0", " ") - .split(" ", 1)[1] - )(client) - except Exception as e: - logger.exception(e) - client.post("エラーが発生したっぽ......") + ) and mentions and cred["id"] in mentions: + client = MisskeyClient(misskey_client, note) + client.add_waiting_reaction() + try: + analyze.analyze_message( + note["text"] + .replace("\xa0", " ") + .split(" ", 1)[1] + )(client) + except Exception as e: + logger.exception(e) + client.post("エラーが発生したっぽ......") except websockets.ConnectionClosedError: time.sleep(1) From e1016f47dd38b99385c96b4257b76d144e6ced78 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:02:14 +0000 Subject: [PATCH 2/2] =?UTF-8?q?format=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=9F=E3=81=AE=E3=81=A7=E7=9B=B4=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=82=E3=81=92=E3=81=9F=E3=82=88=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 3001949b6c..acaf442c47 100644 --- a/run.py +++ b/run.py @@ -233,8 +233,10 @@ async def misskey_runner(): host = note["user"].get("host") mentions = note.get("mentions") if ( - host is None or host == conf.MISSKEY_DOMAIN - ) and mentions and cred["id"] in mentions: + (host is None or host == conf.MISSKEY_DOMAIN) + and mentions + and cred["id"] in mentions + ): client = MisskeyClient(misskey_client, note) client.add_waiting_reaction() try: