updated readme, added :media-only? option

This commit is contained in:
dmitri.sotnikov@gmail.com 2018-11-21 01:05:47 -05:00
parent 08c66f6c1f
commit d9be88305c
2 changed files with 12 additions and 5 deletions

View file

@ -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

View file

@ -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