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"