Browse Source

Finished up the yell command

Kirk Trombley 5 years ago
parent
commit
11fb9870ab
2 changed files with 23 additions and 2 deletions
  1. 3 0
      config/secrets.toml.template
  2. 20 2
      src/plugins/yell.py

+ 3 - 0
config/secrets.toml.template

@@ -18,3 +18,6 @@ banlist = {}
 
 [hangguy]
 alert_chat = ""
+
+[yell]
+endpoint = "your-yell-endpoint"

+ 20 - 2
src/plugins/yell.py

@@ -1,6 +1,24 @@
+import tempfile
+import os.path
+
+from gtts import gTTS
+import requests
+
 from command_system import as_plugin
+from config import get_secret
+
+YELL_ENDPOINT = get_secret("yell.endpoint")
 
 
 @as_plugin
-def yell():
-    return "Hello, world!"
+def yell(msg):
+    tmp_dir = tempfile.mkdtemp()
+    tmp_file = os.path.join(tmp_dir, "yell.mp3")
+
+    tts = gTTS(text=msg.raw_args, lang="en", slow=False)
+    tts.save(tmp_file)
+    
+    with open(tmp_file, "rb") as f:
+        requests.post(YELL_ENDPOINT, data=f)
+
+    return "Passed the message along to Audiobot!"