Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Misskey: クレデンシャル取得処理を一回だけ行う" #4141

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,6 @@ def main():
misskey_client = Misskey(conf.MISSKEY_DOMAIN, i=conf.MISSKEY_API_TOKEN)
misskey_client.timeout = 2

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:
Expand Down Expand Up @@ -234,21 +223,30 @@ 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
):
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("エラーが発生したっぽ......")
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("エラーが発生したっぽ......")
except websockets.ConnectionClosedError:
time.sleep(1)

Expand Down
Loading