From 11eb764e6a217b29ed6797ffcfc0ad53a33d6877 Mon Sep 17 00:00:00 2001 From: massongit Date: Sun, 26 Nov 2023 20:09:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Misskey=E3=81=AE=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=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=83=AA=E3=83=88=E3=83=A9=E3=82=A4=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E5=85=A5=E3=82=8C=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/run.py b/run.py index d47c08c050..e0f72193d5 100644 --- a/run.py +++ b/run.py @@ -11,6 +11,7 @@ import time from concurrent.futures import ThreadPoolExecutor from typing import Callable, List +from requests.exceptions import ReadTimeout import discord import websockets @@ -223,18 +224,28 @@ async def misskey_runner(): if ( (host is None or host == conf.MISSKEY_DOMAIN) and mentions - and misskey_client.i()["id"] in mentions ): - client = MisskeyClient(misskey_client, note) - try: - analyze.analyze_message( - note["text"] - .replace("\xa0", " ") - .split(" ", 1)[1] - )(client) - except Exception as e: - logger.exception(e) - client.post("エラーが発生したっぽ......") + 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) + 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 465d88b12cfdd4eef603895c37805c48674cac22 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:11:26 +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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index e0f72193d5..5f2865c7e2 100644 --- a/run.py +++ b/run.py @@ -11,13 +11,13 @@ import time from concurrent.futures import ThreadPoolExecutor from typing import Callable, List -from requests.exceptions import ReadTimeout import discord import websockets from flask import Flask, jsonify, request from markupsafe import escape from misskey import Misskey +from requests.exceptions import ReadTimeout from slackeventsapi import SlackEventAdapter import slackbot_settings as conf @@ -222,9 +222,8 @@ async def misskey_runner(): host = note["user"].get("host") mentions = note.get("mentions") if ( - (host is None or host == conf.MISSKEY_DOMAIN) - and mentions - ): + host is None or host == conf.MISSKEY_DOMAIN + ) and mentions: cred = None for i in range(10):