From c2bdbd182e3874ba2817e61124d6d92465e068a1 Mon Sep 17 00:00:00 2001 From: Douglas Land Date: Mon, 16 Jan 2023 14:21:04 -0600 Subject: [PATCH] honor #nobot tag and exclude users with this (and variations) in their Bio --- fedifeeder.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fedifeeder.go b/fedifeeder.go index 0725fa4..0c71b28 100644 --- a/fedifeeder.go +++ b/fedifeeder.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "os" + "regexp" "strings" "time" @@ -252,6 +253,18 @@ func userToID(c *mastodon.Client, user string) (mastodon.ID, error) { return "NaN", errors.New(errMsg) } else { accountId := mID.Accounts[0].ID + // exclude people who have #nobot in their bio + noBot := mID.Accounts[0].Note + logger.Debug().Msg(noBot) + matched, err := regexp.Match("(?i)tags/nobot", []byte(noBot)) + if err != nil { + return "NaN", err + } + if matched { + errMsg := "#nobot set for user " + user + logger.Warn().Msg(errMsg) + return "NaN", errors.New(errMsg) + } logMsg := fmt.Sprintf("ADDING user: %s, id: %s\n", user, accountId) logger.Info().Msg(logMsg) return accountId, nil