diff --git a/bot/bot.lua b/bot/bot.lua index da84033..60d72d6 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -68,7 +68,7 @@ -- print("Trying", text, "against", pattern) matches = { string.match(text, pattern) } if matches[1] then - print(" matches!!!!!") + print(" matches",pattern) result = desc.run(msg, matches) print(" sending", result) if (result) then diff --git a/plugins/rae.lua b/plugins/rae.lua index d187ade..05f1ccf 100644 --- a/plugins/rae.lua +++ b/plugins/rae.lua @@ -2,7 +2,8 @@ function getDulcinea( text ) -- Powered by https://github.com/javierhonduco/dulcinea local api = "http://dulcinea.herokuapp.com/api/?query=" - b = http.request(api..text) + local query_url = api..text + b = http.request(query_url) dulcinea = json:decode(b) if dulcinea.status == "error" then return "Error: " .. dulcinea.message @@ -12,9 +13,11 @@ function getDulcinea( text ) b = http.request(api..text) dulcinea = json:decode(b) end - vardump(dulcinea) local text = "" local responses = #dulcinea.response + if responses == 0 then + return "Error: 404 word not found" + end if (responses > 5) then responses = 5 end @@ -29,8 +32,8 @@ function getDulcinea( text ) text = text .. meaning .. "\n\n" end end + print (text) return text - end function run(msg, matches)