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

32 lines
1.3 KiB
Text
Raw Normal View History

#!/usr/bin/env lumo
(ns mastodon-bot.main
(:require
2020-02-27 22:12:07 +00:00
[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)]
2020-02-27 22:12:07 +00:00
(let [parser (core/rss-parser)]
(doseq [feed feeds]
(core/parse-feed last-post-time parser feed)))))))