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

41 lines
1.0 KiB
Lua

local moe = {}
function moe:init(config)
moe.triggers = {
"^/([Rr][Ii][Kk][Oo])$",
"^/([Yy][Aa][Gg][Yy][Uu][Uu])$"
}
moe.doc = [[*
]]..config.cmd_pat..[[riko*: Postet ein Bild von riko.moe
*]]..config.cmd_pat..[[yagyuu*: Postet ein Bild von yagyuu.moe
]]
end
moe.command = 'riko, /yagyuu'
function moe:get_url(site_url)
local res,code = http.request(site_url)
if code ~= 200 then return nil end
local photo_url = res:match("<img src%=\"(.-)\" alt")
local photo_url = site_url..'/'..photo_url
return photo_url
end
function moe:action(msg, config, matches)
if matches[1]:match('[Rr][Ii][Kk][Oo]') then
site_url = 'http://riko.moe'
elseif matches[1]:match('[Yy][Aa][Gg][Yy][Uu][Uu]') then
site_url = 'http://yagyuu.moe'
end
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local photo_url = moe:get_url(site_url)
if not photo_url then
utilities.send_reply(self, msg, config.errors.connection)
return
end
local file = download_to_file(photo_url)
utilities.send_photo(self, msg.chat.id, file)
end
return moe