diff --git a/argos b/argos index 2323b9f..d9b5d9f 100755 Binary files a/argos and b/argos differ diff --git a/build/argos b/build/argos index 2323b9f..d9b5d9f 100755 Binary files a/build/argos and b/build/argos differ diff --git a/getOperations.go b/getOperations.go index d25bf36..1ea00d6 100644 --- a/getOperations.go +++ b/getOperations.go @@ -84,3 +84,14 @@ func printUserData(user *twitter.User) { fmt.Print("number of favs: ") c.Purple(strconv.Itoa(user.FavouritesCount)) } + +func getRetweets(client *twitter.Client, tweetId int64) []twitter.Tweet { + var tweets []twitter.Tweet + tweets, _, err := client.Statuses.Retweets(tweetId, &twitter.StatusRetweetsParams{ + Count: 200, + }) + if err != nil { + fmt.Println(err) + } + return tweets +} diff --git a/main.go b/main.go index 2d9354c..bd3fdf5 100644 --- a/main.go +++ b/main.go @@ -66,6 +66,7 @@ func main() { 4 - Delete Tweets 5 - Delete Favs (Likes) 6 - Tweet Random + 7 - Analyze tweet 0 - Exit script option to select: ` for { @@ -98,9 +99,13 @@ option to select: ` optionDeleteFavs(client) break case "6": - fmt.Println("selected 5 - Tweet random") + fmt.Println("selected 6 - Tweet random") optionTweetRandom(client) break + case "7": + fmt.Println("selected 7 - Analyze Tweet") + optionAnalyzeTweet(client) + break case "0": fmt.Println("selected 0 - exit script") os.Exit(3) diff --git a/optionAnalyzeTweet.go b/optionAnalyzeTweet.go new file mode 100644 index 0000000..403d613 --- /dev/null +++ b/optionAnalyzeTweet.go @@ -0,0 +1,35 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" + + "github.com/dghubble/go-twitter/twitter" +) + +func optionAnalyzeTweet(client *twitter.Client) { + newcommand := bufio.NewReader(os.Stdin) + fmt.Print("enter link of the tweet: ") + link, _ := newcommand.ReadString('\n') + link = strings.TrimSpace(link) + fmt.Print("link selected: ") + c.Cyan(link) + fmt.Println("-----------------------") + linkParam := strings.Split(link, "/") + tweetIdStr := linkParam[len(linkParam)-1] + c.Cyan(tweetIdStr) + tweetId, err := strconv.ParseInt(tweetIdStr, 10, 64) + if err != nil { + fmt.Println(err) + } + tweets := getRetweets(client, tweetId) + for _, tweet := range tweets { + source := strings.Split(strings.Split(tweet.Source, ">")[1], "<")[0] + fmt.Println(tweet.CreatedAt + " @" + tweet.User.ScreenName + ", source: " + source) + } + fmt.Print("total of: ") + fmt.Println(len(tweets)) +} diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..33bd745 --- /dev/null +++ b/todo.md @@ -0,0 +1,7 @@ +- error when getting user from user following list, and this user don't have users following + +``` +optionFollowRandom.go +line 33 +``` +just need to check if the user have following users, and if not, get another user to follow