mirror of
https://gitea.phreedom.club/localhost_frssoft/mastodon-group-bot.git
synced 2024-12-22 09:13:33 +02:00
follow check fix
This commit is contained in:
parent
8b3296fedf
commit
6c718b73ae
2 changed files with 6 additions and 20 deletions
16
bot.go
16
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
|
||||
|
|
10
utils.go
10
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue