From 897f280d24e98f3bd15b65e53b1dfecc4bef3775 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Sat, 3 Aug 2024 01:52:50 +0100 Subject: [PATCH] fix misskey preview --- app/modules/misskey_preview.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/modules/misskey_preview.py b/app/modules/misskey_preview.py index 82a0992..6945004 100644 --- a/app/modules/misskey_preview.py +++ b/app/modules/misskey_preview.py @@ -35,15 +35,22 @@ class MisskeyPreviewModule(niobot.Module): if resp.status_code != 200: continue data = resp.json() + username = data["user"]["username"] if not data["text"]: continue text_body = [] for line in textwrap.shorten(data["text"], width=1000).splitlines(keepends=True): text_body.append("> " + (line or "\u200b")) body = "@%s:\n\n%s" % ( - "https://%s/notes/%s" % (parsed.netloc, data["user"]["username"]), - data["user"]["username"], + "https://%s/notes/%s" % (parsed.netloc, username), + username, "".join(text_body), ) - await self.bot.send_message(room, body, reply_to=event) + await self.bot.send_message( + room, + body, + reply_to=event, + content_type="html", + override={"body": f"@{username}: {data['text']!r}"} + ) sent.append(post_id)