Browse Source

added analyze user followers

master
arnaucode 6 years ago
parent
commit
29814e88ac
9 changed files with 75 additions and 15 deletions
  1. +1
    -0
      .gitignore
  2. BIN
      argos
  3. +19
    -0
      askForUsername.go
  4. BIN
      build/argos
  5. +7
    -0
      error.go
  6. +8
    -1
      main.go
  7. +37
    -0
      optionAnalyzeUserFollowers.go
  8. +1
    -11
      optionAnalyzeUserTweets.go
  9. +2
    -3
      optionUnfollowAll.go

+ 1
- 0
.gitignore

@ -25,5 +25,6 @@ _testmain.go
twitterConfig.json
twitterConfig2.json
#build/twitterConfig.json
temp

BIN
argos


+ 19
- 0
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
}

BIN
build/argos


+ 7
- 0
error.go

@ -0,0 +1,7 @@
package main
func check(e error) {
if e != nil {
panic(e)
}
}

+ 8
- 1
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)

+ 37
- 0
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)
}
}

+ 1
- 11
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)

+ 2
- 3
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) {

Loading…
Cancel
Save