2015-03-08 22:02:19 +01:00
|
|
|
do
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +01:00
|
|
|
function getRandomButts(attempt)
|
2015-03-08 22:11:00 +01:00
|
|
|
attempt = attempt or 0
|
2015-03-08 22:02:19 +01:00
|
|
|
attempt = attempt + 1
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +01:00
|
|
|
local res,status = http.request("http://api.obutts.ru/noise/1")
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +01:00
|
|
|
if status ~= 200 then return nil end
|
|
|
|
local data = json:decode(res)[1]
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +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)
|
2015-03-08 22:02:19 +01:00
|
|
|
end
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +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
|
2015-03-08 22:02:19 +01:00
|
|
|
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)
|
2015-03-08 22:02:19 +01:00
|
|
|
local url = nil
|
|
|
|
|
2015-03-08 22:11:00 +01:00
|
|
|
if matches[1] == "!boobs" then
|
2015-03-08 22:02:19 +01:00
|
|
|
url = getRandomBoobs()
|
|
|
|
end
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:11:00 +01:00
|
|
|
if matches[1] == "!butts" then
|
2015-03-08 22:02:19 +01:00
|
|
|
url = getRandomButts()
|
|
|
|
end
|
2015-03-06 02:30:44 +01:00
|
|
|
|
2015-03-08 22:02:19 +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.'
|
2015-03-08 22:02:19 +01:00
|
|
|
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"
|
|
|
|
},
|
2015-03-08 22:02:19 +01:00
|
|
|
patterns = {
|
2015-03-08 22:11:00 +01:00
|
|
|
"^!boobs$",
|
|
|
|
"^!butts$"
|
2015-03-08 22:02:19 +01:00
|
|
|
},
|
|
|
|
run = run
|
|
|
|
}
|
|
|
|
|
2015-03-10 18:21:37 +01:00
|
|
|
end
|