mastodon-group-bot/cleaning.go

41 lines
685 B
Go
Raw Permalink Normal View History

2022-09-08 12:26:25 +00:00
package main
import (
"sync"
"time"
"github.com/mattn/go-mastodon"
)
var (
wg sync.WaitGroup
)
// Delete notices
func DeleteNotices() {
wg.Done()
2022-09-08 18:28:32 +00:00
LoggerInit()
2022-09-08 12:26:25 +00:00
for {
2022-09-09 05:44:09 +00:00
time.Sleep(time.Duration(Conf.Del_notices_interval) * time.Minute)
2022-09-08 12:26:25 +00:00
statuses, err := c.GetAccountStatuses(ctx, my_account.ID, &mastodon.Pagination{Limit: 60})
if err != nil {
ErrorLogger.Println("Get account statuses")
}
2022-09-08 15:00:27 +00:00
if len(statuses) > 0 {
for i := range statuses {
if statuses[i].Visibility == "direct" {
c.DeleteStatus(ctx, statuses[i].ID)
}
2022-09-08 12:26:25 +00:00
}
2022-09-08 15:00:27 +00:00
InfoLogger.Println("Cleaning notices")
2022-09-08 12:26:25 +00:00
2022-09-08 15:00:27 +00:00
reset_notice_counter()
InfoLogger.Println("Reset notice counter")
}
2022-09-08 12:26:25 +00:00
}
}