log more
This commit is contained in:
parent
b8d8131dbb
commit
b5b71b741b
1 changed files with 5 additions and 1 deletions
|
@ -27,13 +27,15 @@ class MisskeyPreviewModule(niobot.Module):
|
|||
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)):
|
||||
if not item.startswith(tuple(supported_prefixes)):
|
||||
return
|
||||
parsed = urlparse(item)
|
||||
post_id = parsed.path.split("/")[-1]
|
||||
if post_id in sent:
|
||||
self.log.info("Already sent post %s", post_id)
|
||||
continue
|
||||
elif len(sent) >= 5:
|
||||
self.log.info("Already sent 5 posts, stopping")
|
||||
break
|
||||
resp = await client.get("https://%s/api/v1/statuses/%s" % (parsed.netloc, post_id))
|
||||
if resp.status_code != 200:
|
||||
|
@ -46,6 +48,7 @@ class MisskeyPreviewModule(niobot.Module):
|
|||
continue
|
||||
|
||||
text = textwrap.shorten(data["text"], width=1000)
|
||||
self.log.info("Detected misskey post %s: %r", post_id, text)
|
||||
rendered = await self.bot._markdown_to_html(text)
|
||||
text_body = "<blockquote>%s</blockquote>" % rendered
|
||||
body = "<a href=\"%s\">@%s:</a><br>%s" % (
|
||||
|
@ -53,6 +56,7 @@ class MisskeyPreviewModule(niobot.Module):
|
|||
username,
|
||||
text_body,
|
||||
)
|
||||
self.log.info("Sending misskey post %s", post_id)
|
||||
await self.bot.send_message(
|
||||
room,
|
||||
body,
|
||||
|
|
Loading…
Reference in a new issue