From 4b0fee536f6899915b86e33d1316a078850aa759 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Sat, 6 Jun 2015 22:16:11 +0200 Subject: [PATCH] new plugins alive.lua and tts.lua --- plugins/alive.lua | 14 ++++++++++++++ plugins/tts.lua | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 plugins/alive.lua create mode 100644 plugins/tts.lua diff --git a/plugins/alive.lua b/plugins/alive.lua new file mode 100644 index 0000000..e945d5c --- /dev/null +++ b/plugins/alive.lua @@ -0,0 +1,14 @@ +function run(msg, matches) + local user_name = get_name(msg) + local answers = {'Ja?','Was gibts, ' .. user_name .. '?','Ja ' .. user_name .. ', was ist?', + 'Ich bin noch da.', user_name ,'Nein!'} + return answers[math.random(#answers)] +end + +return { + description = "Ist der Bot noch da?", + usage = {"Miku"}, + patterns = {"^[M|m]iku$"}, + run = run +} +--by Akamaru [https://ponywave.de] \ No newline at end of file diff --git a/plugins/tts.lua b/plugins/tts.lua new file mode 100644 index 0000000..038d2e8 --- /dev/null +++ b/plugins/tts.lua @@ -0,0 +1,39 @@ +-- TTS plugin in lua +local function run(msg, matches) + local receiver = get_receiver(msg) + if matches[2] == nil then + text = matches[1] + lang = 'de' + else + text = matches[2] + lang = matches[1] + end + local b = 1 + + while b ~= 0 do + text,b = text:gsub('^+','+') + text = text:trim() + end + local text = string.gsub(text, "%s+", "+") + local text = string.gsub(text, "ä", "ae") + local text = string.gsub(text, "Ä", "Ae") + local text = string.gsub(text, "ö", "oe") + local text = string.gsub(text, "Ö", "Oe") + 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 file = download_to_file(url) + local cb_extra = {file_path=file} + send_audio(receiver, file, rmtmp_cb, cb_extra) +end + +return { + description = "Text To Speech", + usage = "!tts [whatever]", + patterns = { + "^/tts (.+)$", + "^/tts(%w+) (.+)$" + }, + run = run +} \ No newline at end of file