Added Google API/CSE key vars to config, minor changes to gImages.lua
This commit is contained in:
parent
6cc821f7c7
commit
f89c3fae5e
@ -1,5 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
bot_api_key = '',
|
bot_api_key = '',
|
||||||
|
google_api_key = '',
|
||||||
|
google_cse_key = '',
|
||||||
lastfm_api_key = '',
|
lastfm_api_key = '',
|
||||||
owm_api_key = '',
|
owm_api_key = '',
|
||||||
biblia_api_key = '',
|
biblia_api_key = '',
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
-- You need a Google API key and a Google Custom Search Engine set up to use this, in config.google_api_key and config.google_cse_key, respectively.
|
||||||
|
-- You must also sign up for the CSE in the Google Developer Concsole, and enable image results.
|
||||||
|
|
||||||
|
if not config.google_api_key then
|
||||||
|
print('Missing config value: google_api_key.')
|
||||||
|
print('gImages.lua will not be enabled.')
|
||||||
|
return
|
||||||
|
elseif not config.google_cse_key then
|
||||||
|
print('Missing config value: google_cse_key.')
|
||||||
|
print('gImages.lua will not be enabled.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local doc = [[
|
local doc = [[
|
||||||
/image <query>
|
/image <query>
|
||||||
Returns a randomized top result from Google Images. Safe search is enabled by default; use "/insfw" to disable it. NSFW results will not display an image preview.
|
Returns a randomized top result from Google Images. Safe search is enabled by default; use "/insfw" to disable it. NSFW results will not display an image preview.
|
||||||
@ -20,9 +33,7 @@ local action = function(msg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local url = 'https://www.googleapis.com/customsearch/v1?&searchType=image&imgSize=xlarge&alt=json&num=8&start=1'
|
local url = 'https://www.googleapis.com/customsearch/v1?&searchType=image&imgSize=xlarge&alt=json&num=8&start=1&key=' .. config.google_api_key .. '&cx=' .. config.google_cse_key
|
||||||
url = url .. '&key=0000000' -- KEY Get https://console.developers.google.com/apis/credentials
|
|
||||||
url = url .. '&cx=ABCD:000' -- CX Get https://cse.google.com/cse
|
|
||||||
|
|
||||||
if not string.match(msg.text, '^/i[mage]*nsfw') then
|
if not string.match(msg.text, '^/i[mage]*nsfw') then
|
||||||
url = url .. '&safe=high'
|
url = url .. '&safe=high'
|
||||||
|
Reference in New Issue
Block a user