Documentation ¶
Overview ¶
Package irc provides fast IRC support.
Index ¶
- Variables
- func EncodeCTCP(command, args string) (string, error)
- func ParseCTCP(s string) (command, args string, ok bool)
- type BaseConn
- type Conn
- type Decoder
- type Encoder
- type Message
- func (m *Message) Bytes() []byte
- func (m *Message) Len() int
- func (m *Message) MarshalText() (text []byte, err error)
- func (m *Message) Parse(raw string) error
- func (m *Message) String() string
- func (m *Message) UnmarshalText(text []byte) error
- func (m *Message) WriteToWithNewline(w io.Writer) (n int64, err error)
- type ParseError
- type Prefix
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyMessage is returned when the parser encounters an empty message. ErrEmptyMessage = &ParseError{"empty message"} // ErrInvalidMessage is returned when the parser encounters an invalid message. // This error is likely to be replaced with a more helpful error (encoding something // like where the error occurred). ErrInvalidMessage = &ParseError{"invalid message"} )
var ErrCTCPEmptyCommand = errors.New("empty ctcp command")
ErrCTCPEmptyCommand is returned by EncodeCTCP when the command is empty.
Functions ¶
func EncodeCTCP ¶
EncodeCTCP encodes a command and its arguments into a string.
Types ¶
type BaseConn ¶
type BaseConn struct {
// contains filtered or unexported fields
}
BaseConn is a simple IRC connection.
func BaseDial ¶
BaseDial is shorthand for calling net.Dial("tcp", addr) and calling NewBaseConn on the returned net.Conn.
func NewBaseConn ¶
NewBaseConn creates a new BaseConn from a net.Conn.
type Decoder ¶
Decoder decodes a message into the provided Message struct. Decode must set every field of the message struct.
type Message ¶
type Message struct { Tags map[string]string Prefix Prefix Command string Params []string Trailing string ForcedTags bool ForcedTrailing bool // Raw contains the raw unparsed message. This is not used for encoding, // and is included for users which want the exact original message. // Including this incurs no extra overhead, since the other parts of the // message are references to parts of this string, meaning that the // lifetime of this string is just as long as the message as a whole. Raw string }
Message is an IRC message.
func ParseMessage ¶
ParseMessage parses a string and returns a new Message. A string is used as the input, as it was found that they're more performant than using a byte slice, even with an extra initial copy.
ParseMessage does not check the input for newlines, which are normally invalid.
func (*Message) Bytes ¶
Bytes returns the message encoded as a byte slice. This slice is safe for reuse.
func (*Message) Len ¶
Len returns the length of the encoded message. This message does not actually encode the message, instead simulating encoding and only calculates the length.
func (*Message) MarshalText ¶
MarshalText implements TextMarshaler for Message.
func (*Message) Parse ¶
Parse parses a string into a message. All fields of the message struct will be set (default as needed), so there is no need to zero before parsing.
Parse does not check the input for newlines, which are normally invalid.
func (*Message) UnmarshalText ¶
UnmarshalText implements TextUnmarshaler for Message.
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is returned when parsing a message. It's useful for distinguishing parse errors from network errors when using Conn.Encode.
func (ParseError) Error ¶
func (p ParseError) Error() string