Fix doseq stories

This commit is contained in:
Andros Fenollosa 2019-08-05 10:20:56 +02:00
parent 84831ea7bf
commit a7ffaf6cd8

View File

@ -72,23 +72,21 @@
(defn send_stories_telegram (defn send_stories_telegram
"Send stories by Telegram Channel" "Send stories by Telegram Channel"
[stories] [stories]
(if (not-empty stories) (doall (iterate #((client/post url_telegram_send {:body (json/generate-string {:chat_id (:chat env) (doseq [story stories] (client/post url_telegram_send {:body (json/generate-string {:chat_id (:chat env)
:text (str (get-in % ["title"]) ": " (get-in % ["url"])) :text (str (get-in story ["title"]) ": " (get-in story ["url"]))
:disable_notification true}) :disable_notification true})
:content-type :json :content-type :json
:accept :json})) stories)))) :accept :json})))
(defn check_stories (defn check_stories
"Check news stories and send message to Telegram" "Check news stories and send message to Telegram"
[] []
(let [stories_top (filter_stories (get_all_stories url_all_stories))] (let [stories_top (filter_stories (get_all_stories url_all_stories))]
(doall (add_history stories_top)) (add_history stories_top)
(doall (send_stories_telegram stories_top)))) (send_stories_telegram stories_top)))
(defn -main (defn -main
"Main execution" "Main execution"
[] []
;; Run first time ;; Run first time
(check_stories) (check_stories))
;; Run every :run_every_miliseconds
(set-interval check_stories (:run_every_miliseconds env)))