Add support for bridging spoilers

This commit is contained in:
Tulir Asokan
2021-12-29 22:11:11 +02:00
parent aae8f78cb4
commit afb73b1d17
4 changed files with 11 additions and 3 deletions
@@ -95,5 +95,8 @@ class MatrixParser(BaseMatrixParser[TelegramMessage]):
async def color_to_fstring(self, msg: TelegramMessage, color: str) -> TelegramMessage:
return msg
async def spoiler_to_fstring(self, msg: TelegramMessage, spoiler: str) -> TelegramMessage:
async def spoiler_to_fstring(self, msg: TelegramMessage, reason: str) -> TelegramMessage:
msg = msg.format(self.e.SPOILER)
if reason:
msg = msg.prepend(f"{reason}: ")
return msg
@@ -29,6 +29,7 @@ from telethon.tl.types import (
MessageEntityMention as Mention,
MessageEntityMentionName as MentionName,
MessageEntityPre as Pre,
MessageEntitySpoiler as Spoiler,
MessageEntityStrike as Strike,
MessageEntityTextUrl as TextURL,
MessageEntityUnderline as Underline,
@@ -55,6 +56,7 @@ class TelegramEntityType(Enum):
MENTION = Mention
MENTION_NAME = InputMentionName
COMMAND = Command
SPOILER = Spoiler
USER_MENTION = 1
ROOM_MENTION = 2