Skip to content

Commit

Permalink
honor #nobot tag and exclude users with this (and variations) in thei…
Browse files Browse the repository at this point in the history
…r Bio
  • Loading branch information
looprock committed Jan 16, 2023
1 parent 7562cc1 commit c2bdbd1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fedifeeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c2bdbd1

Please sign in to comment.