From d9be88305c02b2fe63e4b7d1db1d08c8fb334387 Mon Sep 17 00:00:00 2001 From: "dmitri.sotnikov@gmail.com" Date: Wed, 21 Nov 2018 01:05:47 -0500 Subject: [PATCH] updated readme, added :media-only? option --- README.md | 10 ++++++++-- mastodon-bot.cljs | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c510530..6cfe1ad 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ If you get a [permission failure](https://github.com/anmonteiro/lumo/issues/206) * create a Tumblr API key following the instructions [here](http://www.developerdrive.com/2014/05/how-to-get-started-with-the-tumblr-api-part-1/) * create a file called `config.edn` with the following contents: +**NOTE**: the bot checks the specified Mastodon account to see the timestamp of the last post, and only posts content +with later timestamps to avoid duplicate posts. On the first run the timestamp will default to current time. + ```clojure {;; add Twitter config to mirror Twitter accounts :twitter {:access-keys @@ -52,9 +55,12 @@ If you get a [permission failure](https://github.com/anmonteiro/lumo/issues/206) :mastodon {:access_token "XXXX" :api_url "https://botsin.space/api/v1/" ;; optional boolean to mark content as sensitive - :sensitive true + :sensitive? true + ;; optional boolean defaults to false + ;; only sources containing media will be posted when set to true + :media-only? true ;; optional visibility flag: direct, private, unlisted, public - ;; defaults to public + ;; defaults to public :visibility "unlisted" ;; optional limit for the post length :max-post-length 300 diff --git a/mastodon-bot.cljs b/mastodon-bot.cljs index 372797f..cd06b73 100755 --- a/mastodon-bot.cljs +++ b/mastodon-bot.cljs @@ -95,11 +95,11 @@ ([status-text] (post-status status-text nil)) ([status-text media-ids] - (let [{:keys [sensitive signature visibility]} mastodon-config] + (let [{:keys [sensitive? signature visibility]} mastodon-config] (.post mastodon-client "statuses" (clj->js (merge {:status (-> status-text resolve-urls set-signature)} (when media-ids {:media_ids media-ids}) - (when sensitive {:sensitive sensitive}) + (when sensitive? {:sensitive sensitive?}) (when visibility {:visibility visibility}))))))) (defn post-image [image-stream description callback] @@ -127,7 +127,8 @@ (filter #(> (:created-at %) last-post-time)))] (if media-links (post-status-with-images text media-links) - (post-status text)))) + (when-not (:media-only? mastodon-config) + (post-status text))))) (defn parse-tweet [{created-at :created_at text :full_text