add follow command
parent
fe02b9e6af
commit
5a6f6f16f1
|
@ -0,0 +1,30 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/mattn/go-mastodon"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cmdFollow(c *cli.Context) error {
|
||||||
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
||||||
|
if !c.Args().Present() {
|
||||||
|
return errors.New("arguments required")
|
||||||
|
}
|
||||||
|
for i := 0; i < c.NArg(); i++ {
|
||||||
|
account, err := client.AccountsSearch(context.Background(), c.Args().Get(i), 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(account) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_, err = client.AccountFollow(context.Background(), account[0].ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -222,6 +222,11 @@ func makeApp() *cli.App {
|
||||||
Usage: "show followers",
|
Usage: "show followers",
|
||||||
Action: cmdFollowers,
|
Action: cmdFollowers,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "follow",
|
||||||
|
Usage: "follow account",
|
||||||
|
Action: cmdFollow,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "upload",
|
Name: "upload",
|
||||||
Usage: "upload file",
|
Usage: "upload file",
|
||||||
|
|
Loading…
Reference in New Issue