diff --git a/chat.py b/chat.py index 5731070..a5d40ae 100644 --- a/chat.py +++ b/chat.py @@ -20,6 +20,12 @@ last_sent = defaultdict(lambda: datetime(1970,1,1)) timeout = 1 +def speak(text): + espk_proc = subprocess.Popen(("espeak", "-vnl"), stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + espk_proc.stdin.write(text) + espk_proc.stdin.close() + + class Message: def __init__(self, time, sender, sendertype, msg): self.time = time @@ -79,10 +85,11 @@ def messages_post(): if "spam" in str(message, "UTF-8").lower(): messages.append(Message(time, "1.3.3.7", "ip", "Nee")) - else: - messages.append(Message(time, sender, sendertype, str(message, "UTF-8"))) + return "OK" + + messages.append(Message(time, sender, sendertype, str(message, "UTF-8"))) + speak(message) - subprocess.Popen(("espeak", "-vnl"), input=message, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return "OK" diff --git a/restart.sh b/restart.sh index 74c34e7..7350f8e 100755 --- a/restart.sh +++ b/restart.sh @@ -1,6 +1,6 @@ #!/bin/bash killall gunicorn -./runChat & disown +./run.sh & disown sleep 1 DISPLAY=:0 xdotool key F5 diff --git a/run.sh b/run.sh index 5f34d49..d0bd276 100755 --- a/run.sh +++ b/run.sh @@ -2,4 +2,4 @@ cd "$(dirname "$0")" export FLASK_APP=chat.py -exec gunicorn -w 1 -b127.0.0.1:5000 chat:app +exec gunicorn -w 1 -b0.0.0.0:5000 chat:app