mv append screen-name to transform
This commit is contained in:
parent
99014a1239
commit
64fa3120eb
4 changed files with 10 additions and 11 deletions
|
@ -60,9 +60,6 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
|
||||||
:visibility "unlisted"
|
:visibility "unlisted"
|
||||||
;; optional limit for the post length
|
;; optional limit for the post length
|
||||||
:max-post-length 300
|
:max-post-length 300
|
||||||
;; optional flag specifying wether the name of the account
|
|
||||||
;; will be appended in the post, defaults to false
|
|
||||||
:append-screen-name? false
|
|
||||||
;; optionally try to resolve URLs in posts to skip URL shorteners
|
;; optionally try to resolve URLs in posts to skip URL shorteners
|
||||||
;; defaults to false
|
;; defaults to false
|
||||||
:resolve-urls? true
|
:resolve-urls? true
|
||||||
|
@ -82,6 +79,9 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
|
||||||
;; accounts you wish to mirror
|
;; accounts you wish to mirror
|
||||||
:accounts ["arstechnica" "WIRED"]}
|
:accounts ["arstechnica" "WIRED"]}
|
||||||
:target {:type :mastodon-target
|
:target {:type :mastodon-target
|
||||||
|
;; optional flag specifying wether the name of the account
|
||||||
|
;; will be appended in the post, defaults to false
|
||||||
|
:append-screen-name? false
|
||||||
;; optional signature for posts
|
;; optional signature for posts
|
||||||
:signature "#newsbot"}}]
|
:signature "#newsbot"}}]
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,13 @@
|
||||||
(s/def ::content-filters (s/* ::content-filter))
|
(s/def ::content-filters (s/* ::content-filter))
|
||||||
(s/def ::keyword-filters (s/* ::keyword-filter))
|
(s/def ::keyword-filters (s/* ::keyword-filter))
|
||||||
(def mastodon-auth? (s/keys :req-un [::account-id ::access_token ::api_url]))
|
(def mastodon-auth? (s/keys :req-un [::account-id ::access_token ::api_url]))
|
||||||
(def mastodon-target? (s/keys :req-un [
|
(def mastodon-target? (s/keys :opt-un [
|
||||||
;::content-filters ::keyword-filters
|
;::content-filters ::keyword-filters
|
||||||
;::max-post-length
|
;::max-post-length
|
||||||
::signature
|
::signature
|
||||||
;::visibility
|
;::visibility
|
||||||
;::append-screen-name? ::sensitive? ::resolve-urls?
|
::append-screen-name?
|
||||||
|
;::sensitive? ::resolve-urls?
|
||||||
;::nitter-urls? ::replacements
|
;::nitter-urls? ::replacements
|
||||||
]))
|
]))
|
||||||
(def mastodon-config? (s/merge mastodon-auth? mastodon-target?))
|
(def mastodon-config? (s/merge mastodon-auth? mastodon-target?))
|
||||||
|
@ -48,10 +49,6 @@
|
||||||
[mastodon-config mastodon-config?]
|
[mastodon-config mastodon-config?]
|
||||||
(mapv re-pattern (:keyword-filters mastodon-config)))
|
(mapv re-pattern (:keyword-filters mastodon-config)))
|
||||||
|
|
||||||
(defn-spec append-screen-name? ::append-screen-name?
|
|
||||||
[mastodon-config mastodon-config?]
|
|
||||||
(boolean (:append-screen-name? mastodon-config)))
|
|
||||||
|
|
||||||
(defn-spec max-post-length ::max-post-length
|
(defn-spec max-post-length ::max-post-length
|
||||||
[mastodon-config mastodon-config?]
|
[mastodon-config mastodon-config?]
|
||||||
(:max-post-length mastodon-config))
|
(:max-post-length mastodon-config))
|
||||||
|
|
|
@ -47,15 +47,16 @@
|
||||||
|
|
||||||
:else text))
|
:else text))
|
||||||
|
|
||||||
|
; TODO: move this to mastodon-api - seems to belong strongly to mastodon
|
||||||
(defn-spec intermediate-to-mastodon mastodon-output?
|
(defn-spec intermediate-to-mastodon mastodon-output?
|
||||||
[mastodon-auth masto/mastodon-auth?
|
[mastodon-auth masto/mastodon-auth?
|
||||||
target masto/mastodon-target?
|
target masto/mastodon-target?
|
||||||
input input?]
|
input input?]
|
||||||
(let [{:keys [created-at text media-links screen_name untrimmed-text]} input
|
(let [{:keys [created-at text media-links screen_name untrimmed-text]} input
|
||||||
{:keys [signature]} target
|
{:keys [signature append-screen-name?]} target
|
||||||
untrimmed (if (some? untrimmed-text)
|
untrimmed (if (some? untrimmed-text)
|
||||||
(str " " untrimmed-text) "")
|
(str " " untrimmed-text) "")
|
||||||
sname (if (masto/append-screen-name? mastodon-auth)
|
sname (if (some? append-screen-name?)
|
||||||
(str "\n#" screen_name) "")
|
(str "\n#" screen_name) "")
|
||||||
signature_text (if (some? signature)
|
signature_text (if (some? signature)
|
||||||
(str "\n" signature)
|
(str "\n" signature)
|
||||||
|
|
|
@ -14,4 +14,5 @@
|
||||||
:include-rts? true
|
:include-rts? true
|
||||||
:accounts ["an-twitter-account"]}
|
:accounts ["an-twitter-account"]}
|
||||||
:target {:type :mastodon-target
|
:target {:type :mastodon-target
|
||||||
|
:append-screen-name? true
|
||||||
:signature "my-bot"}}])))
|
:signature "my-bot"}}])))
|
||||||
|
|
Reference in a new issue