arnaucube
arnaucube/argosPublic Self-hosted repository
implemented analysis of tweet, getting retweets to detect Bots
arnaucode idoctnef@openmailbox.org
Thu, 22 Jun 2017 01:16:04 +0200
commit

2716285451c44073a3c1cef5001e086d6018682f

parent

a42b4673857cf3eb902199b7439df7431b0518a4

6 files changed, 59 insertions(+), 1 deletions(-)

jump to
M argos → argos

          
M getOperations.go → getOperations.go

@@ -84,3 +84,14 @@

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 +}
M main.go → main.go

@@ -66,6 +66,7 @@ 3 - Follow random

4 - Delete Tweets 5 - Delete Favs (Likes) 6 - Tweet Random + 7 - Analyze tweet 0 - Exit script option to select: ` for {

@@ -98,8 +99,12 @@ fmt.Println("selected 5 - Delete Favs (Likes)")

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")
A 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)) +}
A 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