forked from Kelder/cammiechat
Add assembly messages
This commit is contained in:
parent
bd2e235cd7
commit
51d66e5317
1 changed files with 7 additions and 1 deletions
8
chat.py
8
chat.py
|
@ -7,7 +7,8 @@ import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import mpd
|
import mpd
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
mpc = mpd.MPDClient()
|
mpc = mpd.MPDClient()
|
||||||
mpc.timeout = 0.2
|
mpc.timeout = 0.2
|
||||||
|
@ -88,6 +89,11 @@ def messages_post():
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
messages.append(Message(time, sender, sendertype, str(message, "UTF-8")))
|
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)
|
speak(message)
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
Loading…
Reference in a new issue