mv media-only? & max-post-length to transform

This commit is contained in:
jem 2020-05-29 21:32:41 +02:00
parent 6ec1930a71
commit dd62eab56b
5 changed files with 16 additions and 12 deletions

View file

@ -50,11 +50,6 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
;; e.g: https://mastodon.social/web/accounts/294795
:account-id "XXXX"
:api_url "https://botsin.space/api/v1/"
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length
:max-post-length 300
;; optionally try to resolve URLs in posts to skip URL shorteners
;; defaults to false
:resolve-urls? true
@ -82,6 +77,11 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
:visibility "unlisted"
;; optional boolean to mark content as sensitive
:sensitive? true
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length
:max-post-length 300
;; optional signature for posts
:signature "#newsbot"}}]
}

View file

@ -61,7 +61,7 @@
{:created-at (js/Date. (or isoDate pubDate))
:text (str (transform/trim-text
title
(masto/max-post-length (mastodon-auth config)))
(masto/max-post-length (:target (first (transform config)))))
"\n\n" (twitter/strip-utm link))})))))
(defn -main []

View file

@ -17,6 +17,7 @@
(s/def ::append-screen-name? boolean?)
(s/def ::signature string?)
(s/def ::sensitive? boolean?)
(s/def ::media-only? boolean?)
(s/def ::resolve-urls? boolean?)
(s/def ::nitter-urls? boolean?)
(s/def ::visibility #{"direct" "private" "unlisted" "public"})
@ -31,11 +32,12 @@
(def mastodon-auth? (s/keys :req-un [::account-id ::access_token ::api_url]))
(def mastodon-target? (s/keys :opt-un [
;::content-filters ::keyword-filters
;::max-post-length
::max-post-length
::signature
::visibility
::append-screen-name?
::sensitive?
::media-only?
;::resolve-urls?
;::nitter-urls? ::replacements
]))
@ -51,8 +53,8 @@
(mapv re-pattern (:keyword-filters mastodon-config)))
(defn-spec max-post-length ::max-post-length
[mastodon-config mastodon-config?]
(:max-post-length mastodon-config))
[target mastodon-target?]
(:max-post-length target))
(defn-spec perform-replacements string?
[mastodon-config mastodon-config?
@ -163,7 +165,7 @@
(filter #(> (:created-at %) last-post-time)))]
(if media-links
(post-status-with-images mastodon-auth target text media-links)
(when-not (::media-only? mastodon-auth)
(when-not (:media-only? target)
(post-status mastodon-auth target text)))))
(defn-spec get-mastodon-timeline any?

View file

@ -61,7 +61,7 @@
signature_text (if (some? signature)
(str "\n" signature)
"")
trim-length (- (masto/max-post-length mastodon-auth)
trim-length (- (masto/max-post-length target)
(count untrimmed)
(count sname)
(count signature_text))]

View file

@ -15,6 +15,8 @@
:accounts ["an-twitter-account"]}
:target {:type :mastodon-target
:append-screen-name? true
:media-only? false
:max-post-length 500
:visibility "unlisted"
:sensitive? true
:signature "my-bot"}}])))