clean up, updated docs

master
dmitri.sotnikov@gmail.com 4 years ago
parent 97f1df59be
commit 72f85c1a51

@ -6,7 +6,6 @@ the bot will post the timeline from the specified Twitter/Tumblr accounts and RS
1. install [Node.js](https://nodejs.org/en/)
2. run `npm install` to install Node modules
3. run `npm start` to, well, start
If you wish to run the script directly, you will need to have [Lumo](https://github.com/anmonteiro/lumo) available on the shell path. Lumo can be installed globally via NPM by running:
@ -87,10 +86,10 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
* the bot looks for `config.edn` at its relative path by default, an alternative location can be specified either using the `MASTODON_BOT_CONFIG` environment variable or passing the path to config as an argument
* run the bot: `./mastodon-bot.cljs`
* run the bot: `npm start`
* to poll at intervals setup a cron job such as:
*/30 * * * * mastodon-bot.cljs /path/to/config.edn > /dev/null 2>&1
*/30 * * * * npm start /path/to/config.edn > /dev/null 2>&1
## License

@ -8,6 +8,7 @@
["request" :as request]
["fs" :as fs]
["mastodon-api" :as mastodon]
["rss-parser" :as rss]
["tumblr" :as tumblr]
["twitter" :as twitter]))
@ -16,9 +17,12 @@
(js/process.exit 1))
(defn find-config []
(or (first *command-line-args*)
(-> js/process .-env .-MASTODON_BOT_CONFIG)
"config.edn"))
(let [config (or (first *command-line-args*)
(-> js/process .-env .-MASTODON_BOT_CONFIG)
"config.edn")]
(if (fs/existsSync config)
config
(exit-with-error (str "failed to read config: " config)))))
(def config (-> (find-config) (fs/readFileSync #js {:encoding "UTF-8"}) edn/read-string))
@ -193,3 +197,6 @@
(catch js/Error e
(exit-with-error
(str "failed to connect to Tumblr account " account ": " (.-message e))))))
(defn rss-parser []
(rss.))

@ -2,8 +2,7 @@
(ns mastodon-bot.main
(:require
[mastodon-bot.core :as core]
["rss-parser" :as rss]))
[mastodon-bot.core :as core]))
(core/get-mastodon-timeline
(fn [timeline]
@ -27,6 +26,6 @@
(.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 (rss.)]
(let [parser (core/rss-parser)]
(doseq [feed feeds]
(core/parse-feed last-post-time parser feed)))))))