54 lines
1.4 KiB
Lua
54 lines
1.4 KiB
Lua
local rpic_nsfw = {}
|
|
|
|
function rpic_nsfw:init(config)
|
|
rpic_nsfw.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('nsfw', true).table
|
|
rpic_nsfw.doc = [[*
|
|
]]..config.cmd_pat..[[nsfw* _<Thema>_
|
|
*Themen:*
|
|
- gif
|
|
- rl
|
|
- shimakaze]]
|
|
end
|
|
|
|
rpic_nsfw.command = 'nsfw <Thema>'
|
|
|
|
function rpic_nsfw:get_random_image(dir)
|
|
files = scandir(dir)
|
|
if not files[1] then return ': Keine Dateien vorhanden!' end
|
|
file = files[math.random(#files)]
|
|
return file
|
|
end
|
|
|
|
function rpic_nsfw:action(msg, config)
|
|
local input = utilities.input_from_msg(msg)
|
|
if not input then
|
|
input = 'general'
|
|
end
|
|
|
|
local pics = {
|
|
["general"] = "../Festplatten/Dragoran/Mikubot/nsfw/",
|
|
["gif"] = "../Festplatten/Dragoran/Mikubot/nsfw/gifs/",
|
|
["rl"] = "../Festplatten/Dragoran/Mikubot/nsfw/rl/",
|
|
["shimakaze"] = "../Festplatten/Dragoran/Mikubot/nsfw/Shimakaze/"
|
|
}
|
|
|
|
if pics[input] then
|
|
local img = pics[input]..rpic_nsfw:get_random_image(pics[input])
|
|
print("Sende... "..img)
|
|
if string.ends(img, ".gif") or string.ends(img, ".mp4") then
|
|
utilities.send_document(msg.chat.id, img)
|
|
return
|
|
elseif string.ends(img, ".jpg") or string.ends(img, ".jpeg") or string.ends(img, ".png") then
|
|
utilities.send_photo(msg.chat.id, img)
|
|
return
|
|
else
|
|
utilities.send_reply(msg, 'Fehler: '..img)
|
|
return
|
|
end
|
|
else
|
|
utilities.send_reply(msg, '*Dieses Thema gibt es nicht!*'..rpic_nsfw.doc, true)
|
|
return
|
|
end
|
|
end
|
|
|
|
return rpic_nsfw |