Merge pull request #37 from raboof/replacements

Allow configuring 'replacements'
master
Dmitri Sotnikov 4 years ago committed by GitHub
commit e7daeab93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -131,10 +131,15 @@
(exit-with-error error)
(callback response)))))
(defn perform-replacements [post]
(assoc post :text (reduce-kv string/replace (:text post) (:replacements mastodon-config)))
)
(defn post-items [last-post-time items]
(doseq [{:keys [text media-links]} (->> items
(remove #(blocked-content? (:text %)))
(filter #(> (:created-at %) last-post-time)))]
(filter #(> (:created-at %) last-post-time))
(map perform-replacements))]
(if media-links
(post-status-with-images text media-links)
(when-not (:media-only? mastodon-config)

@ -26,6 +26,12 @@
(:text (core/parse-tweet (readfile "testdata/twitter/normal-tweet.edn")))
)))
(deftest test-replacements
(is (=
"💠 Check out what has been going on during March in the world of @ReproBuilds! 💠 https://t.co/k6NsSO115z @opensuse@fosstodon.org @conservancy@mastodon.technology @PrototypeFund@mastodon.social @debian@fosstodon.org "
(:text (core/perform-replacements (core/parse-tweet (readfile "testdata/twitter/tweet-mentions.edn"))))
)))
(cljs.test/run-tests)
; Don't run core's -main when testing

@ -51,5 +51,19 @@
;; optional keyword filter regexes
;; any posts not matching the regexes will be filtered out
:keyword-filters [".*clojure.*"]
;; optional replacements
:replacements {"@openSUSE " "@opensuse@fosstodon.org ",
"@archlinux " "",
"@lolamby " "",
"@conservancy " "@conservancy@mastodon.technology ",
"@prototypefund " "@PrototypeFund@mastodon.social ",
"@coreboot_org " "",
"@OpenTechFund " "",
"@OpenWrtSummit " "",
"@OpenMirage " "",
"@debian " "@debian@fosstodon.org ",
"@nixos_org " "",
"@lwnnet " "",
"@guixhpc" ""}
;; Replace Twitter links by Nitter
:nitter-urls? false}}

File diff suppressed because one or more lines are too long