add formated message

This commit is contained in:
histausse 2021-10-04 20:09:42 +02:00
parent b39031d53d
commit 66cbd31f82
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 20 additions and 0 deletions

View file

@ -144,6 +144,20 @@ class Client(Aobject):
} }
await self.__send_message(room, msg) await self.__send_message(room, msg)
async def send_formated_message(
self,
room: Union[RoomAlias, RoomId],
message: str,
unformated_message: Optional[str]=None
):
msg = {
"msgtype": "m.text",
"format": "org.matrix.custom.html",
"formatted_body": message,
"body": unformated_message or message,
}
await self.__send_message(room, msg)
async def send_firework_message( async def send_firework_message(
self, self,
room: Union[RoomAlias, RoomId], room: Union[RoomAlias, RoomId],

View file

@ -29,6 +29,12 @@ async def main():
client.set_invite_policy(whitelist_policy) client.set_invite_policy(whitelist_policy)
await client.send_message(room_name, "Beware of Greeks bearing gifts") await client.send_message(room_name, "Beware of Greeks bearing gifts")
await asyncio.sleep(5) await asyncio.sleep(5)
await client.send_formated_message(
room_name,
"<b><font color='red'>Beware of Greeks bearing gifts</font></b>",
"Beware of Greeks bearing gifts"
)
await asyncio.sleep(5)
await client.send_firework_message(room_name, "fire") await client.send_firework_message(room_name, "fire")
await asyncio.sleep(5) await asyncio.sleep(5)
await client.send_confetti_message(room_name, "confetti") await client.send_confetti_message(room_name, "confetti")