# HG changeset patch # User Mikael Berthe # Date 1536349784 -7200 # Node ID 4508376c8fcba0106eaae12b0f231f1c8fc524a2 # Parent 7386c6a454a8db6b02b346405c78c2515ba2608b GetTimelines & StreamListener: Accept "direct" timeline diff -r 7386c6a454a8 -r 4508376c8fcb streams.go --- a/streams.go Fri Sep 07 19:17:12 2018 +0200 +++ b/streams.go Fri Sep 07 21:49:44 2018 +0200 @@ -25,14 +25,15 @@ // openStream opens a stream URL and returns an http.Response // Note that the caller should close the connection when it's done reading // the stream. -// The stream name can be "user", "local", "public", "list" or "hashtag". +// The stream name can be "user", "local", "public", "direct", "list" or +// "hashtag". // When it is "hashtag", the param argument contains the hashtag. // When it is "list", the param argument contains the list ID. func (mc *Client) openStream(streamName, param string) (*websocket.Conn, error) { var tag, list string switch streamName { - case "user", "public", "public:local": + case "user", "public", "public:local", "direct": case "hashtag": if param == "" { return nil, ErrInvalidParameter diff -r 7386c6a454a8 -r 4508376c8fcb timelines.go --- a/timelines.go Fri Sep 07 19:17:12 2018 +0200 +++ b/timelines.go Fri Sep 07 21:49:44 2018 +0200 @@ -12,9 +12,9 @@ "github.com/pkg/errors" ) -// GetTimelines returns a timeline (a list of statuses -// timeline can be "home", "public", a hashtag (use ":hashtag" or "#hashtag") -// or a list (use "!N", e.g. "!42" for list ID #42). +// GetTimelines returns a timeline (a list of statuses) +// timeline can be "home", "public", "direct", a hashtag (use ":hashtag" or +// "#hashtag") or a list (use "!N", e.g. "!42" for list ID #42). // For the public timelines, you can set 'local' to true to get only the // local instance. // Set 'onlyMedia' to true to only get statuses that have media attachments. @@ -26,7 +26,7 @@ var endPoint string switch { - case timeline == "home", timeline == "public": + case timeline == "home", timeline == "public", timeline == "direct": endPoint = "timelines/" + timeline case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): hashtag := timeline[1:]