45 lines
831 B
Go
45 lines
831 B
Go
package main
|
|
|
|
import (
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
"git.laidback.moe/shinyoukai/mikuru/mirai"
|
|
"go.yarn.social/client"
|
|
)
|
|
|
|
var unfollowCmd = &cobra.Command{
|
|
Use: "unfollow <NICK>",
|
|
Short: "Cease to track a feed",
|
|
Run: func(_ *cobra.Command, args []string) {
|
|
cli, err := client.NewClient(
|
|
client.WithURI(mirai.Config.Host),
|
|
client.WithToken(mirai.Config.Token),
|
|
)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if len(args) != 1 {
|
|
log.Fatal("Not enough arguments")
|
|
}
|
|
nick := args[0]
|
|
|
|
leave_alone(cli, nick)
|
|
if err != nil {
|
|
log.Fatalf("Could not unfollow %s\n", nick)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
mirai.ConfInit()
|
|
rootCmd.AddCommand(unfollowCmd)
|
|
}
|
|
|
|
func leave_alone(cli *client.Client, nick string) error {
|
|
err := cli.Unfollow(nick)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|