X-Git-Url: http://git.treefish.org/~alex/mtxbot.git/blobdiff_plain/a6f58518069909db7b170ad374b13328986b98da..6c4dbc2edd8bf5cac128c2fa48728d8abe52432e:/src/presence.py?ds=sidebyside diff --git a/src/presence.py b/src/presence.py index e239bdb..7430ee8 100644 --- a/src/presence.py +++ b/src/presence.py @@ -1,5 +1,6 @@ import aiofiles import asyncio +import base64 import errno import logging import posix @@ -68,12 +69,19 @@ class Presence: if self._stop: break if self._joined_room_id != None: + try: + msgB64Bytes = line.rstrip("\n").encode("UTF-8") + msgBytes = base64.b64decode(msgB64Bytes) + msgStr = msgBytes.decode("UTF-8") + except: + self._log(logging.WARNING, "Error decoding message") + continue await client.room_send( room_id=self._joined_room_id, message_type="m.room.message", content={ "msgtype": "m.text", - "body": line.rstrip("\n") + "body": msgStr } ) else: