Documentation
¶
Overview ¶
nolint
Index ¶
Constants ¶
const ( // RFC1459 RPL_TRACELINK = "200" RPL_TRACECONNECTING = "201" RPL_TRACEHANDSHAKE = "202" RPL_TRACEUNKNOWN = "203" RPL_TRACEOPERATOR = "204" RPL_TRACEUSER = "205" RPL_TRACESERVER = "206" RPL_TRACENEWTYPE = "208" RPL_STATSLINKINFO = "211" RPL_STATSCOMMANDS = "212" RPL_STATSCLINE = "213" RPL_STATSNLINE = "214" RPL_STATSILINE = "215" RPL_STATSKLINE = "216" RPL_STATSQLINE = "217" RPL_STATSYLINE = "218" RPL_ENDOFSTATS = "219" RPL_UMODEIS = "221" RPL_STATSLLINE = "241" RPL_STATSUPTIME = "242" RPL_STATSOLINE = "243" RPL_STATSHLINE = "244" RPL_LUSERCLIENT = "251" RPL_LUSEROP = "252" RPL_LUSERUNKNOWN = "253" RPL_LUSERCHANNELS = "254" RPL_LUSERME = "255" RPL_ADMINME = "256" RPL_ADMINLOC1 = "257" RPL_ADMINLOC2 = "258" RPL_ADMINEMAIL = "259" RPL_TRACELOG = "261" RPL_NONE = "300" RPL_AWAY = "301" RPL_USERHOST = "302" RPL_ISON = "303" RPL_UNAWAY = "305" RPL_NOWAWAY = "306" RPL_WHOISUSER = "311" RPL_WHOISSERVER = "312" RPL_WHOISOPERATOR = "313" RPL_WHOWASUSER = "314" RPL_ENDOFWHO = "315" RPL_WHOISIDLE = "317" RPL_ENDOFWHOIS = "318" RPL_WHOISCHANNELS = "319" RPL_LIST = "322" RPL_LISTEND = "323" RPL_CHANNELMODEIS = "324" RPL_NOTOPIC = "331" RPL_TOPIC = "332" RPL_INVITING = "341" RPL_VERSION = "351" RPL_WHOREPLY = "352" RPL_NAMREPLY = "353" RPL_LINKS = "364" RPL_ENDOFLINKS = "365" RPL_ENDOFNAMES = "366" RPL_BANLIST = "367" RPL_ENDOFBANLIST = "368" RPL_ENDOFWHOWAS = "369" RPL_INFO = "371" RPL_MOTD = "372" RPL_ENDOFINFO = "374" RPL_MOTDSTART = "375" RPL_ENDOFMOTD = "376" RPL_YOUREOPER = "381" RPL_REHASHING = "382" RPL_TIME = "391" RPL_USERSSTART = "392" RPL_USERS = "393" RPL_ENDOFUSERS = "394" RPL_NOUSERS = "395" ERR_NOSUCHNICK = "401" ERR_NOSUCHSERVER = "402" ERR_NOSUCHCHANNEL = "403" ERR_CANNOTSENDTOCHAN = "404" ERR_TOOMANYCHANNELS = "405" ERR_WASNOSUCHNICK = "406" ERR_TOOMANYTARGETS = "407" ERR_NOORIGIN = "409" ERR_NORECIPIENT = "411" ERR_NOTEXTTOSEND = "412" ERR_NOTOPLEVEL = "413" ERR_WILDTOPLEVEL = "414" ERR_UNKNOWNCOMMAND = "421" ERR_NOMOTD = "422" ERR_NOADMININFO = "423" ERR_FILEERROR = "424" ERR_NONICKNAMEGIVEN = "431" ERR_ERRONEUSNICKNAME = "432" ERR_NICKNAMEINUSE = "433" ERR_NICKCOLLISION = "436" ERR_USERNOTINCHANNEL = "441" ERR_NOTONCHANNEL = "442" ERR_USERONCHANNEL = "443" ERR_NOLOGIN = "444" ERR_SUMMONDISABLED = "445" ERR_USERSDISABLED = "446" ERR_NOTREGISTERED = "451" ERR_NEEDMOREPARAMS = "461" ERR_ALREADYREGISTERED = "462" ERR_NOPERMFORHOST = "463" ERR_PASSWDMISMATCH = "464" ERR_YOUREBANNEDCREEP = "465" ERR_KEYSET = "467" ERR_CHANNELISFULL = "471" ERR_UNKNOWNMODE = "472" ERR_INVITEONLYCHAN = "473" ERR_BANNEDFROMCHAN = "474" ERR_BADCHANNELKEY = "475" ERR_NOPRIVILEGES = "481" ERR_CHANOPRIVSNEEDED = "482" ERR_CANTKILLSERVER = "483" ERR_NOOPERHOST = "491" ERR_UMODEUNKNOWNFLAG = "501" ERR_USERSDONTMATCH = "502" // RFC1459 (Obsolete) RPL_SERVICEINFO = "231" RPL_ENDOFSERVICES = "232" RPL_SERVICE = "233" RPL_WHOISCHANOP = "316" RPL_LISTSTART = "321" RPL_SUMMONING = "342" RPL_KILLDONE = "361" RPL_CLOSING = "362" RPL_CLOSEEND = "363" RPL_INFOSTART = "373" RPL_MYPORTIS = "384" ERR_YOUWILLBEBANNED = "466" ERR_NOSERVICEHOST = "492" // RFC2812 RPL_WELCOME = "001" RPL_YOURHOST = "002" RPL_CREATED = "003" RPL_MYINFO = "004" RPL_TRACESERVICE = "207" RPL_TRACECLASS = "209" RPL_SERVLIST = "234" RPL_SERVLISTEND = "235" RPL_STATSVLINE = "240" RPL_STATSBLINE = "247" RPL_STATSDLINE = "250" RPL_TRACEEND = "262" RPL_TRYAGAIN = "263" RPL_UNIQOPIS = "325" RPL_INVITELIST = "346" RPL_ENDOFINVITELIST = "347" RPL_EXCEPTLIST = "348" RPL_ENDOFEXCEPTLIST = "349" RPL_YOURESERVICE = "383" ERR_NOSUCHSERVICE = "408" ERR_BADMASK = "415" ERR_UNAVAILRESOURCE = "437" ERR_BADCHANMASK = "476" ERR_NOCHANMODES = "477" ERR_BANLISTFULL = "478" ERR_RESTRICTED = "484" ERR_UNIQOPRIVSNEEDED = "485" // RFC2812 (Obsolete) RPL_BOUNCE = "005" RPL_TRACERECONNECT = "210" RPL_STATSPING = "246" // IRCv3 ERR_INVALIDCAPCMD = "410" // Undernet? RPL_STARTTLS = "670" ERR_STARTTLS = "691" RPL_MONONLINE = "730" // RatBox RPL_MONOFFLINE = "731" // RatBox RPL_MONLIST = "732" // RatBox RPL_ENDOFMONLIST = "733" // RatBox ERR_MONLISTFULL = "734" // RatBox RPL_WHOISKEYVALUE = "760" RPL_KEYVALUE = "761" RPL_METADATAEND = "762" ERR_METADATALIMIT = "764" ERR_TARGETINVALID = "765" ERR_NOMATCHINGKEY = "766" ERR_KEYINVALID = "767" ERR_KEYNOTSET = "768" ERR_KEYNOPERMISSION = "769" RPL_LOGGEDIN = "900" // Charybdis/Atheme, IRCv3 RPL_LOGGEDOUT = "901" // Charybdis/Atheme, IRCv3 ERR_NICKLOCKED = "902" // Charybdis/Atheme, IRCv3 RPL_SASLSUCCESS = "903" // Charybdis/Atheme, IRCv3 ERR_SASLFAIL = "904" // Charybdis/Atheme, IRCv3 ERR_SASLTOOLONG = "905" // Charybdis/Atheme, IRCv3 ERR_SASLABORTED = "906" // Charybdis/Atheme, IRCv3 ERR_SASLALREADY = "907" // Charybdis/Atheme, IRCv3 RPL_SASLMECHS = "908" // Charybdis/Atheme, IRCv3 // Other RPL_ISUPPORT = "005" )
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 ¶
func EncodeTagValue ¶
EncodeTagValue converts a raw string to the format in the connection.
func MaskToRegex ¶
MaskToRegex converts an irc mask to a go Regexp for more convenient use. This should never return an error, but we have this here just in case.
func ParseTagValue ¶
ParseTagValue parses an encoded tag value as a string. If you need to set a tag, you probably want to just set the string itself, so it will be encoded properly.
Types ¶
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. It ignores empty messages.
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) // WriteCallback is called for each outgoing message. It needs to write the // message to the connection. Note that this API is not a part of the semver // stability guarantee. WriteCallback func(w *Writer, line string) error // contains filtered or unexported fields }
Writer is the outgoing side of a connection.
func (*Writer) RawWrite ¶
RawWrite will write the given data to the underlying connection, skipping the WriteCallback. This is meant to be used by implementations of the WriteCallback to write data directly to the stream. Otherwise, it is recommended to avoid this function and use one of the other helpers. Also note that it will not append \r\n to the end of the line.
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.