mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
added analyze user followers
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,5 +25,6 @@ _testmain.go
|
|||||||
|
|
||||||
|
|
||||||
twitterConfig.json
|
twitterConfig.json
|
||||||
|
twitterConfig2.json
|
||||||
#build/twitterConfig.json
|
#build/twitterConfig.json
|
||||||
temp
|
temp
|
||||||
|
|||||||
19
askForUsername.go
Normal file
19
askForUsername.go
Normal file
@@ -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
BIN
build/argos
Binary file not shown.
7
error.go
Normal file
7
error.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func check(e error) {
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
9
main.go
9
main.go
@@ -67,6 +67,7 @@ func main() {
|
|||||||
5 - Delete Favs (Likes)
|
5 - Delete Favs (Likes)
|
||||||
6 - Tweet Random
|
6 - Tweet Random
|
||||||
7 - Analyze tweet
|
7 - Analyze tweet
|
||||||
|
8 - Analyze User Followers
|
||||||
0 - Exit script
|
0 - Exit script
|
||||||
option to select: `
|
option to select: `
|
||||||
for {
|
for {
|
||||||
@@ -78,7 +79,8 @@ option to select: `
|
|||||||
switch option {
|
switch option {
|
||||||
case "1":
|
case "1":
|
||||||
fmt.Println("selected 1 - Analyze username")
|
fmt.Println("selected 1 - Analyze username")
|
||||||
optionAnalyzeUserTweets(client)
|
username := askForUsername()
|
||||||
|
optionAnalyzeUserTweets(client, username)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
c.Purple("Note: the current hours displaying, are the Twitter servers hours (Coordinated Universal Time (UTC) +0000 UTC)")
|
c.Purple("Note: the current hours displaying, are the Twitter servers hours (Coordinated Universal Time (UTC) +0000 UTC)")
|
||||||
break
|
break
|
||||||
@@ -106,6 +108,11 @@ option to select: `
|
|||||||
fmt.Println("selected 7 - Analyze Tweet")
|
fmt.Println("selected 7 - Analyze Tweet")
|
||||||
optionAnalyzeTweet(client)
|
optionAnalyzeTweet(client)
|
||||||
break
|
break
|
||||||
|
case "8":
|
||||||
|
fmt.Println("selected 8 - Analyze User Followers")
|
||||||
|
username := askForUsername()
|
||||||
|
optionAnalyzeUserFollowers(client, username)
|
||||||
|
break
|
||||||
case "0":
|
case "0":
|
||||||
fmt.Println("selected 0 - exit script")
|
fmt.Println("selected 0 - exit script")
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
|
|||||||
37
optionAnalyzeUserFollowers.go
Normal file
37
optionAnalyzeUserFollowers.go
Normal file
@@ -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,23 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func optionAnalyzeUserTweets(client *twitter.Client) {
|
func optionAnalyzeUserTweets(client *twitter.Client, username 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("-----------------------")
|
|
||||||
|
|
||||||
//get tweets
|
//get tweets
|
||||||
tweets := getTweets(client, username, iterationsCount)
|
tweets := getTweets(client, username, iterationsCount)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
@@ -40,9 +39,9 @@ func getFollowingUsers(client *twitter.Client, user *twitter.User) {
|
|||||||
for _, k := range following.Users {
|
for _, k := range following.Users {
|
||||||
unfollowUser(client, k.ScreenName)
|
unfollowUser(client, k.ScreenName)
|
||||||
//wait to avoid the twitter api limitation
|
//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())
|
fmt.Println(time.Now().Local())
|
||||||
time.Sleep(1 * time.Minute)
|
time.Sleep(1 * time.Minute)*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func optionUnfollowAll(client *twitter.Client) {
|
func optionUnfollowAll(client *twitter.Client) {
|
||||||
|
|||||||
Reference in New Issue
Block a user