From 0341224158841277fdce421af2ef919a7a990172 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Sun, 6 Sep 2020 10:23:45 +0200 Subject: [PATCH] Update names and filter with url stories --- project.clj | 2 +- src/isahn/core.clj | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index 50e04a6..23c6da9 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject isahn "1.0.0" +(defproject isahn "1.0.1" :description "ISAHN check news stories for Hacker News" :url "http://example.com/FIXME" :micense {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" diff --git a/src/isahn/core.clj b/src/isahn/core.clj index 7db62fd..4b8d6fc 100644 --- a/src/isahn/core.clj +++ b/src/isahn/core.clj @@ -65,6 +65,11 @@ ;; Filter with score min_score (filter #(> (get-in % ["score"]) min_score) stories_without_histories))) +(defn filter_with_url + "Filter by removing stories that do not have the URL property" + [stories] + (filter (fn [story] (contains? story :url))) stories) + (defn send_stories_telegram "Send stories by Telegram Channel" [stories] @@ -74,14 +79,22 @@ :content-type :json :accept :json}))) -(defn check_stories +(defn stories_top + "Get all Top Stories with all data" + [] + (->> url_all_stories + (get_all_stories) + (filter_stories) + (filter_with_url))) + +(defn send_new_alert "Check news stories and send message to Telegram" [] - (let [stories_top (filter_stories (get_all_stories url_all_stories))] + (let [stories_top (stories_top)] (add_history stories_top) (send_stories_telegram stories_top))) (defn -main "Main execution" [] - (check_stories)) + (send_new_alert))