Documentation
¶
Overview ¶
Package irc implements basic scanning and formatting of IRC messages.
While package irc is designed for Twitch.TV IRC, it should be able to handle any valid RFC 1459 messages plus IRCv3 tags. The focus is on simplicity, universality, and performance, rather than convenience. Users should be familiar with RFC 1459.
This package does not handle IRC connections. It can parse messages from an existing IRC connection via an io.RuneScanner wrapper, such as bufio.Reader.
Index ¶
- type Malformed
- type Message
- func (m Message) Badges(v []string) []string
- func (m Message) DisplayName() string
- func (m Message) ForeachTag(f func(key, value string))
- func (m Message) Reply(format string, args ...interface{}) Message
- func (m Message) String() string
- func (m Message) Tag(name string) (val string, ok bool)
- func (m Message) Text() string
- func (m Message) To() string
- type Sender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Malformed ¶
type Malformed struct {
// contains filtered or unexported fields
}
Malformed indicates a malformed IRC message.
type Message ¶
type Message struct { // Time is the time at which the message was sent. Time time.Time // Tags is the full tags component of the received message. Use the Tag // method to get the parsed, unquoted value of a single tag. Tags string // Sender is identifying information of the user or server that sent the // message. Sender // Command is the message command or numeric response code. Command string // Params is the "middle" parameters of the message. Params []string // Trailing is the "trailing" parameter of the message. Trailing string }
Message represents a single Twitch IRC Message.
func (Message) Badges ¶
Badges appends the list of Twitch badges, parsed from the badges tag and without versions, to v and returns v.
func (Message) DisplayName ¶
DisplayName returns a display name for the message sender. If the message has a non-empty display-name tag, then this returns that; otherwise, it returns the sender's nick.
func (Message) ForeachTag ¶
ForeachTag calls f for each tag on m. Tag values are unquoted and may be the empty string.
func (Message) Reply ¶
Reply creates an appropriately-targeted response to a PRIVMSG or WHISPER. Panics if the message type is neither PRIVMSG nor WHISPER. The message is formatted according to the rules of fmt.Sprintf.
func (Message) String ¶
String formats the message as an IRC message string appropriate for sending to an IRC server, not including the ending CR LF sequence. This does not perform any validation.
func (Message) Tag ¶
Tag retrieves a tag by name. ok is false if and only if the tag is not present.
type Sender ¶
type Sender struct { // Nick is the nickname of the user who produced the message, or the // hostname of the server for messages not produced by users. Nick string // User is the username of the user who produced the message, if any. For // Twitch IRC, this is always the same as Nick if it is nonempty. User string // Host is the hostname of the user who produced the message, if any. For // Twitch IRC, this is always "tmi.twitch.tv" or "<user>.tmi.twitch.tv", // where <user> is the username of the authenticated client. Host string }
Sender is a message Sender. It may represent a user or server.