Documentation
¶
Index ¶
- Variables
- func AwayHandler(message *irc.Message, client *Client)
- func ChannelModeHandler(message *irc.Message, client *Client)
- func InviteHandler(message *irc.Message, client *Client)
- func IsonHandler(message *irc.Message, client *Client)
- func JoinHandler(message *irc.Message, client *Client)
- func KickHandler(message *irc.Message, client *Client)
- func LinksHandler(message *irc.Message, client *Client)
- func ListHandler(message *irc.Message, client *Client)
- func MOTDHandler(message *irc.Message, client *Client)
- func ModeHandler(message *irc.Message, client *Client)
- func NamesHandler(message *irc.Message, client *Client)
- func NickHandler(message *irc.Message, client *Client)
- func NoticeHandler(message *irc.Message, client *Client)
- func OperHandler(message *irc.Message, client *Client)
- func PartHandler(message *irc.Message, client *Client)
- func PassHandler(message *irc.Message, client *Client)
- func PingHandler(message *irc.Message, client *Client)
- func PongHandler(message *irc.Message, client *Client)
- func PrivMsgHandler(message *irc.Message, client *Client)
- func QuitHandler(message *irc.Message, client *Client)
- func SendInvite(inviter *Client, invitee *Client, channel *Channel)
- func TimeHandler(message *irc.Message, client *Client)
- func TopicHandler(message *irc.Message, client *Client)
- func UserHandler(message *irc.Message, client *Client)
- func UserModeHandler(message *irc.Message, client *Client)
- func VersionHandler(message *irc.Message, client *Client)
- func WhoHandler(message *irc.Message, client *Client)
- type BasicOperAuthMethod
- type Channel
- func (c *Channel) AddMember(client *Client)
- func (c *Channel) AddMemberMode(client *Client, mode ChannelMode)
- func (c *Channel) GetMemberCount() int
- func (c *Channel) GetMemberModes(client *Client) *ChannelModeSet
- func (c *Channel) HasMember(client *Client) bool
- func (c *Channel) Join(client *Client, key string)
- func (c *Channel) Kick(client *Client, kicked []string, message string)
- func (c *Channel) ListMessage(client *Client) (m *irc.Message)
- func (c *Channel) MemberHasMode(client *Client, mode ChannelMode) bool
- func (c *Channel) Message(client *Client, message string)
- func (c *Channel) Names(client *Client) []string
- func (c *Channel) Notice(client *Client, message string)
- func (c *Channel) Part(client *Client, message string)
- func (c *Channel) Quit(client *Client, message string)
- func (c *Channel) RemoveMember(client *Client)
- func (c *Channel) RemoveMemberMode(client *Client, mode ChannelMode)
- func (c *Channel) SendMessage(m *irc.Message)
- func (c *Channel) SendMessageToOthers(m *irc.Message, client *Client)
- func (c *Channel) TopicCommand(client *Client, topic string)
- func (c *Channel) UpdateMemberNick(client *Client, oldNick string)
- type ChannelMode
- type ChannelModeSet
- func (c *ChannelModeSet) AddBanMask(mask string)
- func (c *ChannelModeSet) AddExceptionMask(mask string)
- func (c *ChannelModeSet) AddInvitationMask(mask string)
- func (c *ChannelModeSet) AddMode(mode ChannelMode)
- func (c *ChannelModeSet) AddModeWithValue(mode ChannelMode, value interface{})
- func (c *ChannelModeSet) Copy() *ChannelModeSet
- func (c *ChannelModeSet) GetBanMasks() map[string]interface{}
- func (c *ChannelModeSet) GetExceptionMasks() map[string]interface{}
- func (c *ChannelModeSet) GetInvitationMasks() map[string]interface{}
- func (c *ChannelModeSet) GetKey() string
- func (c *ChannelModeSet) GetLimit() int
- func (c *ChannelModeSet) GetMode(mode ChannelMode) interface{}
- func (c *ChannelModeSet) HasMode(mode ChannelMode) bool
- func (c *ChannelModeSet) RemoveMode(mode ChannelMode)
- func (c *ChannelModeSet) SetKey(key string)
- func (c *ChannelModeSet) SetLimit(limit int)
- func (c *ChannelModeSet) String() string
- type Client
- func (c *Client) AddChannel(channel *Channel)
- func (c *Client) Close() error
- func (c *Client) GetChannels() map[string]*Channel
- func (c *Client) GetVisible() map[string]*Client
- func (c *Client) MOTD()
- func (c *Client) MakeOper()
- func (c *Client) Ping()
- func (c *Client) Pong()
- func (c *Client) Quit()
- func (c *Client) RemoveChannel(channel *Channel)
- func (c *Client) SendMessagetoVisible(m *irc.Message)
- func (c *Client) UpdateNick(newNick string)
- func (c *Client) Welcome()
- func (c *Client) Who()
- type CommandHandler
- type CommandHandlerFunc
- type CommandsMux
- type ModeModifier
- type OperAuthMethod
- type OperAuthMethodFunc
- type Server
- func (s *Server) AddChannel(channel *Channel)
- func (s *Server) AddClient(client *Client)
- func (s *Server) AddClientNick(client *Client)
- func (s *Server) GetChannel(channelName string) (*Channel, bool)
- func (s *Server) GetClient(addr net.Addr) *Client
- func (s *Server) GetClientByNick(nick string) (*Client, bool)
- func (s *Server) RemoveChannel(channel *Channel)
- func (s *Server) RemoveClient(client *Client)
- func (s *Server) RemoveClientNick(client *Client)
- func (s *Server) Start()
- func (s *Server) UpdateClientNick(client *Client, oldNick string)
- type ServerConfig
- type UserMode
- type UserModeSet
Constants ¶
This section is empty.
Variables ¶
var UserModes = map[UserMode]interface{}{ UserModeAway: nil, UserModeInvisible: nil, UserModeWallOps: nil, UserModeRestricted: nil, UserModeOperator: nil, UserModeLocalOperator: nil, UserModeServerNotice: nil, }
UserModes contains the supported User UserMode types
Functions ¶
func AwayHandler ¶
AwayHandler is a CommandHandler to respond to IRC AWAY commands from a client Implemented according to RFC 1459 Section 5.1 and RFC 2812 Section 4.1
func ChannelModeHandler ¶
ChannelModeHandler is a specialized CommandHandler to respond to channel IRC MODE commands from a client Implemented according to RFC 1459 Section 4.2.3.1 and RFC 2811
func InviteHandler ¶
InviteHandler is a specialized CommandHandler to respond to channel IRC INVITE commands from a client Implemented according to RFC 1459 Section 4.2.7 and RFC 2812 Section 3.2.7
func IsonHandler ¶
IsonHandler is a specialized CommandHandler to respond to channel IRC ISON commands from a client Implemented according to RFC 1459 Section 5.8 and RFC 2812 Section 4.9
func JoinHandler ¶
JoinHandler is a CommandHandler to respond to IRC JOIN commands from a client Implemented according to RFC 1459 Section 4.2.1 and RFC 2812 Section 3.2.1
func KickHandler ¶
KickHandler is a specialized CommandHandler to respond to channel IRC KICK commands from a client Implemented according to RFC 1459 Section 4.2.8 and RFC 2812 Section 3.2.8
func LinksHandler ¶
LinksHandler is a specialized CommandHandler to respond to channel IRC LINKS commands from a client Implemented according to RFC 1459 Section 4.3.3 and RFC 2812 Section 3.4.5
func ListHandler ¶
ListHandler is a specialized CommandHandler to respond to channel IRC LIST commands from a client Implemented according to RFC 1459 Section 4.2.6 and RFC 2812 Section 3.2.6
func MOTDHandler ¶
MOTDHandler is a specialized CommandHandler to respond to channel IRC MOTD commands from a client Implemented according to RFC 1459 Section 8.5 and RFC 2812 Section 3.4.1
func ModeHandler ¶
ModeHandler is a CommandHandler to respond to IRC MODE commands from a client Implemented according to RFC 1459 Section 4.2.3 and RFC 2812 Section 3.1.5 and RFC 2811
func NamesHandler ¶
NamesHandler is a specialized CommandHandler to respond to channel IRC NAMES commands from a client Implemented according to RFC 1459 Section 4.2.5 and RFC 2812 Section 3.2.5
func NickHandler ¶
NickHandler is a CommandHandler to respond to IRC NICK commands from a client Implemented according to RFC 1459 Section 4.1.2 and RFC 2812 Section 3.1.2
func NoticeHandler ¶
NoticeHandler is a CommandHandler to respond to IRC NOTICE commands from a client Implemented according to RFC 1459 Section 4.4.2 and RFC 2812 Section 3.3.2
func OperHandler ¶
OperHandler is a specialized CommandHandler to respond to channel IRC OPER commands from a client Implemented according to RFC 1459 Section 4.1.5 and RFC 2812 Section 3.1.4
func PartHandler ¶
PartHandler is a CommandHandler to respond to IRC PART commands from a client Implemented according to RFC 1459 Section 4.2.2 and RFC 2812 Section 3.2.2
func PassHandler ¶
PassHandler is a CommandHandler to respond to IRC PASS commands from a client Implemented according to RFC 1459 Section 4.1.1 and RFC 2812 Section 3.1.1
func PingHandler ¶
PingHandler is a CommandHandler to respond to IRC PING commands from a client Implemented according to RFC 1459 Section 4.6.2 and RFC 2812 Section 3.7.2
func PongHandler ¶
PongHandler is a CommandHandler to respond to IRC PONG commands from a client Implemented according to RFC 1459 Section 4.6.3 and RFC 2812 Section 3.7.3
func PrivMsgHandler ¶
PrivMsgHandler is a CommandHandler to respond to IRC PRIVMSG commands from a client Implemented according to RFC 1459 Section 4.4.1 and RFC 2812 Section 3.3.1
func QuitHandler ¶
QuitHandler is a CommandHandler to respond to IRC QUIT commands from a client Implemented according to RFC 1459 Section 4.1.6 and RFC 2812 Section 3.1.7
func SendInvite ¶
SendInvite handles sending the invite messages to both parties
func TimeHandler ¶
TimeHandler is a specialized CommandHandler to respond to channel IRC TIME commands from a client Implemented according to RFC 1459 Section 4.3.4 and RFC 2812 Section 3.4.6
func TopicHandler ¶
TopicHandler is a CommandHandler to respond to IRC TOPIC commands from a client Implemented according to RFC 1459 Section 4.2.4 and RFC 2812 Section 3.2.4
func UserHandler ¶
UserHandler is a CommandHandler to respond to IRC USER commands from a client Implemented according to RFC 1459 Section 4.1.3 and RFC 2812 Section 3.1.3
func UserModeHandler ¶
UserModeHandler is a specialized CommandHandler to respond to global or user IRC MODE commands from a client Implemented according to RFC 1459 Section 4.2.3.2 and RFC 2812 Section 3.1.5
func VersionHandler ¶
VersionHandler is a specialized CommandHandler to respond to channel IRC VERSION commands from a client Implemented according to RFC 1459 Section 4.3.1 and RFC 2812 Section 3.4.3
func WhoHandler ¶
WhoHandler is a CommandHandler to respond to IRC WHO commands from a client Implemented according to RFC 1459 Section 4.5.1 and RFC 2812 Section 3.6.1
Types ¶
type BasicOperAuthMethod ¶
type BasicOperAuthMethod struct {
// contains filtered or unexported fields
}
BasicOperAuthMethod can handle simple username password mappings for operator authentication
func NewBasicOperAuthMethod ¶
func NewBasicOperAuthMethod() *BasicOperAuthMethod
NewBasicOperAuthMethod creates and returns a new BasicOperAuthMethod
func (BasicOperAuthMethod) Add ¶
func (b BasicOperAuthMethod) Add(username, password string)
Add adds a new username and password for an acceptable operator
func (BasicOperAuthMethod) Authenticate ¶
func (b BasicOperAuthMethod) Authenticate(username string, password string, client *Client)
Authenticate locates if an operator of the given username is found, and if so checks if the password matches
func (BasicOperAuthMethod) Get ¶
func (b BasicOperAuthMethod) Get(username string) (password string, ok bool)
Get returns the password if the username was found as a valid operator, if not found, ok will be false
func (BasicOperAuthMethod) Remove ¶
func (b BasicOperAuthMethod) Remove(username string)
Remove removes an operator from being allowed to authenticate
type Channel ¶
type Channel struct {
Name string
*ChannelModeSet
Topic string
Key string
Server *Server
// contains filtered or unexported fields
}
Channel represents an IRC channel or room
func NewChannel ¶
NewChannel creates and returns a new Channel
func (*Channel) AddMemberMode ¶
func (c *Channel) AddMemberMode(client *Client, mode ChannelMode)
AddMemberMode adds a mode for the member of the channel
func (*Channel) GetMemberCount ¶
GetMemberCount returns how many users are currently on the channel
func (*Channel) GetMemberModes ¶
func (c *Channel) GetMemberModes(client *Client) *ChannelModeSet
GetMemberModes returns the Channel Modes active for a member
func (*Channel) Kick ¶
Kick provides the capability for operators to kick members out of the channel
func (*Channel) ListMessage ¶
ListMessage creates and returns the message that should be sent for an IRC LIST query
func (*Channel) MemberHasMode ¶
func (c *Channel) MemberHasMode(client *Client, mode ChannelMode) bool
MemberHasMode returns whether the given client has the requested mode
func (*Channel) Message ¶
Message is when a Private Message is directed for this channel - forward the message to each member
func (*Channel) Notice ¶
Notice is when a Notice is directed for this channel - forward the notice to each member
func (*Channel) RemoveMember ¶
RemoveMember removes a member from the channel
func (*Channel) RemoveMemberMode ¶
func (c *Channel) RemoveMemberMode(client *Client, mode ChannelMode)
RemoveMemberMode removes a mode from the member of the channel
func (*Channel) SendMessage ¶
SendMessage allows sending an IRC message to all channel members
func (*Channel) SendMessageToOthers ¶
SendMessageToOthers allows sending an IRC message to all other channel members
func (*Channel) TopicCommand ¶
TopicCommand handles querying or modifying the channels topic
func (*Channel) UpdateMemberNick ¶
UpdateMemberNick updates the listing of the client from the old nickname to what the client actually has
type ChannelMode ¶
type ChannelMode rune
ChannelMode - RFC 1459 Section 4.2.3.1 and RFC 2812 Section 3.2.3 and RFC 2811 Section 4
const ( ChannelModeCreator ChannelMode = 'O' ChannelModeOperator ChannelMode = 'o' ChannelModeVoice ChannelMode = 'v' ChannelModeAnonymous ChannelMode = 'a' ChannelModeInviteOnly ChannelMode = 'i' ChannelModeModerated ChannelMode = 'm' ChannelModeNoOutsideMessages ChannelMode = 'n' ChannelModeQuiet ChannelMode = 'q' ChannelModePrivate ChannelMode = 'p' ChannelModeSecret ChannelMode = 's' ChannelModeReOp ChannelMode = 'r' ChannelModeTopic ChannelMode = 't' ChannelModeKey ChannelMode = 'k' ChannelModeLimit ChannelMode = 'l' ChannelModeBan ChannelMode = 'b' ChannelModeExceptionMask ChannelMode = 'e' ChannelModeInvitationMask ChannelMode = 'I' )
type ChannelModeSet ¶
type ChannelModeSet struct {
// contains filtered or unexported fields
}
ChannelModeSet represents a set of active ChannelModes
func NewChannelModeSet ¶
func NewChannelModeSet() *ChannelModeSet
NewChannelModeSet creates and returns a new ChannelModeSet
func (*ChannelModeSet) AddBanMask ¶
func (c *ChannelModeSet) AddBanMask(mask string)
AddBanMask sets the channel ban mask
func (*ChannelModeSet) AddExceptionMask ¶
func (c *ChannelModeSet) AddExceptionMask(mask string)
AddExceptionMask sets the channel exception mask
func (*ChannelModeSet) AddInvitationMask ¶
func (c *ChannelModeSet) AddInvitationMask(mask string)
AddInvitationMask sets the channel invitation mask
func (*ChannelModeSet) AddMode ¶
func (c *ChannelModeSet) AddMode(mode ChannelMode)
AddMode adds a ChannelMode as active
func (*ChannelModeSet) AddModeWithValue ¶
func (c *ChannelModeSet) AddModeWithValue(mode ChannelMode, value interface{})
AddModeWithValue adds a ChannelMode as active with a value
func (*ChannelModeSet) Copy ¶
func (c *ChannelModeSet) Copy() *ChannelModeSet
Copy creates and returns a deep copy of a ChannelModeSet
func (*ChannelModeSet) GetBanMasks ¶
func (c *ChannelModeSet) GetBanMasks() map[string]interface{}
GetBanMasks gets the ban masks for the channel
func (*ChannelModeSet) GetExceptionMasks ¶
func (c *ChannelModeSet) GetExceptionMasks() map[string]interface{}
GetExceptionMasks gets the exception masks for the channel
func (*ChannelModeSet) GetInvitationMasks ¶
func (c *ChannelModeSet) GetInvitationMasks() map[string]interface{}
GetInvitationMasks gets the invitation masks for the channel
func (*ChannelModeSet) GetKey ¶
func (c *ChannelModeSet) GetKey() string
GetKey gets the key if stored in the ChannelModeSet
func (*ChannelModeSet) GetLimit ¶
func (c *ChannelModeSet) GetLimit() int
GetLimit gets the member limit for the channel
func (*ChannelModeSet) GetMode ¶
func (c *ChannelModeSet) GetMode(mode ChannelMode) interface{}
GetMode determines if the ChannelModeSet contains the given ChannelMode
func (*ChannelModeSet) HasMode ¶
func (c *ChannelModeSet) HasMode(mode ChannelMode) bool
HasMode determines if the ChannelModeSet contains the given ChannelMode
func (*ChannelModeSet) RemoveMode ¶
func (c *ChannelModeSet) RemoveMode(mode ChannelMode)
RemoveMode removes the given mode from the active set
func (*ChannelModeSet) SetKey ¶
func (c *ChannelModeSet) SetKey(key string)
SetKey sets the channel key
func (*ChannelModeSet) SetLimit ¶
func (c *ChannelModeSet) SetLimit(limit int)
SetLimit sets the channel member limit
func (*ChannelModeSet) String ¶
func (c *ChannelModeSet) String() string
String returns the ChannelModeSet formatted for the MODE queries
type Client ¶
type Client struct {
*irc.Conn
Nickname string
Name string
Host string
Username string
RealName string
Prefix *irc.Prefix
Server *Server
Authorized bool
Registered bool
AwayMessage string
*UserModeSet
// contains filtered or unexported fields
}
Client represents an IRC Client connection to the server
func (*Client) AddChannel ¶
AddChannel adds a channel to the client's active list
func (*Client) GetChannels ¶
GetChannels gets a list of channels this client is joined to
func (*Client) GetVisible ¶
GetVisible returns a map of clients visible to this client
func (*Client) MOTD ¶
func (c *Client) MOTD()
MOTD returns the Message of the Day of the server to the client
func (*Client) Quit ¶
func (c *Client) Quit()
Quit sends the IRC Quit command and closes the connection
func (*Client) RemoveChannel ¶
RemoveChannel removes a channel to the client's active list
func (*Client) SendMessagetoVisible ¶
SendMessagetoVisible sends a message to all other visible clients
func (*Client) UpdateNick ¶
UpdateNick updates the clients nicknamae to a new nickname
type CommandHandler ¶
CommandHandler allows objects implementing this interface to be registered to serve a particular IRC command
func RegisteredHandler ¶
func RegisteredHandler(h CommandHandler) CommandHandler
RegisteredHandler is a CommandHandler middleware to check that a user/client is properly registered
type CommandHandlerFunc ¶
CommandHandlerFunc is a wrapper to to use regular functions as a CommandHandler
type CommandsMux ¶
type CommandsMux struct {
// contains filtered or unexported fields
}
CommandsMux multiplexes incoming IRC commands
func NewCommandsMux ¶
func NewCommandsMux() CommandsMux
NewCommandsMux creates and returns a new CommandsMux
func (*CommandsMux) Handle ¶
func (c *CommandsMux) Handle(command string, handler CommandHandler)
Handle registers the given CommandHandler for a given IRC command
func (*CommandsMux) HandleFunc ¶
func (c *CommandsMux) HandleFunc(command string, handler CommandHandlerFunc)
HandleFunc registers the given handler function for a given IRC command
type ModeModifier ¶
type ModeModifier rune
ModeModifier - RFC 1459 Section 4.2.3 and RFC 2812 Section 3.1.5
const ( ModeModifierAdd ModeModifier = '+' ModeModifierRemove ModeModifier = '-' )
type OperAuthMethod ¶
OperAuthMethod is an interface for authenticating server level operators
type OperAuthMethodFunc ¶
OperAuthMethodFunc is a wrapper so regular functions can be an OperAuthMethod
func (OperAuthMethodFunc) Authenticate ¶
func (o OperAuthMethodFunc) Authenticate(username string, password string, conn *Client)
Authenticate attempts to authenticate a given user
type Server ¶
type Server struct {
Config ServerConfig
Prefix *irc.Prefix
CommandsMux CommandsMux
OperAuthMethod
// contains filtered or unexported fields
}
Server represents an IRC server
func NewServer ¶
func NewServer(config ServerConfig) *Server
NewServer creates and returns a new Server based on the provided config
func (*Server) AddChannel ¶
AddChannel adds an active channel
func (*Server) AddClientNick ¶
AddClientNick adds a client based on its nickname
func (*Server) GetChannel ¶
GetChannel finds and returns an active channel with a matching name if it exists
func (*Server) GetClientByNick ¶
GetClientByNick returns a client with the corresponding nickname
func (*Server) RemoveChannel ¶
RemoveChannel removes a channel from the active listing
func (*Server) RemoveClient ¶
RemoveClient removes a client
func (*Server) RemoveClientNick ¶
RemoveClientNick removes a client based on its nickname
func (*Server) UpdateClientNick ¶
UpdateClientNick updates the nickname of a client as it is stored by the server
type ServerConfig ¶
type ServerConfig struct {
Name string
MOTD string
Version string
TLSConfig *tls.Config
Addr string
Password string
}
ServerConfig contains configuration data for seeding a server
type UserModeSet ¶
type UserModeSet struct {
// contains filtered or unexported fields
}
UserModeSet provides means for storing and checking UserModes
func NewUserModeSet ¶
func NewUserModeSet() *UserModeSet
NewUserModeSet creates and returns a new UserModeSet
func (*UserModeSet) AddMode ¶
func (u *UserModeSet) AddMode(mode UserMode)
AddMode adds a mode to the UserModeSet
func (*UserModeSet) HasMode ¶
func (u *UserModeSet) HasMode(mode UserMode) bool
HasMode detects if a UserMode is contained in the UserModeSet
func (*UserModeSet) RemoveMode ¶
func (u *UserModeSet) RemoveMode(mode UserMode)
RemoveMode removes a mode from the UserModeSet
func (*UserModeSet) String ¶
func (u *UserModeSet) String() string
String formats the UserModeString to be returned for MODE queries