Browse Source

in analyze tweet, group retweets by same minute

master
arnaucode 6 years ago
parent
commit
be2b96630b
7 changed files with 22 additions and 6 deletions
  1. +0
    -1
      .gitignore
  2. +3
    -1
      README.md
  3. BIN
      argos
  4. BIN
      build/argos
  5. BIN
      build/argos.exe
  6. +13
    -4
      optionAnalyzeTweet.go
  7. +6
    -0
      twitterConfig_DEMO.json

+ 0
- 1
.gitignore

@ -19,7 +19,6 @@ _cgo_export.*
_testmain.go _testmain.go
*.exe
*.test *.test
*.prof *.prof

+ 3
- 1
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 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 #### Argos Panoptes
https://en.wikipedia.org/wiki/Argus_Panoptes https://en.wikipedia.org/wiki/Argus_Panoptes
@ -15,7 +18,6 @@ https://en.wikipedia.org/wiki/Panopticon
![Argos](https://raw.githubusercontent.com/arnaucode/argos/master/argos.jpg "argos") ![Argos](https://raw.githubusercontent.com/arnaucode/argos/master/argos.jpg "argos")
[under development]
#### Current features #### Current features
1. User analyzer 1. User analyzer

BIN
argos


BIN
build/argos


BIN
build/argos.exe


+ 13
- 4
optionAnalyzeTweet.go

@ -7,6 +7,7 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/dghubble/go-twitter/twitter" "github.com/dghubble/go-twitter/twitter"
) )
@ -28,7 +29,11 @@ func printDateRT(v DateRT) {
fmt.Print("\x1b[0m") //defaultColor fmt.Print("\x1b[0m") //defaultColor
fmt.Print(" (ID: ") fmt.Print(" (ID: ")
fmt.Print("\x1b[31;1m" + retweet.User.IDStr + "\x1b[0m)") 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(", 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.FollowersCount) + "\x1b[0m followers")
@ -68,12 +73,16 @@ func optionAnalyzeTweet(client *twitter.Client) {
var dates = make(map[string]DateRT) var dates = make(map[string]DateRT)
for _, retweet := range retweets { 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) retws = append(retws, retweet)
var currDate DateRT var currDate DateRT
currDate.Retweets = retws 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") fmt.Println("total of " + strconv.Itoa(len(retweets)) + " retweets")

+ 6
- 0
twitterConfig_DEMO.json

@ -0,0 +1,6 @@
{
"consumer_key": "xxxxxxxxxxxxxxxx",
"consumer_secret": "xxxxxxxxxxxxxxxx",
"access_token_key": "xxxxxxxxxxxxxxxx",
"access_token_secret": "xxxxxxxxxxxxxxxx"
}

Loading…
Cancel
Save