Fix misskey preview 403'ing

This commit is contained in:
Nexus 2024-08-11 15:21:37 +01:00
parent 293777a688
commit fdbc802ec1

View file

@ -16,12 +16,14 @@ class MisskeyPreviewModule(niobot.Module):
@niobot.event("message")
async def on_message(self, room: niobot.MatrixRoom, event: niobot.RoomMessage):
supported_prefixes = self.bot.cfg.get("misskey_preview", {})
supported_prefixes = supported_prefixes.get("urls", ["https://fedi.transgender.ing/notes"])
supported_prefixes = supported_prefixes.get("urls", ["https://fedi.transgender.ing"])
if not isinstance(event, niobot.RoomMessageText):
return
sent = []
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0"}
) as client:
for item in event.body.split():
if not event.body.startswith(tuple(supported_prefixes)):
return