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/sankakucomplex.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

52 lines
1.7 KiB
Lua

local sankakucomplex = {}
function sankakucomplex:init(config)
sankakucomplex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sc', true):t('sankaku', true).table
sankakucomplex.doc = [[*
]]..config.cmd_pat..[[sc* _<Tags>_: Sucht auf Sankaku mit diesen Tags]]
end
sankakucomplex.command = 'sc <Tags>'
function sankakucomplex:get_post(tag)
local user = cred_data.sankaku_username
local password = cred_data.sankaku_pw --Your SHA1 hashed password. (echo "choujin-steiner--YOUR-PASSWORD--" | sha1sum)
local BASE_URL = 'https://chan.sankakucomplex.com'
local url = BASE_URL..'/post/index.json?login='..user..'&password_hash='..password..'&tags='..tag
local b,c = https.request(url)
if c ~= 200 then return nil end
local complex = json.decode(b)
if not complex[1] then return nil end
local i = math.random(#complex)
local link_image = 'https:'..complex[i].file_url
return link_image
end
function sankakucomplex:action(msg, config)
local input = utilities.input_from_msg(msg)
if not input then
utilities.send_reply(self, msg, sankakucomplex.doc, true)
return
end
local tag = string.gsub(input, " ", '_' )
local tag = string.gsub(tag, ":", '%%3A' )
local url = sankakucomplex: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)
if string.match(url, ".gif") or string.match(url, ".zip") or string.match(url, ".webm") or string.match(url, ".mp4") then
utilities.send_document(self, msg.chat.id, file)
else
utilities.send_photo(self, msg.chat.id, file)
end
utilities.send_reply(self, msg, url)
end
return sankakucomplex