-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (44 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"github.com/ChimeraCoder/anaconda"
"highest-twitterbot/utils"
"net/url"
"sort"
)
func main() {
v := url.Values{}
v.Set("count", utils.Count)
v.Set("since_id", utils.BenchID)
api := anaconda.NewTwitterApiWithCredentials(utils.AccessToken, utils.AccessTokenSecret, utils.ConsumerKey, utils.ConsumerSecret)
search, _ := api.GetSearch(utils.Query, v)
var users []utils.User
for _, i := range search.Statuses {
incremented := false
for n, j := range users {
if j.ScreenName == i.User.ScreenName {
users[n].Tweets = j.Tweets + 10
incremented = true
break
}
}
if !incremented {
users = append(users, utils.User{Name: i.User.Name, ScreenName: i.User.ScreenName, Tweets: 1})
}
}
sort.Slice(users, func(i, j int) bool {
return users[i].Tweets < users[j].Tweets
})
if len(users) != 0 {
for _, tweetEntry := range users {
if tweetEntry.Tweets == 1 {
fmt.Printf("@%s made %d tweet \n", tweetEntry.ScreenName, tweetEntry.Tweets)
continue
}
fmt.Printf("@%s made %d tweets \n", tweetEntry.ScreenName, tweetEntry.Tweets)
}
fmt.Println("\nTweet Retrieval and Sort done")
}else{
fmt.Println("No tweets based on your params")
}
}