Documentation
¶
Index ¶
- type ChannelState
- 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 *irc.Message) bool
- func (c *Client) Run() error
- func (c *Client) RunContext(ctx context.Context) error
- type ClientConfig
- type Handler
- type HandlerFunc
- type ISupportTracker
- func (t *ISupportTracker) GetList(key string) ([]string, bool)
- func (t *ISupportTracker) GetMap(key string) (map[string]string, bool)
- func (t *ISupportTracker) GetPrefixMap() (map[rune]rune, bool)
- func (t *ISupportTracker) GetRaw(key string) (string, bool)
- func (t *ISupportTracker) Handle(msg *irc.Message) error
- func (t *ISupportTracker) IsEnabled(key string) bool
- type Tracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelState ¶
ChannelState represents the current state of a channel, including the name, topic, and all users in it.
type Client ¶
type Client struct { *irc.Conn ISupport *ISupportTracker Tracker *Tracker // contains filtered or unexported fields }
Client is a wrapper around irc.Conn which is designed to make common operations much simpler. It is safe for concurrent use.
func NewClient ¶
func NewClient(rwc io.ReadWriteCloser, 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 // If this is set to true, the ISupport value on the client struct will be // non-nil. EnableISupport bool // If this is set to true, the Tracker value on the client struct will be // non-nil. EnableTracker bool // 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 ¶
type Handler interface {
Handle(*Client, *irc.Message)
}
Handler is a simple interface meant for dispatching a message from a Client connection.
type HandlerFunc ¶
type HandlerFunc func(*Client, *irc.Message)
HandlerFunc is a simple wrapper around a function which allows it to be used as a Handler.
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(c *Client, m *irc.Message)
Handle calls f(c, m).
type ISupportTracker ¶
ISupportTracker tracks the ISUPPORT values returned by servers and provides a convenient way to access them.
From http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
005 RPL_ISUPPORT.
func NewISupportTracker ¶
func NewISupportTracker() *ISupportTracker
NewISupportTracker creates a new tracker instance with a set of sane defaults if the server is missing them.
func (*ISupportTracker) GetList ¶
func (t *ISupportTracker) GetList(key string) ([]string, bool)
GetList will check for list ISupport values.
func (*ISupportTracker) GetMap ¶
func (t *ISupportTracker) GetMap(key string) (map[string]string, bool)
GetMap will check for map ISupport values.
func (*ISupportTracker) GetPrefixMap ¶
func (t *ISupportTracker) GetPrefixMap() (map[rune]rune, bool)
GetPrefixMap gets the mapping of mode to symbol for the PREFIX value. Unfortunately, this is fairly specific, so it can only be used with PREFIX.
func (*ISupportTracker) GetRaw ¶
func (t *ISupportTracker) GetRaw(key string) (string, bool)
GetRaw will get the raw ISupport values.
func (*ISupportTracker) Handle ¶
func (t *ISupportTracker) Handle(msg *irc.Message) error
Handle needs to be called for all 005 IRC messages, but it is fine to call it with all.
func (*ISupportTracker) IsEnabled ¶
func (t *ISupportTracker) IsEnabled(key string) bool
IsEnabled will check for boolean ISupport values.
type Tracker ¶
Tracker provides a convenient interface to track users, the channels they are in, and what modes they have in those channels.
func NewTracker ¶
func NewTracker(isupport *ISupportTracker) *Tracker
NewTracker creates a new tracker instance.
func (*Tracker) GetChannel ¶
func (t *Tracker) GetChannel(name string) *ChannelState
GetChannel will look up the ChannelState for a given channel name. It will return nil if the channel is unknown.
func (*Tracker) Handle ¶
Handle needs to be called for all 001, 332, 353, JOIN, TOPIC, PART, KICK, QUIT, and NICK messages, but it is fine to call it with all. Note that this will not handle calling the underlying ISupportTracker's Handle method.
func (*Tracker) ListChannels ¶
ListChannels will list the names of all known channels.