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:
clawbot
2026-02-10 17:53:13 -08:00
parent 0ee3fd78d2
commit d06bb5334a
2 changed files with 11 additions and 13 deletions

View File

@@ -148,21 +148,19 @@ func (c *Client) PollMessages(afterID string, timeout int) ([]Message, error) {
return msgs, nil
}
// JoinChannel joins a channel.
// JoinChannel joins a channel via the unified command endpoint.
func (c *Client) JoinChannel(channel string) error {
_, err := c.do("POST", "/api/v1/channels/join", map[string]string{"channel": channel})
return err
return c.SendMessage(&Message{Command: "JOIN", To: channel})
}
// PartChannel leaves a channel.
// PartChannel leaves a channel via the unified command endpoint.
func (c *Client) PartChannel(channel string) error {
_, err := c.do("DELETE", "/api/v1/channels/"+url.PathEscape(channel), nil)
return err
return c.SendMessage(&Message{Command: "PART", To: channel})
}
// ListChannels returns all channels on the server.
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 {
return nil, err
}

View File

@@ -15,12 +15,12 @@ type App struct {
ui *UI
client *api.Client
mu sync.Mutex
nick string
target string // current target (#channel or nick for DM)
connected bool
lastMsgID string
stopPoll chan struct{}
mu sync.Mutex
nick string
target string // current target (#channel or nick for DM)
connected bool
lastMsgID string
stopPoll chan struct{}
}
func main() {