mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 11:06:39 +01:00
show detected bots retweeting a tweet
This commit is contained in:
@@ -32,6 +32,8 @@ https://en.wikipedia.org/wiki/Panopticon
|
||||
5. Delete Favs (Likes)
|
||||
6. Random tweet
|
||||
- post a tweet with content from a selected account
|
||||
7. Tweet analyzer
|
||||
- analyze the retweets and detect Bots
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -37,6 +37,32 @@ func printBar(n int, lowest int, highest int) {
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
fmt.Println(" ")
|
||||
}
|
||||
func printBarRetweets(n int, lowest int, highest int) {
|
||||
bar := int((float64(n) / float64(highest)) * 40)
|
||||
|
||||
if n == lowest {
|
||||
fmt.Print("\x1b[36;1m") //cyan
|
||||
}
|
||||
if n == highest {
|
||||
fmt.Print("\x1b[31;1m") //red
|
||||
}
|
||||
|
||||
for i := 0; i < bar; i++ {
|
||||
fmt.Print("█")
|
||||
}
|
||||
|
||||
if bar == 0 && n > 0 {
|
||||
fmt.Print("█")
|
||||
}
|
||||
if n == lowest {
|
||||
//fmt.Print(" lowest")
|
||||
}
|
||||
if n == highest {
|
||||
fmt.Print(" possible bots")
|
||||
}
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
fmt.Println(" ")
|
||||
}
|
||||
func getHigherValueOfMap(m map[string]int) (int, int) {
|
||||
var values []int
|
||||
for _, v := range m {
|
||||
@@ -106,3 +132,24 @@ func analyzeDates(tweets []twitter.Tweet) {
|
||||
fmt.Println("Daily activity distribution (per hour)")
|
||||
analyzeHours(tweets)
|
||||
}
|
||||
|
||||
func printTimeRetweets(dates map[string]int) {
|
||||
lowest, highest := getHigherValueOfMap(dates)
|
||||
|
||||
for k, v := range dates {
|
||||
fmt.Print(k + " - " + strconv.Itoa(v) + "tw")
|
||||
fmt.Print(" ")
|
||||
printBarRetweets(v, lowest, highest)
|
||||
}
|
||||
}
|
||||
|
||||
func analyzeTimeRetweets(tweets []twitter.Tweet) {
|
||||
var dates = make(map[string]int)
|
||||
for _, v := range tweets {
|
||||
/*time := strings.Split(v.CreatedAt, " ")[3]
|
||||
hour := strings.Split(time, ":")[0]*/
|
||||
dates[v.CreatedAt]++
|
||||
}
|
||||
printTimeRetweets(dates)
|
||||
//printSortedMapStringInt(dates, 0)
|
||||
}
|
||||
|
||||
BIN
build/argos
BIN
build/argos
Binary file not shown.
2
main.go
2
main.go
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const version = "0.3-beta"
|
||||
const version = "0.4-beta"
|
||||
const minNumWords = 10
|
||||
const minNumHashtag = 2
|
||||
const minNumUserInteractions = 2
|
||||
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
)
|
||||
|
||||
type DateRT struct {
|
||||
Retweets []twitter.Tweet
|
||||
}
|
||||
|
||||
func optionAnalyzeTweet(client *twitter.Client) {
|
||||
newcommand := bufio.NewReader(os.Stdin)
|
||||
fmt.Print("enter link of the tweet: ")
|
||||
@@ -25,11 +29,44 @@ func optionAnalyzeTweet(client *twitter.Client) {
|
||||
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)
|
||||
|
||||
tweet, _, err := client.Statuses.Show(tweetId, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Print("tweet text: ")
|
||||
c.Yellow(tweet.Text)
|
||||
|
||||
retweets := getRetweets(client, tweetId)
|
||||
|
||||
var dates = make(map[string]DateRT)
|
||||
for _, retweet := range retweets {
|
||||
retws := dates[retweet.CreatedAt].Retweets
|
||||
retws = append(retws, retweet)
|
||||
var currDate DateRT
|
||||
currDate.Retweets = retws
|
||||
dates[retweet.CreatedAt] = currDate
|
||||
}
|
||||
fmt.Print("total of: ")
|
||||
fmt.Println(len(tweets))
|
||||
fmt.Println(len(retweets))
|
||||
|
||||
for k, v := range dates {
|
||||
printDateRT(k, v)
|
||||
}
|
||||
c.Purple("Warning: Twitter API only gives the last 100 Retweets")
|
||||
}
|
||||
func printDateRT(k string, v DateRT) {
|
||||
fmt.Print("\x1b[32;1m" + k + "\x1b[0m")
|
||||
fmt.Println(" " + strconv.Itoa(len(v.Retweets)) + " Retweets at this date:")
|
||||
for _, retweet := range v.Retweets {
|
||||
source := strings.Split(strings.Split(retweet.Source, ">")[1], "<")[0]
|
||||
if len(v.Retweets) > 1 {
|
||||
fmt.Print("\x1b[31;1m") //red
|
||||
}
|
||||
fmt.Print(" @" + retweet.User.ScreenName)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
fmt.Println(", source: " + source)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user