Skip to content

Commit 2cc3d23

Browse files
authored
Merge pull request #2411 from dev-hato/fix-format-fix_websocket_disconnect
formatが間違ってたので直してあげたよ! #2410
2 parents c9d013b + 29ebf71 commit 2cc3d23

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

run.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,30 +190,38 @@ async def discord_runner():
190190
try:
191191
# pylint: disable=E1101
192192
async with websockets.connect(
193-
"wss://"
194-
+ misskey_client.address
195-
+ "/streaming"
196-
+ "?i="
197-
+ misskey_client.token
193+
"wss://"
194+
+ misskey_client.address
195+
+ "/streaming"
196+
+ "?i="
197+
+ misskey_client.token
198198
) as ws:
199199
await ws.send(
200200
json.dumps(
201-
{"type": "connect", "body": {"channel": "main", "id": "main"}}
201+
{
202+
"type": "connect",
203+
"body": {"channel": "main", "id": "main"},
204+
}
202205
)
203206
)
204207
while True:
205208
data = json.loads(await ws.recv())
206-
if data["type"] == "channel" and data["body"]["type"] == "mention":
209+
if (
210+
data["type"] == "channel"
211+
and data["body"]["type"] == "mention"
212+
):
207213
note = data["body"]["body"]
208214
host = note["user"].get("host")
209215
mentions = note.get("mentions")
210216
if (
211-
(host is None or host == conf.MISSKEY_DOMAIN)
212-
and mentions
213-
and misskey_client.i()["id"] in mentions
217+
(host is None or host == conf.MISSKEY_DOMAIN)
218+
and mentions
219+
and misskey_client.i()["id"] in mentions
214220
):
215221
analyze.analyze_message(
216-
note["text"].replace("\xa0", " ").split(" ", 1)[1]
222+
note["text"]
223+
.replace("\xa0", " ")
224+
.split(" ", 1)[1]
217225
)(MisskeyClient(misskey_client, note))
218226
except websockets.ConnectionClosedError:
219227
time.sleep(1)

0 commit comments

Comments
 (0)