]> git.treefish.org Git - mtxbot.git/blobdiff - src/presence.py
use b64 encoding
[mtxbot.git] / src / presence.py
index e239bdb454c5cde70a8dc31d87b6cfb4835e4c49..b3da8589dc1614fb250a2e0f352cfd441cdef0f3 100644 (file)
@@ -1,5 +1,6 @@
 import aiofiles
 import asyncio
+import base64
 import errno
 import logging
 import posix
@@ -68,12 +69,18 @@ class Presence:
             if self._stop:
                 break
             if self._joined_room_id != None:
+                try:
+                    msgB64Bytes = line.rstrip("\n").encode("UTF-8")
+                    msgBytes = base64.b64decode(msgB64Bytes)
+                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": msgBytes.decode("UTF-8")
                     }
                 )
             else: