# HG changeset patch # User Mikael Berthe # Date 1521581913 -3600 # Node ID cc086e49cd0c866f1fba0e1e9860c5cec3e9f9e0 # Parent 403ce36a94ab3d59a969fab39ffbc4361903631a Add support for list-based streams diff -r 403ce36a94ab -r cc086e49cd0c streams.go --- a/streams.go Tue Mar 20 21:52:55 2018 +0100 +++ b/streams.go Tue Mar 20 22:38:33 2018 +0100 @@ -25,18 +25,24 @@ // 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" or "hashtag". -// When it is "hashtag", the hashTag argument cannot be empty. -func (mc *Client) openStream(streamName, hashTag string) (*websocket.Conn, error) { - var tag string +// The stream name can be "user", "local", "public", "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 "hashtag": - if hashTag == "" { + if param == "" { return nil, ErrInvalidParameter } - tag = hashTag + tag = param + case "list": + if param == "" { + return nil, ErrInvalidParameter + } + list = param default: return nil, ErrInvalidParameter } @@ -56,6 +62,8 @@ urlParams.Add("access_token", mc.UserToken.AccessToken) if tag != "" { urlParams.Add("tag", tag) + } else if list != "" { + urlParams.Add("list", list) } u.RawQuery = urlParams.Encode()