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

View file

@ -11,13 +11,3 @@ func postToot(toot string, vis string) (*mastodon.Status, error) {
status, err := c.PostStatus(ctx, &conToot) status, err := c.PostStatus(ctx, &conToot)
return status, err 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
}