2015-08-15 15:42:49 +02:00
|
|
|
do
|
|
|
|
function get_random_image(dir)
|
|
|
|
files = scandir(dir)
|
|
|
|
file = files[math.random(#files)]
|
|
|
|
return file
|
|
|
|
end
|
|
|
|
|
|
|
|
function run(msg, matches)
|
|
|
|
local pics = {
|
2015-08-19 15:16:44 +02:00
|
|
|
-- add more below!
|
2016-03-27 16:03:31 +02:00
|
|
|
["test"] = "../Bilder/Mikubot/sfw/test/",
|
|
|
|
["anime"] = "../Bilder/Mikubot/sfw/anime/",
|
|
|
|
["mlp"] = "../Bilder/Mikubot/sfw/mlp/",
|
|
|
|
["faktillon"] = "../Bilder/Mikubot/sfw/faktillon/",
|
|
|
|
["faktastisch"] = "../Bilder/Mikubot/sfw/faktastisch/",
|
|
|
|
["gamefakt"] = "../Bilder/Mikubot/sfw/gamefakt/",
|
|
|
|
["faktglaublich"] = "../Bilder/Mikubot/sfw/faktglaublich/"
|
2015-08-19 15:16:44 +02:00
|
|
|
}
|
2015-08-15 15:42:49 +02:00
|
|
|
|
|
|
|
local receiver = get_receiver(msg)
|
|
|
|
local imgtype = matches[1]
|
|
|
|
|
|
|
|
if pics[imgtype] then
|
|
|
|
local img = pics[imgtype]..get_random_image(pics[imgtype])
|
|
|
|
print("Sende... "..img)
|
2016-04-11 23:21:49 +02:00
|
|
|
if string.ends(img, ".gif") or string.ends(img, ".mp4") then
|
2015-08-15 15:42:49 +02:00
|
|
|
send_document(receiver, img, function() end, function() end)
|
2015-08-19 15:16:44 +02:00
|
|
|
elseif string.ends(img, ".jpg") or string.ends(img, ".jpeg") or string.ends(img, ".png") then
|
2015-08-15 15:42:49 +02:00
|
|
|
send_photo(receiver, img, function() end, function() end)
|
2015-08-19 15:16:44 +02:00
|
|
|
else
|
|
|
|
return "Fehler: " .. img
|
2015-08-15 15:42:49 +02:00
|
|
|
end
|
2015-08-19 15:16:44 +02:00
|
|
|
else
|
2016-03-27 16:03:31 +02:00
|
|
|
return '"'..imgtype..'" gibt es nicht.\nEs gibt:\nanime\nmlp\nfaktillon\nfaktastisch\ngamefakt\nfaktglaublich'
|
2015-08-15 15:42:49 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
description = "Sendet ein zufälliges Bild",
|
2016-03-27 16:03:31 +02:00
|
|
|
usage = {"/rpic [Thema]","Themen:","anime","mlp","faktillon","faktastisch","gamefakt","faktglaublich"},
|
2015-08-15 15:42:49 +02:00
|
|
|
patterns = {"^/rpic (.*)$"},
|
|
|
|
run = run
|
|
|
|
}
|
|
|
|
end
|