check if infinite loop or go-mastodon is bad

This commit is contained in:
Andriy Cherniy 2024-01-05 21:53:38 +02:00
parent a8a9cf27ba
commit b3bf6d7b17

34
main.go
View file

@ -100,30 +100,28 @@ func main() {
ClientSecret: os.Getenv("MASTODON_CLIENT_SECRET"),
AccessToken: os.Getenv("MASTODON_ACCESS_TOKEN"),
})
_, err = masto_client.GetAccountCurrentUser(ctx)
masto_user, err := masto_client.GetAccountCurrentUser(ctx)
if err != nil {
log.Fatal(err)
}
var subscribers []*mastodon.Account
// var pg mastodon.Pagination
// log.Info("test")
// log.Debug("get followers list")
// for {
// fs, err := masto_client.GetAccountFollowers(context.Background(), masto_user.ID, &pg)
// if err != nil {
// log.Fatal(err)
// }
// subscribers = append(subscribers, fs...)
// log.Debug(pg)
// log.Debug(pg.MaxID)
// if pg.MaxID == "" {
// break
// }
// }
// log.Println(my_account)
var pg mastodon.Pagination
log.Info("test")
log.Debug("get followers list")
for {
fs, err := masto_client.GetAccountFollowers(context.Background(), masto_user.ID, &pg)
if err != nil {
log.Fatal(err)
}
subscribers = append(subscribers, fs...)
log.Debug(pg)
log.Debug(pg.MaxID)
if pg.MaxID == "" {
break
}
}
matrix_client, err := mautrix.NewClient(os.Getenv("MATRIX_HOMESERVER"), m_id.UserID(os.Getenv("MATRIX_USERNAME")), os.Getenv("MATRIX_ACCESS_TOKEN"))
matrix_client.Store = mautrix.NewAccountDataStore("ua.in.fediland.uabot", matrix_client)