diff --git a/.gitignore b/.gitignore index 71b65e3..00032bd 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,6 @@ _testmain.go twitterConfig.json +twitterConfig2.json #build/twitterConfig.json temp diff --git a/argos b/argos index 5353a93..dc1e525 100755 Binary files a/argos and b/argos differ diff --git a/askForUsername.go b/askForUsername.go new file mode 100644 index 0000000..3ae81f6 --- /dev/null +++ b/askForUsername.go @@ -0,0 +1,19 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strings" +) + +func askForUsername() string { + newcommand := bufio.NewReader(os.Stdin) + fmt.Print("enter username: @") + username, _ := newcommand.ReadString('\n') + username = strings.TrimSpace(username) + fmt.Print("user selected: ") + c.Cyan("@" + username) + fmt.Println("-----------------------") + return username +} diff --git a/build/argos b/build/argos index a80587a..dc1e525 100755 Binary files a/build/argos and b/build/argos differ diff --git a/error.go b/error.go new file mode 100644 index 0000000..d9f9f75 --- /dev/null +++ b/error.go @@ -0,0 +1,7 @@ +package main + +func check(e error) { + if e != nil { + panic(e) + } +} diff --git a/main.go b/main.go index 58e0f51..30ec64b 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,7 @@ func main() { 5 - Delete Favs (Likes) 6 - Tweet Random 7 - Analyze tweet + 8 - Analyze User Followers 0 - Exit script option to select: ` for { @@ -78,7 +79,8 @@ option to select: ` switch option { case "1": fmt.Println("selected 1 - Analyze username") - optionAnalyzeUserTweets(client) + username := askForUsername() + optionAnalyzeUserTweets(client, username) fmt.Println("") c.Purple("Note: the current hours displaying, are the Twitter servers hours (Coordinated Universal Time (UTC) +0000 UTC)") break @@ -106,6 +108,11 @@ option to select: ` fmt.Println("selected 7 - Analyze Tweet") optionAnalyzeTweet(client) break + case "8": + fmt.Println("selected 8 - Analyze User Followers") + username := askForUsername() + optionAnalyzeUserFollowers(client, username) + break case "0": fmt.Println("selected 0 - exit script") os.Exit(3) diff --git a/optionAnalyzeUserFollowers.go b/optionAnalyzeUserFollowers.go new file mode 100644 index 0000000..7318ae5 --- /dev/null +++ b/optionAnalyzeUserFollowers.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + + "github.com/dghubble/go-twitter/twitter" +) + +func optionAnalyzeUserFollowers(client *twitter.Client, username string) { + var followers []twitter.User + var maxid int64 + maxid = 0 + for i := 0; i < 4; i++ { + followersRaw, _, err := client.Followers.List(&twitter.FollowerListParams{ + ScreenName: username, + Count: 200, + Cursor: maxid, + }) + check(err) + maxid = followersRaw.NextCursor + for _, f := range followersRaw.Users { + /*fmt.Println("@" + follower.ScreenName) + fmt.Println("CreatedAt: " + follower.CreatedAt)*/ + followers = append(followers, f) + } + fmt.Println(followersRaw.NextCursor) + if followersRaw.NextCursor == 0 { + break + } + } + + for k, follower := range followers { + fmt.Print(k) + fmt.Println(" @" + follower.ScreenName) + fmt.Println(" CreatedAt: " + follower.CreatedAt) + } +} diff --git a/optionAnalyzeUserTweets.go b/optionAnalyzeUserTweets.go index b993760..2874890 100644 --- a/optionAnalyzeUserTweets.go +++ b/optionAnalyzeUserTweets.go @@ -1,23 +1,13 @@ package main import ( - "bufio" "fmt" - "os" "strconv" - "strings" "github.com/dghubble/go-twitter/twitter" ) -func optionAnalyzeUserTweets(client *twitter.Client) { - newcommand := bufio.NewReader(os.Stdin) - fmt.Print("enter username: @") - username, _ := newcommand.ReadString('\n') - username = strings.TrimSpace(username) - fmt.Print("user selected: ") - c.Cyan("@" + username) - fmt.Println("-----------------------") +func optionAnalyzeUserTweets(client *twitter.Client, username string) { //get tweets tweets := getTweets(client, username, iterationsCount) diff --git a/optionUnfollowAll.go b/optionUnfollowAll.go index 452d3bb..ed12a9d 100644 --- a/optionUnfollowAll.go +++ b/optionUnfollowAll.go @@ -6,7 +6,6 @@ import ( "os" "strconv" "strings" - "time" "github.com/dghubble/go-twitter/twitter" ) @@ -40,9 +39,9 @@ func getFollowingUsers(client *twitter.Client, user *twitter.User) { for _, k := range following.Users { unfollowUser(client, k.ScreenName) //wait to avoid the twitter api limitation - fmt.Println("waiting 1 min to avoid twitter api limitation") + /*fmt.Println("waiting 1 min to avoid twitter api limitation") fmt.Println(time.Now().Local()) - time.Sleep(1 * time.Minute) + time.Sleep(1 * time.Minute)*/ } } func optionUnfollowAll(client *twitter.Client) {