Documentation ¶
Index ¶
- func IsCTCP(s string) bool
- func IsChannel(s string) bool
- type Event
- type IRC
- func (irc *IRC) Action(replyTo, message string)
- func (irc *IRC) AddEventCallback(code string, cb func(*Event)) *IRC
- func (irc *IRC) Ban(channel, nick string)
- func (irc *IRC) CTCP(replyTo, ctcp, message string)
- func (irc *IRC) Connect() error
- func (irc *IRC) Disconnect(s string)
- func (irc *IRC) Identify()
- func (irc *IRC) Invite(nick, channel string)
- func (irc *IRC) IsAdmin(u *User) bool
- func (irc *IRC) IsIgnored(u *User) bool
- func (irc *IRC) Join(channel string)
- func (irc *IRC) Kick(channel, nick, message string)
- func (irc *IRC) KickBan(channel, nick string)
- func (irc *IRC) Loop()
- func (irc *IRC) Mode(channel, mode, nick string)
- func (irc *IRC) Nick(nick string)
- func (irc *IRC) Notice(replyTo, message string)
- func (irc *IRC) ParseToEvent(raw string) (event *Event, ok bool)
- func (irc *IRC) Part(channel string)
- func (irc *IRC) PrivMsg(replyTo, message string)
- func (irc *IRC) PrivMsgf(replyTo, format string, args ...interface{})
- func (irc *IRC) Quit()
- func (irc *IRC) ReadEvent(raw string)
- func (irc *IRC) Register()
- func (irc *IRC) SendRaw(s string)
- func (irc *IRC) SendRawf(format string, args ...interface{})
- func (irc *IRC) Unban(channel, nick string)
- type State
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct { Raw string // Raw line received from the server Code string // Event code received or parsed from a CTCP message Source string // Source of the event, user or server Arguments []string // Arguments of the event User *User // If the source is a user, parse it & store it Message string // If the event is a PRIVMSG, store the message here ReplyTo string // Store the user or the channel to reply to }
Event contains the raw event received from the server along with the parsed data. The framework parses CTCP messages as event, changing the Code to the CTCP action received. In case we receive an event from a user (and not the server), we parse it and store it into the `User` variable.
type IRC ¶
type IRC struct { Server *config.Server State State Events map[string][]func(*Event) Waiter *sync.WaitGroup // contains filtered or unexported fields }
IRC is the main structure containing the connection, server, state, event callbacks, etc.
func (*IRC) Action ¶
Action sends a PRIVMSG command to the server, mimicking the "/me" in IRC clients.
func (*IRC) AddEventCallback ¶
AddEventCallback adds a callback function to the Events map on the specified reply code.
func (*IRC) Connect ¶
Connect tries to connect to the server with the address & port specified in the config. It has a 5 second timeout on the dialing.
func (*IRC) Disconnect ¶
Disconnect sends a QUIT command to the server, and closes the connection.
func (*IRC) Identify ¶
func (irc *IRC) Identify()
Identify sends the NickServ identify command to the server.
func (*IRC) Invite ¶
Invite sends an INVITE command to the server, requesting to invite <nick> to <channel>.
func (*IRC) Kick ¶
Kick sends a KICK command to the server, requesting to kick <nick> from <channel> using <message>.
func (*IRC) Loop ¶
func (irc *IRC) Loop()
Loop keeps the connection active, getting the raw text from the server. It also handles the quitting & debug logging.
func (*IRC) Mode ¶
Mode sends a MODE command to the server, requesting to set/unset mode <mode> on <nick> on <channel>.
func (*IRC) Nick ¶
Nick sends a NICK command to the server, requesting to change the current nick into <nick>.
func (*IRC) ParseToEvent ¶
ParseToEvent reads and parses a raw string to an Event struct.
func (*IRC) Quit ¶
func (irc *IRC) Quit()
Quit provides a wrapper to sending a value into the `quit` channel.
func (*IRC) ReadEvent ¶
ReadEvent reads a parsed Event, calls the callbacks defined, and adds some basic logging.
func (*IRC) Register ¶
func (irc *IRC) Register()
Register sends the USER and NICK commands to the server, and sets the registered state.
func (*IRC) SendRaw ¶
SendRaw sends a raw string back to the server, appending a CR LF. It automatically strips carriage returns and line feeds from the string.