Explorar el Código

Merge branch 'yell-plugin' of kirkleon/rollbot3 into master

kirkleon hace 5 años
padre
commit
e30f4c508e
Se han modificado 3 ficheros con 28 adiciones y 0 borrados
  1. 3 0
      config/secrets.toml.template
  2. 1 0
      src/plugins/__init__.py
  3. 24 0
      src/plugins/yell.py

+ 3 - 0
config/secrets.toml.template

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

+ 1 - 0
src/plugins/__init__.py

@@ -10,3 +10,4 @@ import plugins.the_house
 import plugins.meme
 import plugins.hangguy
 import plugins.finchat
+import plugins.yell

+ 24 - 0
src/plugins/yell.py

@@ -0,0 +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(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!"