]> git.treefish.org Git - mtxbot.git/blobdiff - src/presence.py
use b64 encoding
[mtxbot.git] / src / presence.py
index e239bdb454c5cde70a8dc31d87b6cfb4835e4c49..7430ee814f4a5e02b2138fed820473964ba16454 100644 (file)
@@ -1,5 +1,6 @@
 import aiofiles
 import asyncio
 import aiofiles
 import asyncio
+import base64
 import errno
 import logging
 import posix
 import errno
 import logging
 import posix
@@ -68,12 +69,19 @@ class Presence:
             if self._stop:
                 break
             if self._joined_room_id != None:
             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",
                 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:
                     }
                 )
             else: