in analyze tweet, group retweets by same minute
arnaucode arnaucode@gmail.com
Wed, 14 Mar 2018 18:29:36 +0100
7 files changed,
22 insertions(+),
6 deletions(-)
M
README.md
→
README.md
@@ -7,6 +7,9 @@ Be half bot and half human, a new generation of cyborgs
The user analyzer features are insipired on the Python tweets_analyzer by x0rz https://github.com/x0rz/tweets_analyzer +#### [Disclamer] +This software was made to learn the Go syntax, it works, but the implementation is not in the optimal way. I don't have time to maintain it. + #### Argos Panoptes https://en.wikipedia.org/wiki/Argus_Panoptes@@ -15,7 +18,6 @@
 -[under development] #### Current features 1. User analyzer
M
optionAnalyzeTweet.go
→
optionAnalyzeTweet.go
@@ -7,6 +7,7 @@ "os"
"sort" "strconv" "strings" + "time" "github.com/dghubble/go-twitter/twitter" )@@ -28,7 +29,11 @@ fmt.Print(" @" + retweet.User.ScreenName)
fmt.Print("\x1b[0m") //defaultColor fmt.Print(" (ID: ") fmt.Print("\x1b[31;1m" + retweet.User.IDStr + "\x1b[0m)") - fmt.Print(", source: \x1b[33;1m" + source + "\x1b[0m") + if source == "TweetDeck" { + fmt.Print(", source: \x1b[33;1m" + source + "\x1b[0m") + } else { + fmt.Print(", source: " + source) + } 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")@@ -68,12 +73,16 @@ retweets := getRetweets(client, tweetId)
var dates = make(map[string]DateRT) for _, retweet := range retweets { - retws := dates[retweet.CreatedAt].Retweets + createdat, err := retweet.CreatedAtTime() + check(err) + createdatRounded := time.Date(createdat.Year(), createdat.Month(), createdat.Day(), createdat.Hour(), createdat.Minute(), 0, 0, createdat.Location()) + + retws := dates[createdatRounded.String()].Retweets retws = append(retws, retweet) var currDate DateRT currDate.Retweets = retws - currDate.Date = retweet.CreatedAt - dates[retweet.CreatedAt] = currDate + currDate.Date = createdatRounded.String() + dates[createdatRounded.String()] = currDate } fmt.Println("total of " + strconv.Itoa(len(retweets)) + " retweets")
A
twitterConfig_DEMO.json
@@ -0,0 +1,6 @@
+{ + "consumer_key": "xxxxxxxxxxxxxxxx", + "consumer_secret": "xxxxxxxxxxxxxxxx", + "access_token_key": "xxxxxxxxxxxxxxxx", + "access_token_secret": "xxxxxxxxxxxxxxxx" +}