feat: add content filtering functionality
- Introduce kikifilter package with IsWordsInText() function for word filtering - Add FiltredWorlds configuration option to KikiSettings - Integrate filtering into service to prevent posting filtered content - Update Dockerfile and Makefile to include filter package - Add example configuration with filtered words
This commit is contained in:
parent
95c95031d8
commit
3b0b688843
7 changed files with 32 additions and 14 deletions
|
|
@ -8,13 +8,16 @@ replace kiki/stacker => ../stacker
|
|||
|
||||
replace kiki/tooter => ../tooter
|
||||
|
||||
replace kiki/file_watcher => ../file_watcher/
|
||||
replace kiki/file_watcher => ../file_watcher
|
||||
|
||||
replace kiki/kikifilter => ../filter
|
||||
|
||||
require (
|
||||
github.com/mattn/go-mastodon v0.0.9
|
||||
github.com/urfave/cli/v3 v3.2.0
|
||||
kiki/config v0.0.0-00010101000000-000000000000
|
||||
kiki/file_watcher v0.0.0-00010101000000-000000000000
|
||||
kiki/kikifilter v0.0.0-00010101000000-000000000000
|
||||
kiki/stacker v0.0.0-00010101000000-000000000000
|
||||
kiki/tooter v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -11,6 +12,7 @@ import (
|
|||
|
||||
"kiki/config"
|
||||
"kiki/file_watcher"
|
||||
"kiki/kikifilter"
|
||||
"kiki/stacker"
|
||||
"kiki/tooter"
|
||||
|
||||
|
|
@ -56,6 +58,7 @@ func main() {
|
|||
log.Println(err)
|
||||
}
|
||||
kikiConfig := config.GetKikiConfig(confFile)
|
||||
fmt.Println(kikiConfig.FiltredWorlds)
|
||||
|
||||
lastFileMod, err := file_watcher.GetFileModTime(confFile)
|
||||
log.Println(lastFileMod)
|
||||
|
|
@ -88,15 +91,18 @@ func main() {
|
|||
}
|
||||
|
||||
if !inStack {
|
||||
|
||||
log.Println(post.Description)
|
||||
|
||||
toot, err := tooter.CreateToot(*mastoClient, post, rssUrl.Sensitive, rssUrl.Visibility)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
if !kikifilter.IsWordsInText(post.Description, kikiConfig.FiltredWorlds) {
|
||||
|
||||
toot, err := tooter.CreateToot(*mastoClient, post, rssUrl.Sensitive, rssUrl.Visibility)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
tooter.CreatePost(*mastoClient, toot)
|
||||
}
|
||||
|
||||
tooter.CreatePost(*mastoClient, toot)
|
||||
|
||||
stacker.SetToRedis(rdb, post.GUID, post.Description)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue