added :keyword-filters flag

This commit is contained in:
Sotnikov, Dmitri 2018-10-09 11:59:50 -04:00
parent 8c004bd876
commit 45d7871058
2 changed files with 10 additions and 2 deletions

View file

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

View file

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