implemented analysis of tweet, getting retweets to detect Bots

This commit is contained in:
arnaucode
2017-06-22 01:16:04 +02:00
parent a42b467385
commit 2716285451
6 changed files with 59 additions and 1 deletions

BIN
argos

Binary file not shown.

Binary file not shown.

View File

@@ -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
}

View File

@@ -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)

35
optionAnalyzeTweet.go Normal file
View File

@@ -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))
}

7
todo.md Normal file
View File

@@ -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