argos/unfollowAll.go
unfollowAll.goRaw
1package main
2
3import (
4 "bufio"
5 "fmt"
6 "os"
7 "strconv"
8 "strings"
9
10 "github.com/dghubble/go-twitter/twitter"
11)
12
13func printUserFollowsData(user *twitter.User) {
14 fmt.Print("followers: ")
15 c.Cyan(strconv.Itoa(user.FollowersCount))
16 fmt.Print("following: ")
17 c.Cyan(strconv.Itoa(user.FriendsCount))
18}
19func unfollowFollowingUsers(client *twitter.Client, user *twitter.User) {
20 following, _, _ := client.Friends.List(&twitter.FriendListParams{
21 ScreenName: user.ScreenName,
22 Count: 200,
23 })
24 fmt.Println(following)
25}
26func optionUnfollowAll(client *twitter.Client) {
27 fmt.Println("Getting user data...")
28 user := getUserData(client)
29 printUserFollowsData(user)
30 fmt.Println("")
31 c.Red("Are you sure you want to unfollow all? [y/n]")
32 newcommand := bufio.NewReader(os.Stdin)
33 answer, _ := newcommand.ReadString('\n')
34 answer = strings.TrimSpace(answer)
35 switch answer {
36 case "y":
37 fmt.Println("ok, you are sure")
38 unfollowFollowingUsers(client, user)
39 break
40 default:
41 fmt.Println("Operation cancelled")
42 break
43 }
44}