tangled
alpha
login
or
join now
zenfyr.dev
/
xpost
2
fork
atom
social media crossposting tool. 3rd time's the charm
mastodon
misskey
crossposting
bluesky
2
fork
atom
overview
issues
1
pulls
pipelines
i have no idea what i'm doing
zenfyr.dev
6 days ago
de19853a
4c457fee
verified
This commit was signed with the committer's
known signature
.
zenfyr.dev
SSH Key Fingerprint:
SHA256:TtcIcnTnoAB5mqHofsaOxIgiMzfVBxej1AXT7DQdrTE=
+44
-53
3 changed files
expand all
collapse all
unified
split
bluesky
input.py
mastodon
input.py
misskey
input.py
+14
-17
bluesky/input.py
···
303
303
url += "&wantedCollections=app.bsky.feed.repost"
304
304
url += f"&wantedDids={self.did}"
305
305
306
306
-
async for ws in websockets.connect(
307
307
-
url,
308
308
-
ping_interval=20,
309
309
-
ping_timeout=10,
310
310
-
close_timeout=5,
311
311
-
):
306
306
+
while True:
312
307
try:
313
313
-
self.log.info("Listening to '%s'...", env.JETSTREAM_URL)
308
308
+
async with websockets.connect(
309
309
+
url,
310
310
+
ping_interval=20,
311
311
+
ping_timeout=10,
312
312
+
close_timeout=5,
313
313
+
) as ws:
314
314
+
self.log.info("Listening to '%s'...", env.JETSTREAM_URL)
314
315
315
315
-
async def listen_for_messages():
316
316
async for msg in ws:
317
317
self.submitter(lambda: self._accept_msg(msg))
318
318
319
319
-
listen = asyncio.create_task(listen_for_messages())
320
320
-
321
321
-
_ = await asyncio.gather(listen)
322
319
except websockets.ConnectionClosedError as e:
323
323
-
self.log.error(e, stack_info=True, exc_info=True)
324
324
-
self.log.info("Reconnecting to '%s'...", env.JETSTREAM_URL)
325
325
-
continue
320
320
+
self.log.warning("Connection closed: %s", e)
326
321
except TimeoutError as e:
327
327
-
self.log.error("Connection timeout: '%s'", e)
328
328
-
self.log.info("Reconnecting to '%s'...", env.JETSTREAM_URL)
329
329
-
continue
322
322
+
self.log.warning("Connection timeout: '%s'", e)
323
323
+
except Exception as e:
324
324
+
self.log.error("Unexpected error: '%s'", e, exc_info=True)
325
325
+
326
326
+
self.log.info("Reconnecting to '%s'...", env.JETSTREAM_URL)
+15
-18
mastodon/input.py
···
248
248
async def listen(self):
249
249
url = f"{self.streaming_url}/api/v1/streaming?stream=user"
250
250
251
251
-
async for ws in websockets.connect(
252
252
-
url,
253
253
-
additional_headers={"Authorization": f"Bearer {self.options.token}"},
254
254
-
ping_interval=20,
255
255
-
ping_timeout=10,
256
256
-
close_timeout=5,
257
257
-
):
251
251
+
while True:
258
252
try:
259
259
-
self.log.info("Listening to '%s'...", self.streaming_url)
253
253
+
async with websockets.connect(
254
254
+
url,
255
255
+
additional_headers={"Authorization": f"Bearer {self.options.token}"},
256
256
+
ping_interval=20,
257
257
+
ping_timeout=10,
258
258
+
close_timeout=5,
259
259
+
) as ws:
260
260
+
self.log.info("Listening to '%s'...", self.streaming_url)
260
261
261
261
-
async def listen_for_messages():
262
262
async for msg in ws:
263
263
self.submitter(lambda: self._accept_msg(msg))
264
264
265
265
-
listen = asyncio.create_task(listen_for_messages())
266
266
-
267
267
-
_ = await asyncio.gather(listen)
268
265
except websockets.ConnectionClosedError as e:
269
269
-
self.log.error(e, stack_info=True, exc_info=True)
270
270
-
self.log.info("Reconnecting to '%s'...", self.streaming_url)
271
271
-
continue
266
266
+
self.log.warning("Connection closed: %s", e)
272
267
except TimeoutError as e:
273
273
-
self.log.error("Connection timeout: '%s'", e)
274
274
-
self.log.info("Reconnecting to '%s'...", self.streaming_url)
275
275
-
continue
268
268
+
self.log.warning("Connection timeout: '%s'", e)
269
269
+
except Exception as e:
270
270
+
self.log.error("Unexpected error: '%s'", e, exc_info=True)
271
271
+
272
272
+
self.log.info("Reconnecting to '%s'...", self.streaming_url)
+15
-18
misskey/input.py
···
243
243
streaming: str = f"{'wss' if self.url.startswith('https') else 'ws'}://{self.url.split('://', 1)[1]}"
244
244
url: str = f"{streaming}/streaming?i={self.options.token}"
245
245
246
246
-
async for ws in websockets.connect(
247
247
-
url,
248
248
-
ping_interval=20,
249
249
-
ping_timeout=10,
250
250
-
close_timeout=5,
251
251
-
):
246
246
+
while True:
252
247
try:
253
253
-
self.log.info("Listening to '%s'...", streaming)
254
254
-
await self._subscribe_to_home(ws)
248
248
+
async with websockets.connect(
249
249
+
url,
250
250
+
ping_interval=20,
251
251
+
ping_timeout=10,
252
252
+
close_timeout=5,
253
253
+
) as ws:
254
254
+
self.log.info("Listening to '%s'...", streaming)
255
255
+
await self._subscribe_to_home(ws)
255
256
256
256
-
async def listen_for_messages():
257
257
async for msg in ws:
258
258
self.submitter(lambda: self._accept_msg(msg))
259
259
260
260
-
listen = asyncio.create_task(listen_for_messages())
261
261
-
262
262
-
_ = await asyncio.gather(listen)
263
260
except websockets.ConnectionClosedError as e:
264
264
-
self.log.error(e, stack_info=True, exc_info=True)
265
265
-
self.log.info("Reconnecting to '%s'...", streaming)
266
266
-
continue
261
261
+
self.log.warning("Connection closed: %s", e)
267
262
except TimeoutError as e:
268
268
-
self.log.error("Connection timeout: '%s'", e)
269
269
-
self.log.info("Reconnecting to '%s'...", streaming)
270
270
-
continue
263
263
+
self.log.warning("Connection timeout: '%s'", e)
264
264
+
except Exception as e:
265
265
+
self.log.error("Unexpected error: '%s'", e, exc_info=True)
266
266
+
267
267
+
self.log.info("Reconnecting to '%s'...", streaming)