equal
deleted
inserted
replaced
10 "strings" |
10 "strings" |
11 |
11 |
12 "github.com/pkg/errors" |
12 "github.com/pkg/errors" |
13 ) |
13 ) |
14 |
14 |
15 // GetTimelines returns a timeline (a list of statuses |
15 // GetTimelines returns a timeline (a list of statuses) |
16 // timeline can be "home", "public", a hashtag (use ":hashtag" or "#hashtag") |
16 // timeline can be "home", "public", "direct", a hashtag (use ":hashtag" or |
17 // or a list (use "!N", e.g. "!42" for list ID #42). |
17 // "#hashtag") or a list (use "!N", e.g. "!42" for list ID #42). |
18 // For the public timelines, you can set 'local' to true to get only the |
18 // For the public timelines, you can set 'local' to true to get only the |
19 // local instance. |
19 // local instance. |
20 // Set 'onlyMedia' to true to only get statuses that have media attachments. |
20 // Set 'onlyMedia' to true to only get statuses that have media attachments. |
21 // If lopt.All is true, several requests will be made until the API server |
21 // If lopt.All is true, several requests will be made until the API server |
22 // has nothing to return. |
22 // has nothing to return. |
24 // limit is reached. |
24 // limit is reached. |
25 func (mc *Client) GetTimelines(timeline string, local, onlyMedia bool, lopt *LimitParams) ([]Status, error) { |
25 func (mc *Client) GetTimelines(timeline string, local, onlyMedia bool, lopt *LimitParams) ([]Status, error) { |
26 var endPoint string |
26 var endPoint string |
27 |
27 |
28 switch { |
28 switch { |
29 case timeline == "home", timeline == "public": |
29 case timeline == "home", timeline == "public", timeline == "direct": |
30 endPoint = "timelines/" + timeline |
30 endPoint = "timelines/" + timeline |
31 case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): |
31 case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): |
32 hashtag := timeline[1:] |
32 hashtag := timeline[1:] |
33 if hashtag == "" { |
33 if hashtag == "" { |
34 return nil, errors.New("timelines API: empty hashtag") |
34 return nil, errors.New("timelines API: empty hashtag") |