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 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
} }

View File

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