diff --git a/README.md b/README.md index ff2dbec..7dae171 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,10 @@ If you get a [permission failure](https://github.com/anmonteiro/lumo/issues/206) :resolve-urls? true ;; optional content filter regexes ;; any posts matching the regexes will be filtered out - :content-filters [".*bannedsite.*"]}} + :content-filters [".*bannedsite.*"] + ;; optional keyword filter regexes + ;; any posts not matching the regexes will be filtered out + :keyword-filters [".*clojure.*"]}} ``` * the bot looks for `config.edn` at its relative path by default, an alternative location can be specified either using the `MASTODON_BOT_CONFIG` environment variable or passing the path to config as an argument diff --git a/mastodon-bot.cljs b/mastodon-bot.cljs index 18eefdd..372797f 100755 --- a/mastodon-bot.cljs +++ b/mastodon-bot.cljs @@ -31,12 +31,17 @@ (def content-filter-regexes (mapv re-pattern (:content-filters mastodon-config))) +(def keyword-filter-regexes (mapv re-pattern (:keyword-filters mastodon-config))) + (def append-screen-name? (boolean (:append-screen-name? mastodon-config))) (def max-post-length (:max-post-length mastodon-config)) (defn blocked-content? [text] - (boolean (some #(re-find % text) content-filter-regexes))) + (boolean + (or (some #(re-find % text) content-filter-regexes) + (when (not-empty keyword-filter-regexes) + (empty? (some #(re-find % text) keyword-filter-regexes)))))) (defn js->edn [data] (js->clj data :keywordize-keys true))