Documentation ¶
Index ¶
- Variables
- func MaskToRegex(rawMask string) (*regexp.Regexp, error)
- type Client
- func (c *Client) CapAvailable(capName string) bool
- func (c *Client) CapEnabled(capName string) bool
- func (c *Client) CapRequest(capName string, required bool)
- func (c *Client) CurrentNick() string
- func (c *Client) FromChannel(m *Message) bool
- func (c *Client) Run() error
- func (c *Client) RunContext(ctx context.Context) error
- type ClientConfig
- type Conn
- type Handler
- type HandlerFunc
- type Message
- type Prefix
- type Reader
- type TagValue
- type Tags
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrZeroLengthMessage is returned when parsing if the input is // zero-length. ErrZeroLengthMessage = errors.New("irc: Cannot parse zero-length message") // ErrMissingDataAfterPrefix is returned when parsing if there is // no message data after the prefix. ErrMissingDataAfterPrefix = errors.New("irc: No message data after prefix") // ErrMissingDataAfterTags is returned when parsing if there is no // message data after the tags. ErrMissingDataAfterTags = errors.New("irc: No message data after tags") // ErrMissingCommand is returned when parsing if there is no // command in the parsed message. ErrMissingCommand = errors.New("irc: Missing message command") )
Functions ¶
Types ¶
type Client ¶
type Client struct { *Conn // contains filtered or unexported fields }
Client is a wrapper around Conn which is designed to make common operations much simpler.
func NewClient ¶
func NewClient(rw io.ReadWriter, config ClientConfig) *Client
NewClient creates a client given an io stream and a client config.
func (*Client) CapAvailable ¶
CapAvailable allows you to check if a CAP is available on this server. Note that it will not be populated until after the CAP handshake is done, so it is recommended to wait to check this until after a message like 001.
func (*Client) CapEnabled ¶
CapEnabled allows you to check if a CAP is enabled for this connection. Note that it will not be populated until after the CAP handshake is done, so it is recommended to wait to check this until after a message like 001.
func (*Client) CapRequest ¶
CapRequest allows you to request IRCv3 capabilities from the server during the handshake. The behavior is undefined if this is called before the handshake completes so it is recommended that this be called before Run. If the CAP is marked as required, the client will exit if that CAP could not be negotiated during the handshake.
func (*Client) CurrentNick ¶
CurrentNick returns what the nick of the client is known to be at this point in time.
func (*Client) FromChannel ¶
FromChannel takes a Message representing a PRIVMSG and returns if that message came from a channel or directly from a user.
type ClientConfig ¶
type ClientConfig struct { // General connection information. Nick string Pass string User string Name string // Connection settings PingFrequency time.Duration PingTimeout time.Duration // SendLimit is how frequent messages can be sent. If this is zero, // there will be no limit. SendLimit time.Duration // SendBurst is the number of messages which can be sent in a burst. SendBurst int // Handler is used for message dispatching. Handler Handler }
ClientConfig is a structure used to configure a Client.
type Handler ¶
Handler is a simple interface meant for dispatching a message from a Client connection.
type HandlerFunc ¶
HandlerFunc is a simple wrapper around a function which allows it to be used as a Handler.
type Message ¶
type Message struct { // Each message can have IRCv3 tags Tags // Each message can have a Prefix *Prefix // Command is which command is being called. Command string // Params are all the arguments for the command. Params []string }
Message represents a line parsed from the server
func MustParseMessage ¶
MustParseMessage calls ParseMessage and either returns the message or panics if an error is returned.
func ParseMessage ¶
ParseMessage takes a message string (usually a whole line) and parses it into a Message struct. This will return nil in the case of invalid messages.
type Prefix ¶
type Prefix struct { // Name will contain the nick of who sent the message, the // server who sent the message, or a blank string Name string // User will either contain the user who sent the message or a blank string User string // Host will either contain the host of who sent the message or a blank string Host string }
Prefix represents the prefix of a message, generally the user who sent it
func ParsePrefix ¶
ParsePrefix takes an identity string and parses it into an identity struct. It will always return an Prefix struct and never nil.
type Reader ¶
type Reader struct { // DebugCallback is called for each incoming message. The name of this may // not be stable. DebugCallback func(string) // contains filtered or unexported fields }
Reader is the incoming side of a connection. The data will be buffered, so do not re-use the io.Reader used to create the irc.Reader.
func NewReader ¶
NewReader creates an irc.Reader from an io.Reader. Note that once a reader is passed into this function, you should no longer use it as it is being used inside a bufio.Reader so you cannot rely on only the amount of data for a Message being read when you call ReadMessage.
func (*Reader) ReadMessage ¶
ReadMessage returns the next message from the stream or an error.
type TagValue ¶
type TagValue string
TagValue represents the value of a tag.
func ParseTagValue ¶
ParseTagValue parses a TagValue from the connection. If you need to set a TagValue, you probably want to just set the string itself, so it will be encoded properly.
type Tags ¶
Tags represents the IRCv3 message tags.
func ParseTags ¶
ParseTags takes a tag string and parses it into a tag map. It will always return a tag map, even if there are no valid tags.
type Writer ¶
type Writer struct { // DebugCallback is called for each outgoing message. The name of this may // not be stable. DebugCallback func(line string) // contains filtered or unexported fields }
Writer is the outgoing side of a connection.
func (*Writer) Write ¶
Write is a simple function which will write the given line to the underlying connection.
func (*Writer) WriteMessage ¶
WriteMessage writes the given message to the stream