follow check fix

This commit is contained in:
fade 2022-09-22 22:10:13 -04:00
parent 8b3296fedf
commit 6c718b73ae
2 changed files with 6 additions and 20 deletions

16
bot.go
View file

@ -31,11 +31,6 @@ func RunBot() {
ErrorLogger.Println("Streaming")
}
followers, err := c.GetAccountFollowers(ctx, my_account.ID, &mastodon.Pagination{Limit: 60})
if err != nil {
ErrorLogger.Println("Fetch followers")
}
// Run bot
for {
notifEvent, ok := (<-events).(*mastodon.NotificationEvent)
@ -66,18 +61,19 @@ func RunBot() {
// Read message
if notif.Type == "mention" {
var account_id = []string{string(notif.Status.Account.ID)}
acct := notif.Status.Account.Acct
content := notif.Status.Content
tooturl := notif.Status.URL
if check_following(followers, acct) {
fmt.Println("True")
} else {
fmt.Println("False")
// Fetch relationship
relationship, err := c.GetAccountRelationships(ctx, account_id)
if err != nil {
ErrorLogger.Println("Fetch relationship")
}
// Follow check
if check_following(followers, acct) {
if relationship[0].FollowedBy {
if notif.Status.Visibility == "public" { // Reblog toot
if notif.Status.InReplyToID == nil { // Not boost replies
// Duplicate protection

View file

@ -11,13 +11,3 @@ func postToot(toot string, vis string) (*mastodon.Status, error) {
status, err := c.PostStatus(ctx, &conToot)
return status, err
}
// Check following
func check_following(followers []*mastodon.Account, acct string) bool {
for i := range followers {
if acct == string(followers[i].Acct) {
return true
}
}
return false
}