tts verwendet nun Baidu (nur Englisch)

Shimakaze zum NSFW-Rpic-Plugin hinzugefügt
This commit is contained in:
Akamaru 2016-04-07 19:46:11 +02:00
parent 326be7afb9
commit 2c8c66cce3
3 changed files with 13 additions and 27 deletions

3
.gitignore vendored
View File

@ -18,4 +18,5 @@ plugins/gravatar.lua
pictures/3uhrmorgens.jpg pictures/3uhrmorgens.jpg
plugins/figuya.lua plugins/figuya.lua
plugins/plex_info.lua plugins/plex_info.lua
plugins/plex_last.lua plugins/plex_last.lua
plugins/akamaru.lua

View File

@ -9,7 +9,8 @@ function run(msg, matches)
local pics = { local pics = {
-- add more below! -- add more below!
["/nsfw"] = "../Bilder/Mikubot/nsfw/", ["/nsfw"] = "../Bilder/Mikubot/nsfw/",
["/nsfw gif"] = "../Bilder/Mikubot/nsfw/gifs/" ["/nsfw gif"] = "../Bilder/Mikubot/nsfw/gifs/",
["/nsfw shimakaze"] = "../Bilder/Mikubot/nsfw/Shimakaze/"
} }
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
@ -26,14 +27,14 @@ function run(msg, matches)
return "Fehler: " .. img return "Fehler: " .. img
end end
else else
return '"'..imgtype..'" gibt es nicht.\n' return '"'..imgtype..'" gibt es nicht.\n/nsfw\n/nsfw gif\n/nsfw shimakaze'
end end
end end
return { return {
description = "Sendet ein zufälliges Bild (NSFW)", description = "Sendet ein zufälliges Bild (NSFW)",
usage = {"/nsfw (gif)"}, usage = {"/nsfw","/nsfw gif","/nsfw shimakaze"},
patterns = {"^/nsfw$","^/nsfw gif$"}, patterns = {"^/nsfw$","^/nsfw gif$","^/nsfw shimakaze$"},
run = run run = run
} }
end end

View File

@ -1,23 +1,7 @@
-- TTS plugin in lua
local function run(msg, matches) local function run(msg, matches)
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
if matches[2] == nil then local text = matches[1]
text = matches[1]
lang = 'de'
else
text = matches[2]
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, "Ä", "Ae") local text = string.gsub(text, "Ä", "Ae")
local text = string.gsub(text, "ö", "oe") local text = string.gsub(text, "ö", "oe")
@ -26,7 +10,9 @@ local function run(msg, matches)
local text = string.gsub(text, "Ü", "Ue") local text = string.gsub(text, "Ü", "Ue")
local text = string.gsub(text, "ß", "ss") local text = string.gsub(text, "ß", "ss")
local text = string.gsub(text, "%&", "und") 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 text = string.gsub(text, " ", "+")
local url = "http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&text="..text
local file = download_to_file(url, text..'.mp3') local file = download_to_file(url, text..'.mp3')
if file == nil then if file == nil then
return "Ein Fehler ist aufgetreten, besuche die URL eventuell direkt?\n"..url return "Ein Fehler ist aufgetreten, besuche die URL eventuell direkt?\n"..url
@ -38,12 +24,10 @@ end
return { return {
description = "Text-To-Speech", description = "Text-To-Speech",
usage = { usage = {
"/tts [Text]: Sendet Sprachnachricht mit dem Text", "/tts [Text]: Sendet Sprachnachricht mit dem Text"
"/tts(Sprache) [Text]: Sendet Sprachnachricht in der Sprache mit dem Text (bspw. !ttsen Hello)"
}, },
patterns = { patterns = {
"^/tts (.+)$", "^/tts (.+)$"
"^/tts(%w+) (.+)$"
}, },
run = run run = run
} }