commit 89b1a5c3e10fed60ffc86bbc60616d963580ffdb
parent c7e484674044c521253419f430bd26350824dd69
Author: MTRNord <mtrnord1@gmail.com>
Date: Sat, 17 Feb 2018 13:36:50 +0100
Check if we already know the exiting tweet
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/twitter/twitter.go b/twitter/twitter.go
@@ -183,6 +183,7 @@ func (t *TwitterAPI) GetTweets(tweets []int64) ([]byte, error) {
v := url.Values{}
v.Set("include_entities", "true")
retweets := make(map[string]bool)
+ tweetsSlice := make(map[string]bool)
var divided [][]int64
@@ -209,15 +210,23 @@ func (t *TwitterAPI) GetTweets(tweets []int64) ([]byte, error) {
for _, t := range tweetsR {
//fmt.Printf("%+v\n\n\n", t)
JT := Tweet{}
+ if tweetsSlice[t.IdStr] {
+ continue
+ }
if t.RetweetedStatus != nil {
JT.Retweet = true
+ if tweetsSlice[t.RetweetedStatus.IdStr] {
+ continue
+ }
if retweets[t.RetweetedStatus.IdStr] {
continue
+ } else {
+ retweets[t.RetweetedStatus.IdStr] = true
}
- retweets[t.RetweetedStatus.IdStr] = true
} else {
JT.Retweet = false
}
+ tweetsSlice[t.IdStr] = true
JT.Username = t.User.ScreenName
JT.UserID = t.User.IdStr
JT.DisplayName = t.User.Name