This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/miku/plugins/yandere.lua
Andreas Bielawski 345e33dcb0 Portiere EINEN HAUFEN an Imageboard-Plugins, NSFW-Plugins, etc. Im Folgenden:
- boobs
- danbooru
- derpibooru(_nsfw)
- e621
- gifeye
- konachan(_nsfw)
- riko & yagyuu >> moe
- porndoge
- pornhub_gif
- pr0gramm
- random_pic(_nsfw)
- rule34
- sankakucomplex
- yandere
- z0r
2016-08-18 17:23:55 +02:00

44 lines
1.2 KiB
Lua

local yandere = {}
function yandere:init(config)
yandere.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('yan', true):t('yandere', true).table
yandere.doc = [[*
]]..config.cmd_pat..[[yan* _<Tags>_: Sucht auf Yandere mit diesen Tags]]
end
yandere.command = 'yan <Tags>'
function yandere:get_post(tag)
local BASE_URL = 'https://yande.re'
local url = BASE_URL..'/post.json?tags='..tag
local b,c = https.request(url)
print(url)
if c ~= 200 then return nil end
local yan = json.decode(b)
if not yan[1] then return nil end
local i = math.random(#yan)
local link_image = yan[i].file_url
return link_image
end
function yandere:action(msg, config)
local input = utilities.input_from_msg(msg)
if not input then
utilities.send_reply(self, msg, yandere.doc, true)
return
end
local tag = string.gsub(input, " ", '_' )
local url = yandere:get_post(tag)
if not url then
utilities.send_reply(self, msg, config.errors.results)
return
end
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local file = download_to_file(url)
utilities.send_photo(self, msg.chat.id, file)
utilities.send_reply(self, msg, url)
end
return yandere