2017-04-16 15:27:54 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-17 04:10:29 +02:00
|
|
|
"context"
|
2017-04-16 15:27:54 +02:00
|
|
|
"fmt"
|
2017-05-04 17:18:17 +02:00
|
|
|
"time"
|
2017-04-16 15:27:54 +02:00
|
|
|
|
|
|
|
"github.com/mattn/go-mastodon"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func cmdFollowers(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
2017-04-19 16:32:23 +02:00
|
|
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
|
|
|
|
2017-04-17 04:10:29 +02:00
|
|
|
account, err := client.GetAccountCurrentUser(context.Background())
|
2017-04-16 15:27:54 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-04 17:18:17 +02:00
|
|
|
var followers []*mastodon.Account
|
2017-05-08 04:06:01 +02:00
|
|
|
var pg mastodon.Pagination
|
2017-05-04 17:18:17 +02:00
|
|
|
for {
|
2017-05-06 16:49:46 +02:00
|
|
|
fs, err := client.GetAccountFollowers(context.Background(), account.ID, &pg)
|
2017-05-04 17:18:17 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
followers = append(followers, fs...)
|
2017-10-25 03:22:39 +02:00
|
|
|
if pg.MaxID == "" {
|
2017-05-04 17:18:17 +02:00
|
|
|
break
|
|
|
|
}
|
2019-02-14 14:54:45 +01:00
|
|
|
pg.SinceID = ""
|
2019-08-08 06:35:37 +02:00
|
|
|
pg.MinID = ""
|
2017-05-04 17:18:17 +02:00
|
|
|
time.Sleep(10 * time.Second)
|
2017-04-16 15:27:54 +02:00
|
|
|
}
|
2017-04-19 16:32:23 +02:00
|
|
|
s := newScreen(config)
|
2017-04-16 15:27:54 +02:00
|
|
|
for _, follower := range followers {
|
2017-04-19 16:32:23 +02:00
|
|
|
fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, s.acct(follower.Acct))
|
2017-04-16 15:27:54 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|