31 lines
446 B
Go
31 lines
446 B
Go
package ircclient
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"tuxpa.in/a/irc/pkg/ircconn"
|
|
"tuxpa.in/a/irc/pkg/ircv3"
|
|
)
|
|
|
|
type Client struct {
|
|
}
|
|
|
|
func (r *Client) Connect(ctx context.Context,
|
|
Connector func() (io.Writer, io.Reader, error),
|
|
h ircv3.Handler) error {
|
|
wr, rd, err := Connector()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
irc := ircconn.New(wr, rd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = irc.Serve(ctx, h)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|