-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 987 Bytes
/
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
package main
import (
"net/url"
"github.com/ChimeraCoder/anaconda"
"github.com/imunizeme/config.core"
"github.com/sirupsen/logrus"
)
const (
minSaudeTwitterID = "37717107"
)
func main() {
log := &logger{logrus.New()}
if err := config.Load(); err != nil {
log.Fatal(err)
}
anaconda.SetConsumerKey(config.Get.Bot.Consumerkey)
anaconda.SetConsumerSecret(config.Get.Bot.ConsumerSecret)
api := anaconda.NewTwitterApi(config.Get.Bot.AccessToken, config.Get.Bot.TokenSecret)
api.SetLogger(log)
stream := api.PublicStreamFilter(url.Values{
"track": []string{"vacina"},
"follow": []string{minSaudeTwitterID},
})
defer stream.Stop()
for v := range stream.C {
t, ok := v.(anaconda.Tweet)
if !ok {
log.Errorln("received unexpected value of type %T", v)
continue
}
if t.User.IdStr == minSaudeTwitterID {
log.Infof("sending to firebase %s", t.Text)
if err := send(t.Text); err != nil {
log.Errorln("unexpected error from firebase")
}
}
}
}