From 51d66e531775e4e4cd67e5647126cceae0cd82dc Mon Sep 17 00:00:00 2001 From: redfast00 Date: Fri, 2 Aug 2019 20:34:45 +0200 Subject: [PATCH] Add assembly messages --- chat.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chat.py b/chat.py index a5d40ae..793c407 100644 --- a/chat.py +++ b/chat.py @@ -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"