feat(cli): update client to use unified command endpoint
- JoinChannel/PartChannel now send via POST /messages with command field - ListChannels uses /channels instead of /channels/all - gofmt whitespace fixes
This commit is contained in:
@@ -148,21 +148,19 @@ func (c *Client) PollMessages(afterID string, timeout int) ([]Message, error) {
|
|||||||
return msgs, nil
|
return msgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// JoinChannel joins a channel.
|
// JoinChannel joins a channel via the unified command endpoint.
|
||||||
func (c *Client) JoinChannel(channel string) error {
|
func (c *Client) JoinChannel(channel string) error {
|
||||||
_, err := c.do("POST", "/api/v1/channels/join", map[string]string{"channel": channel})
|
return c.SendMessage(&Message{Command: "JOIN", To: channel})
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PartChannel leaves a channel.
|
// PartChannel leaves a channel via the unified command endpoint.
|
||||||
func (c *Client) PartChannel(channel string) error {
|
func (c *Client) PartChannel(channel string) error {
|
||||||
_, err := c.do("DELETE", "/api/v1/channels/"+url.PathEscape(channel), nil)
|
return c.SendMessage(&Message{Command: "PART", To: channel})
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListChannels returns all channels on the server.
|
// ListChannels returns all channels on the server.
|
||||||
func (c *Client) ListChannels() ([]Channel, error) {
|
func (c *Client) ListChannels() ([]Channel, error) {
|
||||||
data, err := c.do("GET", "/api/v1/channels/all", nil)
|
data, err := c.do("GET", "/api/v1/channels", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user