From 75daa0742555def4a05e37c4b79c95514c315b1a Mon Sep 17 00:00:00 2001 From: Tiago Danin Date: Fri, 22 Jan 2016 19:20:08 -0300 Subject: [PATCH] Solved "Connection error." --- plugins/apod.lua | 9 +++++++-- plugins/reddit.lua | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/apod.lua b/plugins/apod.lua index ec412be..1ed5d17 100755 --- a/plugins/apod.lua +++ b/plugins/apod.lua @@ -23,8 +23,13 @@ local action = function(msg) local url = 'https://api.nasa.gov/planetary/apod?api_key=' .. config.nasa_api_key if input then - url = url .. '&date=' .. URL.escape(input) - date = date .. input + if input:match('(%d+)%-(%d+)%-(%d+)$') then + url = url .. '&date=' .. URL.escape(input) + date = date .. input + else + sendMessage(msg.chat.id, doc, true, msg.message_id, true) + return + end else date = date .. os.date("%F") end diff --git a/plugins/reddit.lua b/plugins/reddit.lua index fefea3a..6051f55 100755 --- a/plugins/reddit.lua +++ b/plugins/reddit.lua @@ -26,10 +26,10 @@ local action = function(msg) local source if input then if input:match('^r/.') then - url = 'http://www.reddit.com/' .. input .. '/.json?limit=' .. limit + url = 'http://www.reddit.com/' .. URL.escape(input) .. '/.json?limit=' .. limit source = '*/r/' .. input:match('^r/(.+)') .. '*\n' else - url = 'http://www.reddit.com/search.json?q=' .. input .. '&limit=' .. limit + url = 'http://www.reddit.com/search.json?q=' .. URL.escape(input) .. '&limit=' .. limit source = '*reddit results for* _' .. input .. '_ *:*\n' end else