equal
deleted
inserted
replaced
5 */ |
5 */ |
6 |
6 |
7 package madon |
7 package madon |
8 |
8 |
9 import ( |
9 import ( |
10 "fmt" |
|
11 "strings" |
10 "strings" |
|
11 |
|
12 "github.com/pkg/errors" |
12 ) |
13 ) |
13 |
14 |
14 // GetTimelines returns a timeline (a list of statuses |
15 // GetTimelines returns a timeline (a list of statuses |
15 // timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag") |
16 // timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag") |
16 // For the public timelines, you can set 'local' to true to get only the |
17 // For the public timelines, you can set 'local' to true to get only the |
26 case timeline == "home", timeline == "public": |
27 case timeline == "home", timeline == "public": |
27 endPoint = "timelines/" + timeline |
28 endPoint = "timelines/" + timeline |
28 case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): |
29 case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): |
29 hashtag := timeline[1:] |
30 hashtag := timeline[1:] |
30 if hashtag == "" { |
31 if hashtag == "" { |
31 return nil, fmt.Errorf("timelines API: empty hashtag") |
32 return nil, errors.New("timelines API: empty hashtag") |
32 } |
33 } |
33 endPoint = "timelines/tag/" + hashtag |
34 endPoint = "timelines/tag/" + hashtag |
34 default: |
35 default: |
35 return nil, fmt.Errorf("GetTimelines: bad timelines argument") |
36 return nil, errors.New("GetTimelines: bad timelines argument") |
36 } |
37 } |
37 |
38 |
38 params := make(apiCallParams) |
39 params := make(apiCallParams) |
39 if timeline == "public" && local { |
40 if timeline == "public" && local { |
40 params["local"] = "true" |
41 params["local"] = "true" |