From 6c718b73ae520624b3a5f7df9bfaf5f5c3ee054b Mon Sep 17 00:00:00 2001 From: fade Date: Thu, 22 Sep 2022 22:10:13 -0400 Subject: [PATCH] follow check fix --- bot.go | 16 ++++++---------- utils.go | 10 ---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/bot.go b/bot.go index 5c819ae..8e444dd 100644 --- a/bot.go +++ b/bot.go @@ -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 diff --git a/utils.go b/utils.go index 7076586..11cdf4e 100644 --- a/utils.go +++ b/utils.go @@ -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 -}