Add assembly messages

This commit is contained in:
redfast00 2019-08-02 20:34:45 +02:00
parent bd2e235cd7
commit 51d66e5317
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -7,7 +7,8 @@ import json
from datetime import datetime
from collections import defaultdict
import mpd
from urllib.parse import urlencode
from urllib.request import Request, urlopen
mpc = mpd.MPDClient()
mpc.timeout = 0.2
@ -88,6 +89,11 @@ def messages_post():
return "OK"
messages.append(Message(time, sender, sendertype, str(message, "UTF-8")))
url = 'http://10.0.5.42:8000/' # Set destination URL here
post_fields = {'X-Messages': message} # Set POST fields here
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
speak(message)
return "OK"