This repository has been archived on 2023-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-bot/mastodon_bot/main.cljs
dmitri.sotnikov@gmail.com 72f85c1a51 clean up, updated docs
2020-02-27 17:12:07 -05:00

31 lines
1.3 KiB
Clojure

#!/usr/bin/env lumo
(ns mastodon-bot.main
(:require
[mastodon-bot.core :as core]))
(core/get-mastodon-timeline
(fn [timeline]
(let [last-post-time (-> timeline first :created_at (js/Date.))]
;;post from Twitter
(when-let [twitter-config (:twitter core/config)]
(let [{:keys [access-keys accounts include-replies? include-rts?]} twitter-config
client (core/twitter-client access-keys)]
(doseq [account accounts]
(.get client
"statuses/user_timeline"
#js {:screen_name account
:tweet_mode "extended"
:include_rts (boolean include-rts?)
:exclude_replies (not (boolean include-replies?))}
(core/post-tweets last-post-time)))))
;;post from Tumblr
(when-let [{:keys [access-keys accounts limit tumblr-oauth]} (:tumblr core/config)]
(doseq [account accounts]
(let [client (core/tumblr-client access-keys account)]
(.posts client #js {:limit (or limit 5)} (core/post-tumblrs last-post-time)))))
;;post from RSS
(when-let [feeds (some-> core/config :rss)]
(let [parser (core/rss-parser)]
(doseq [feed feeds]
(core/parse-feed last-post-time parser feed)))))))