mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
improved visualization of tweet analysis, better Bot detection
This commit is contained in:
BIN
build/argos
BIN
build/argos
Binary file not shown.
2
main.go
2
main.go
@@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4-beta"
|
const version = "0.5-beta"
|
||||||
const minNumWords = 10
|
const minNumWords = 10
|
||||||
const minNumHashtag = 2
|
const minNumHashtag = 2
|
||||||
const minNumUserInteractions = 2
|
const minNumUserInteractions = 2
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ import (
|
|||||||
|
|
||||||
type DateRT struct {
|
type DateRT struct {
|
||||||
Retweets []twitter.Tweet
|
Retweets []twitter.Tweet
|
||||||
|
Date string
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionAnalyzeTweet(client *twitter.Client) {
|
func optionAnalyzeTweet(client *twitter.Client) {
|
||||||
@@ -45,28 +47,52 @@ func optionAnalyzeTweet(client *twitter.Client) {
|
|||||||
retws = append(retws, retweet)
|
retws = append(retws, retweet)
|
||||||
var currDate DateRT
|
var currDate DateRT
|
||||||
currDate.Retweets = retws
|
currDate.Retweets = retws
|
||||||
|
currDate.Date = retweet.CreatedAt
|
||||||
dates[retweet.CreatedAt] = currDate
|
dates[retweet.CreatedAt] = currDate
|
||||||
}
|
}
|
||||||
fmt.Print("total of: ")
|
fmt.Println("total of " + strconv.Itoa(len(retweets)) + " retweets")
|
||||||
fmt.Println(len(retweets))
|
|
||||||
|
|
||||||
for k, v := range dates {
|
//puts the map into a slice, to easy sort
|
||||||
printDateRT(k, v)
|
var arrayDates []DateRT
|
||||||
|
for _, v := range dates {
|
||||||
|
arrayDates = append(arrayDates, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("")
|
||||||
|
c.Cyan("Showing accounts that retweeted at the same exact time (they are possible Bots) and the source the RT were made:")
|
||||||
|
|
||||||
|
//sort the slice
|
||||||
|
sort.Slice(arrayDates, func(i, j int) bool {
|
||||||
|
return len(arrayDates[i].Retweets) < len(arrayDates[j].Retweets)
|
||||||
|
})
|
||||||
|
//print the sorted slice
|
||||||
|
for _, v := range arrayDates {
|
||||||
|
if len(v.Retweets) > 1 {
|
||||||
|
printDateRT(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println("")
|
||||||
c.Purple("Warning: Twitter API only gives the last 100 Retweets")
|
c.Purple("Warning: Twitter API only gives the last 100 Retweets")
|
||||||
}
|
}
|
||||||
func printDateRT(k string, v DateRT) {
|
func printDateRT(v DateRT) {
|
||||||
fmt.Print("\x1b[32;1m" + k + "\x1b[0m")
|
fmt.Print("\x1b[32;1m" + v.Date + "\x1b[0m")
|
||||||
fmt.Println(" " + strconv.Itoa(len(v.Retweets)) + " Retweets at this date:")
|
fmt.Println(" " + strconv.Itoa(len(v.Retweets)) + " Retweets at this date:")
|
||||||
for _, retweet := range v.Retweets {
|
for _, retweet := range v.Retweets {
|
||||||
source := strings.Split(strings.Split(retweet.Source, ">")[1], "<")[0]
|
source := strings.Split(strings.Split(retweet.Source, ">")[1], "<")[0]
|
||||||
if len(v.Retweets) > 1 {
|
if len(v.Retweets) > 1 {
|
||||||
fmt.Print("\x1b[31;1m") //red
|
fmt.Print("\x1b[31;1m") //red
|
||||||
}
|
}
|
||||||
fmt.Print(" @" + retweet.User.ScreenName)
|
fmt.Print(" @" + retweet.User.ScreenName)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
fmt.Println(", source: " + source)
|
fmt.Print(" (ID: ")
|
||||||
|
fmt.Print("\x1b[31;1m" + retweet.User.IDStr + "\x1b[0m)")
|
||||||
|
fmt.Print(", source: \x1b[33;1m" + source + "\x1b[0m")
|
||||||
|
fmt.Print(", user created at: \x1b[32;1m" + retweet.User.CreatedAt + "\x1b[0m,")
|
||||||
|
|
||||||
|
fmt.Print(" \x1b[34;1m" + strconv.Itoa(retweet.User.FollowersCount) + "\x1b[0m followers")
|
||||||
|
fmt.Print(", \x1b[34;1m" + strconv.Itoa(retweet.User.FriendsCount) + "\x1b[0m following")
|
||||||
|
fmt.Println("")
|
||||||
}
|
}
|
||||||
|
fmt.Println("")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ func optionAnalyzeUserTweets(client *twitter.Client) {
|
|||||||
fmt.Println("User @" + username + " does not have tweets")
|
fmt.Println("User @" + username + " does not have tweets")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
analyzeUserAccount(client, username)
|
||||||
|
|
||||||
//now analyze words and dates
|
//now analyze words and dates
|
||||||
fmt.Println("Word frequency (more than " + strconv.Itoa(minNumWords) + " times):")
|
fmt.Println("Word frequency (more than " + strconv.Itoa(minNumWords) + " times):")
|
||||||
words := analyzeWords(tweets)
|
words := analyzeWords(tweets)
|
||||||
@@ -62,6 +65,6 @@ func optionAnalyzeUserTweets(client *twitter.Client) {
|
|||||||
fmt.Println(" ")
|
fmt.Println(" ")
|
||||||
fmt.Print("User @")
|
fmt.Print("User @")
|
||||||
c.Cyan(username)
|
c.Cyan(username)
|
||||||
analyzeUserAccount(client, username)
|
//analyzeUserAccount(client, username)
|
||||||
fmt.Println(" analysis finished")
|
fmt.Println(" analysis finished")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user