!butts command 🍑 and indentation in boobs.lua
This commit is contained in:
parent
f831cae647
commit
9c2582f627
@ -1,29 +1,55 @@
|
|||||||
|
do
|
||||||
|
|
||||||
function getBoobs()
|
function getRandomButts(attempt)
|
||||||
|
attempt = attempt or 0;
|
||||||
|
attempt = attempt + 1
|
||||||
|
|
||||||
local rand = math.random(1, 8315)
|
local res,status = http.request("http://api.obutts.ru/noise/1")
|
||||||
local res,status = http.request("http://api.oboobs.ru/boobs/get/"..rand)
|
|
||||||
|
|
||||||
if status ~= 200 then return nil end
|
if status ~= 200 then return nil end
|
||||||
|
local data = json:decode(res)[1]
|
||||||
local data = json:decode(res)
|
|
||||||
|
|
||||||
-- The OpenBoobs API sometimes returns an empty array
|
-- The OpenBoobs API sometimes returns an empty array
|
||||||
if not data[1] then
|
if not data and attempt < 10 then
|
||||||
print 'Cannot get that boobs, trying another ones...'
|
print('Cannot get that boobs, trying another ones...')
|
||||||
return getBoobs()
|
return getRandomBoobs(attempt)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 'http://media.oboobs.ru/' .. data[1].preview
|
return 'http://media.obutts.ru/' .. data.preview
|
||||||
|
end
|
||||||
|
|
||||||
|
function getRandomBoobs(attempt)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
function run(msg, matches)
|
function run(msg, matches)
|
||||||
|
local url = nil
|
||||||
|
|
||||||
local boobs = getBoobs()
|
if matches[1] == "^!boobs" then
|
||||||
|
url = getRandomBoobs()
|
||||||
|
end
|
||||||
|
|
||||||
if boobs ~= nil then
|
if matches[1] == "!buts" then
|
||||||
file = download_to_file(boobs)
|
url = getRandomButts()
|
||||||
send_photo(get_receiver(msg), file, ok_cb, false)
|
end
|
||||||
|
|
||||||
|
if url ~= nil then
|
||||||
|
local receiver = get_receiver(msg)
|
||||||
|
send_photo_from_url(receiver, url)
|
||||||
else
|
else
|
||||||
return 'Error getting boobs for you, please try again later.'
|
return 'Error getting boobs for you, please try again later.'
|
||||||
end
|
end
|
||||||
@ -33,7 +59,10 @@ return {
|
|||||||
description = "Gets a random boobs pic",
|
description = "Gets a random boobs pic",
|
||||||
usage = "!boobs",
|
usage = "!boobs",
|
||||||
patterns = {
|
patterns = {
|
||||||
"^!boobs$"
|
"^!boobs",
|
||||||
|
"^!buts"
|
||||||
},
|
},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user