fix misskey preview
This commit is contained in:
parent
ca005326d6
commit
897f280d24
1 changed files with 10 additions and 3 deletions
|
@ -35,15 +35,22 @@ class MisskeyPreviewModule(niobot.Module):
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
continue
|
continue
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
|
username = data["user"]["username"]
|
||||||
if not data["text"]:
|
if not data["text"]:
|
||||||
continue
|
continue
|
||||||
text_body = []
|
text_body = []
|
||||||
for line in textwrap.shorten(data["text"], width=1000).splitlines(keepends=True):
|
for line in textwrap.shorten(data["text"], width=1000).splitlines(keepends=True):
|
||||||
text_body.append("> " + (line or "\u200b"))
|
text_body.append("> " + (line or "\u200b"))
|
||||||
body = "<a href=\"%s\">@%s:</a>\n\n%s" % (
|
body = "<a href=\"%s\">@%s:</a>\n\n%s" % (
|
||||||
"https://%s/notes/%s" % (parsed.netloc, data["user"]["username"]),
|
"https://%s/notes/%s" % (parsed.netloc, username),
|
||||||
data["user"]["username"],
|
username,
|
||||||
"".join(text_body),
|
"".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)
|
sent.append(post_id)
|
||||||
|
|
Loading…
Reference in a new issue