Loop for meanings and responses
This commit is contained in:
parent
86c8096631
commit
5d984b1dc1
23
bot/bot.lua
23
bot/bot.lua
@ -280,17 +280,30 @@ function getDulcinea( text )
|
|||||||
local api = "http://dulcinea.herokuapp.com/api/?query="
|
local api = "http://dulcinea.herokuapp.com/api/?query="
|
||||||
b = http.request(api..text)
|
b = http.request(api..text)
|
||||||
dulcinea = json:decode(b)
|
dulcinea = json:decode(b)
|
||||||
|
if dulcinea.status == "error" then
|
||||||
|
return "Error: " .. dulcinea.message
|
||||||
|
end
|
||||||
while dulcinea.type == "multiple" do
|
while dulcinea.type == "multiple" do
|
||||||
text = dulcinea.response[1].id
|
text = dulcinea.response[1].id
|
||||||
b = http.request(api..text)
|
b = http.request(api..text)
|
||||||
dulcinea = json:decode(b)
|
dulcinea = json:decode(b)
|
||||||
end
|
end
|
||||||
local text = ""
|
|
||||||
vardump(dulcinea)
|
vardump(dulcinea)
|
||||||
for i = 1, 5, 1 do
|
local text = ""
|
||||||
text = text .. dulcinea.response[i].word .."\n"
|
local responses = #dulcinea.response
|
||||||
text = text .. dulcinea.response[i].meanings[1].meaning .."\n"
|
if (responses > 5) then
|
||||||
text = text .. "\n"
|
responses = 5
|
||||||
|
end
|
||||||
|
for i = 1, responses, 1 do
|
||||||
|
text = text .. dulcinea.response[i].word .. "\n"
|
||||||
|
local meanings = #dulcinea.response[i].meanings
|
||||||
|
if (meanings > 5) then
|
||||||
|
meanings = 5
|
||||||
|
end
|
||||||
|
for j = 1, meanings, 1 do
|
||||||
|
local meaning = dulcinea.response[i].meanings[j].meaning
|
||||||
|
text = text .. meaning .. "\n\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user