-
Notifications
You must be signed in to change notification settings - Fork 0
/
mentions.go
55 lines (44 loc) · 1.16 KB
/
mentions.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
package main
import (
"github.com/jmcvetta/neoism"
"github.com/juju/errors"
)
func (p *Engine) AddMentions() error {
logger.Info("add mention tweets")
db, err := p.ensureClients()
if err != nil {
return errors.Annotate(err, "ensure clients")
}
screenName, err := p.cnf.ScreenName()
if err != nil {
return err
}
params := map[string]string{
"count": "200",
"screen_name": screenName,
"exclude_replies": "false",
"contributor_details": "true",
}
props := neoism.Props{
"mention_type": "mention_search",
}
maxID, err := p.getMaxID(db, CYPHER_MENTIONS_MAX_ID, screenName)
if err != nil {
return errors.Annotate(err, "mentions get max id")
}
mentions, err := p.tweetsGet(TW_PATH_MENTIONS_TIMELINE, maxID, params)
if err != nil {
return errors.Annotate(err, "get tweets")
}
for len(mentions) > 0 {
maxID = mentions[len(mentions)-1].Id() - 1
if err = p.tweetsImport(db, mentions, props); err != nil {
return errors.Annotate(err, "import mention tweets")
}
mentions, err = p.tweetsGet(TW_PATH_MENTIONS_TIMELINE, maxID, params)
if err != nil {
return errors.Annotate(err, "get tweets")
}
}
return nil
}