Fix, wenn keine Bilder gefunden

This commit is contained in:
Andreas Bielawski 2016-07-05 20:32:35 +02:00
parent b22f30d2cf
commit 14215f52dd

View File

@ -110,8 +110,8 @@ function gImages:callback(callback, msg, self, config, input)
end end
function gImages:get_image(input) function gImages:get_image(input)
local apikey = cred_data.google_apikey_2 -- 100 requests is RIDICULOUS, Google! local apikey = cred_data.google_apikey -- 100 requests is RIDICULOUS, Google!
local cseid = cred_data.google_cse_id_2 local cseid = cred_data.google_cse_id
local BASE_URL = 'https://www.googleapis.com/customsearch/v1' local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&safe=high'..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))' local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&safe=high'..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))'
local jstr, res = HTTPS.request(url) local jstr, res = HTTPS.request(url)
@ -173,7 +173,7 @@ function gImages:action(msg, config, matches)
if results == 403 then if results == 403 then
utilities.send_reply(self, msg, config.errors.quotaexceeded, true) utilities.send_reply(self, msg, config.errors.quotaexceeded, true)
return return
elseif not results then elseif not results or results == 'NORESULTS' then
utilities.send_reply(self, msg, config.errors.results, true) utilities.send_reply(self, msg, config.errors.results, true)
return return
end end