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