-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
81 lines (62 loc) · 2.14 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"os"
"time"
helper "twitter-helper-bot/twitterhelper"
"github.com/sirupsen/logrus"
)
var log = logrus.New()
func init() {
log.Out = os.Stdout
// You could set this to any `io.Writer` such as a file
file, err := os.OpenFile("logs.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {
log.Out = file
} else {
log.Info("Failed to log to file, using default stderr")
}
}
func main() {
// Calculate start time for bot server
startTime := time.Now().Local()
starttimeStampString := startTime.Format("2006-01-02 15:04:05")
unixNano := startTime.UnixNano()
umillisec := unixNano / 1000000
fmt.Println("+++++++++++++++++++++++++++++++++++++++")
fmt.Println("Starting the Twitter-Helper-Bot application.....", starttimeStampString)
fmt.Println("+++++++++++++++++++++++++++++++++++++++")
creds := helper.TwitterCredentials{
Consumerkey: os.Getenv("TWITTER_CONSUMER_KEY"),
ConsumerSecret: os.Getenv("TWITTER_CONSUMER_SECRET"),
AccessToken: os.Getenv("TWITTER_ACCESS_TOKEN"),
AccessTokenSecret: os.Getenv("TWITTER_ACCESS_SECRET"),
}
client, err := helper.Twitter(&creds)
if err != nil {
log.Error("Error in Twitter client", client)
//log.Println(err)
}
/* */
TrendListName := helper.TopTrending(client)
SearchQueries := helper.Searchqueries(TrendListName, client)
TweetStatusIds := helper.FilterTweetstatusId(SearchQueries, client)
TweetStatusDescription := helper.RetweetingTweet(TweetStatusIds, client)
helper.PostTweet("Let's Connect Together", client)
fmt.Println(TweetStatusDescription)
// Calculating end time for the bot
endTime := time.Now().Local()
endttimeStampString := endTime.Format("2006-01-02 15:04:05")
unixNano = endTime.UnixNano()
umillisec1 := unixNano / 1000000
/*
Find differece betweeen start time and end time of the bot server
*/
diff_milli_seconds := umillisec1 - umillisec
fmt.Println()
fmt.Println()
fmt.Println("+++++++++++++++++++++++++++++++++++++++")
fmt.Println("Closing Twitter-Helper-Bot......", endttimeStampString)
fmt.Println("Millisecond consumed ......", diff_milli_seconds)
fmt.Println("+++++++++++++++++++++++++++++++++++++++")
}