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/plugins/boobs.lua

72 lines
1.5 KiB
Lua
Raw Normal View History

do
2015-03-06 02:30:44 +01:00
function getRandomButts(attempt)
2015-03-08 22:11:00 +01:00
attempt = attempt or 0
attempt = attempt + 1
2015-03-06 02:30:44 +01:00
local res,status = http.request("http://api.obutts.ru/noise/1")
2015-03-06 02:30:44 +01:00
if status ~= 200 then return nil end
local data = json:decode(res)[1]
2015-03-06 02:30:44 +01:00
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
2015-03-08 22:11:00 +01:00
print('Cannot get that butts, trying another ones...')
return getRandomButts(attempt)
end
2015-03-06 02:30:44 +01:00
return 'http://media.obutts.ru/' .. data.preview
end
function getRandomBoobs(attempt)
2015-03-08 22:11:00 +01:00
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.oboobs.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that boobs, trying another ones...')
return getRandomBoobs(attempt)
end
return 'http://media.oboobs.ru/' .. data.preview
2015-03-06 02:30:44 +01:00
end
function run(msg, matches)
local url = nil
2015-03-08 22:11:00 +01:00
if matches[1] == "!boobs" then
url = getRandomBoobs()
end
2015-03-06 02:30:44 +01:00
2015-03-08 22:11:00 +01:00
if matches[1] == "!butts" then
url = getRandomButts()
end
2015-03-06 02:30:44 +01:00
if url ~= nil then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
2015-03-08 22:11:00 +01:00
return 'Error getting boobs/butts for you, please try again later.'
end
2015-03-06 02:30:44 +01:00
end
return {
2015-03-10 18:21:37 +01:00
description = "Gets a random boobs or butts pic",
usage = {
"!boobs",
"!butts"
},
patterns = {
2015-03-08 22:11:00 +01:00
"^!boobs$",
"^!butts$"
},
run = run
}
2015-03-10 18:21:37 +01:00
end