fix: encoding

This commit is contained in:
Tim Schubert 2020-05-30 11:43:38 +02:00
parent 9bf963332c
commit bbe474e78c
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA

View file

@ -3,13 +3,18 @@
import asyncio import asyncio
import email import email
import pathlib import pathlib
from os import path, listdir
import sys import sys
import logging import logging
from os import path, listdir
from email.header import decode_header, make_header
from nio import (AsyncClient, Api, ClientConfig, RoomSendError) from nio import (AsyncClient, Api, ClientConfig, RoomSendError)
from inotify_simple import INotify, flags from inotify_simple import INotify, flags
def decode(header):
return make_hader(decode_header(header))
class Client(AsyncClient): class Client(AsyncClient):
def send_message(self, From, Subject): def send_message(self, From, Subject):
@ -18,7 +23,7 @@ class Client(AsyncClient):
message_type="m.room.message", message_type="m.room.message",
content={ content={
"msgtype": "m.text", "msgtype": "m.text",
"body": "From:\t%s\nSubject:\t%s" % (From, Subject) "body": "From:\t%s\nSubject:\t%s" % (decode(From), decode(Subject))
} }
) )