diff --git a/src/joann-pupper-bot.cr b/src/joann-pupper-bot.cr index 2e0bcd1..88ea8c5 100644 --- a/src/joann-pupper-bot.cr +++ b/src/joann-pupper-bot.cr @@ -38,7 +38,7 @@ end spawn do loop do - time = Time.local + time = Time.now url_tuple = get_reddit_post(subreddit, completed) if (active_hours.includes? time.hour) if url_tuple url, title = url_tuple diff --git a/src/joann-pupper-bot/reddit.cr b/src/joann-pupper-bot/reddit.cr index b31ea6f..5141fc9 100644 --- a/src/joann-pupper-bot/reddit.cr +++ b/src/joann-pupper-bot/reddit.cr @@ -21,7 +21,7 @@ class RedditResponse children: Array(RedditWrapper(RedditChild))) def self.from_subreddits(subreddits : Array(String)) - request_url = URI.new scheme: "https", host: "www.reddit.com", path: "/r/hot.json", query: "limit=30" + request_url = URI.new scheme: "https", host: "www.reddit.com", path: "/r/#{subreddits.join "+"}/hot.json", query: "limit=30" response = HTTP::Client.get(request_url, headers: HTTP::Headers { "User-agent" => "Joann-Pupper-Bot" }) @@ -30,7 +30,7 @@ class RedditResponse begin RedditWrapper(RedditResponse).from_json body - rescue + rescue e nil end end @@ -46,7 +46,7 @@ class RedditResponse end end -def filter_reddit_json(json, completed, extensions = ["png", "json"]) +def filter_reddit_json(json, completed, extensions = ["png", "jpeg"]) json.data.posts_matching do |post| extensions.any? { |it| post.url.ends_with? it } && !completed.includes? post.url end