diff --git a/maubot.yaml b/maubot.yaml index fba326a..02a6841 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: xyz.maubot.xkcd -version: 1.2.0 +version: 1.2.1 license: AGPL-3.0-or-later modules: - xkcd diff --git a/xkcd.py b/xkcd.py index 2f2dcee..7f167e5 100644 --- a/xkcd.py +++ b/xkcd.py @@ -41,7 +41,6 @@ except ImportError: Image = None - @dataclass class XKCDInfo(SerializableAttrs): year: str @@ -246,21 +245,26 @@ async def _send_xkcd(self, room_id: RoomID, xkcd: XKCDInfo) -> None: content["license_url"] = "https://xkcd.com/license.html" await self.client.send_message(room_id, content) else: - await self.client.send_text(room_id, text=f"{xkcd.num}: **{xkcd.title}**", - html=f"{xkcd.num}: {xkcd.safe_title}") - content = MediaMessageEventContent(url=info.mxc_uri, body=info.file_name, - msgtype=MessageType.IMAGE, - external_url=f"https://xkcd.com/{xkcd.num}", - info=ImageInfo( - mimetype=info.mime_type, - size=info.size, - width=info.width, - height=info.height, - ),) + content = MediaMessageEventContent( + msgtype=MessageType.IMAGE, + format=Format.HTML, + external_url=f"https://xkcd.com/{xkcd.num}", + url=info.mxc_uri, + filename=info.file_name, + body=f"{xkcd.num}: **{xkcd.title}**\n{xkcd.alt}", + formatted_body=f"{xkcd.num}: {xkcd.safe_title}" + f"
{xkcd.alt}", + info=ImageInfo( + mimetype=info.mime_type, + size=info.size, + width=info.width, + height=info.height, + ), + ) content["license"] = "CC-BY-NC-2.5" content["license_url"] = "https://xkcd.com/license.html" + await self.client.send_message(room_id, content) - await self.client.send_text(room_id, text=xkcd.alt) async def broadcast(self, xkcd: XKCDInfo) -> None: self.log.debug(f"Broadcasting xkcd {xkcd.num}")