Changes to apod.lua:
- Now uses demo key if key is not configured. - Removed newlines in doc. - Removed some unused code.
This commit is contained in:
parent
16b3d10762
commit
4f78323db7
@ -6,7 +6,7 @@ return {
|
|||||||
owm_api_key = '',
|
owm_api_key = '',
|
||||||
biblia_api_key = '',
|
biblia_api_key = '',
|
||||||
thecatapi_key = '',
|
thecatapi_key = '',
|
||||||
nasaapi_key = '',
|
nasa_api_key = '',
|
||||||
time_offset = 0,
|
time_offset = 0,
|
||||||
lang = 'en',
|
lang = 'en',
|
||||||
antisquig = false,
|
antisquig = false,
|
||||||
|
@ -1,20 +1,9 @@
|
|||||||
-- TODO:
|
|
||||||
-- inline bot stuff
|
|
||||||
|
|
||||||
if not config.nasaapi_key then
|
|
||||||
print('Missing config value: nasaapi_key.')
|
|
||||||
print('You can use the simple key DEMO_KEY, but it is very limited.')
|
|
||||||
print('apod.lua will not be enabled.')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local command = 'apod [query]'
|
local command = 'apod [query]'
|
||||||
local doc = [[```
|
local doc = [[```
|
||||||
/apod [query]
|
/apod [query]
|
||||||
Returns the Astronomy Picture of the Day.
|
Returns the Astronomy Picture of the Day.
|
||||||
|
If the query is a date, in the format YYYY-MM-DD, the APOD of that day is returned.
|
||||||
If the query is a date, in the format YYYY-MM-DD,
|
Source: nasa.gov
|
||||||
the APOD of that day is returned.
|
|
||||||
```]]
|
```]]
|
||||||
|
|
||||||
local triggers = {
|
local triggers = {
|
||||||
@ -23,19 +12,20 @@ local triggers = {
|
|||||||
|
|
||||||
local action = function(msg)
|
local action = function(msg)
|
||||||
|
|
||||||
local input = msg.text:input()
|
if not config.nasa_api_key then
|
||||||
local caption = ''
|
config.nasa_api_key = 'DEMO_KEY'
|
||||||
local date = '*'
|
end
|
||||||
--local date_url = ''
|
|
||||||
|
|
||||||
local url = 'https://api.nasa.gov/planetary/apod?api_key=' .. config.nasaapi_key
|
local input = msg.text:input()
|
||||||
|
local caption = ''
|
||||||
|
local date = '*'
|
||||||
|
|
||||||
|
local url = 'https://api.nasa.gov/planetary/apod?api_key=' .. config.nasa_api_key
|
||||||
|
|
||||||
if input then
|
if input then
|
||||||
url = url .. '&date=' .. URL.escape(input)
|
url = url .. '&date=' .. URL.escape(input)
|
||||||
-- date_url = string.sub(date,3,4) .. string.sub(date,6,7) .. string.sub(date,9,10)
|
|
||||||
date = date .. input
|
date = date .. input
|
||||||
else
|
else
|
||||||
-- date_url = os.date("%y%m%d")
|
|
||||||
date = date .. os.date("%Y-%m-%d")
|
date = date .. os.date("%Y-%m-%d")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,14 +45,15 @@ local action = function(msg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--local weburl = 'http://apod.nasa.gov/apod/ap' .. date_url .. '.html'
|
--local weburl = 'http://apod.nasa.gov/apod/ap' .. date_url .. '.html'
|
||||||
--caption = date .. '[' .. jdat.title .. '](' .. weburl .. ')\n'
|
--output = date .. '[' .. jdat.title .. '](' .. weburl .. ')\n'
|
||||||
caption = date .. '[' .. jdat.title .. '](' .. jdat.url .. ')\n'
|
output = date .. '[' .. jdat.title .. '](' .. jdat.url .. ')\n'
|
||||||
|
|
||||||
if jdat.copyright then
|
if jdat.copyright then
|
||||||
caption = caption .. 'Copyright: ' .. jdat.copyright
|
output = output .. 'Copyright: ' .. jdat.copyright
|
||||||
end
|
end
|
||||||
|
|
||||||
sendMessage(msg.chat.id, caption, false, nil, true)
|
sendMessage(msg.chat.id, output, false, nil, true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user