From ad81e3b55e40d7fde0cb6b7ec9ae12612c33fa10 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Mon, 7 Sep 2015 18:12:27 +0200 Subject: [PATCH] fixed tts.lua thx @Brawl345 --- plugins/tts.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/tts.lua b/plugins/tts.lua index 6b159ac..cc60dd3 100644 --- a/plugins/tts.lua +++ b/plugins/tts.lua @@ -9,13 +9,15 @@ local function run(msg, matches) lang = matches[1] end local b = 1 - + local text = string.gsub(text, "%+", "plus") while b ~= 0 do text,b = text:gsub('^+','+') text = text:trim() end + local text = string.gsub(text, "%s+", "+") + -- because everyone loves german umlauts, right? :3 local text = string.gsub(text, "ä", "ae") local text = string.gsub(text, "Ä", "Ae") local text = string.gsub(text, "ö", "oe") @@ -23,18 +25,25 @@ local function run(msg, matches) local text = string.gsub(text, "ü", "ue") local text = string.gsub(text, "Ü", "Ue") local text = string.gsub(text, "ß", "ss") - local url = "http://translate.google.com/translate_tts?tl="..lang.."&q=" .. text + local text = string.gsub(text, "%&", "und") + local url = "http://translate.google.com/translate_tts?tl="..lang.."&q="..text.."&ie=UTF-8&total=1&idx=0&client=t" local file = download_to_file(url) + if file == nil then + return "Google hat den Zugriff auf die API geblockt. URL: "..url + end local cb_extra = {file_path=file} send_audio(receiver, file, rmtmp_cb, cb_extra) end return { - description = "Text To Speech", - usage = "/tts [whatever]", - patterns = { + description = "Text-To-Speech", + usage = { + "/tts [Text]: Sendet Sprachnachricht mit dem Text", + "/tts(Sprache) [Text]: Sendet Sprachnachricht in der Sprache mit dem Text (bspw. !ttsen Hello)" + }, + patterns = { "^/tts (.+)$", "^/tts(%w+) (.+)$" - }, - run = run + }, + run = run } \ No newline at end of file