mirror of
https://git.phreedom.club/localhost_frssoft/mastodon-group-bot.git
synced 2024-12-26 02:59:48 +00:00
follow check fix
This commit is contained in:
parent
8b3296fedf
commit
6c718b73ae
16
bot.go
16
bot.go
@ -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
|
||||||
|
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)
|
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user