Documentation
¶
Overview ¶
Package state provides support for modeling the state of objects affected by IRC messages
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllChannelStates ¶
type AllChannelStates interface { State GetChannel(channelName string) *ChannelState HaveChannel(channelName string) bool DeleteChannel(channelName string) }
An AllChannelStates tracks the state of all channels we're in.
type ChannelState ¶
type ChannelState struct { Topic string // the topic for the channel, if any. // contains filtered or unexported fields }
A ChannelState tracks state for a single channel.
func NewChannelState ¶
func NewChannelState(topic string) *ChannelState
NewChannelState creates a new ChannelState with initial topic `topic` and no users present.
func (*ChannelState) AddUser ¶
func (s *ChannelState) AddUser(nick string)
func (*ChannelState) HaveUser ¶
func (s *ChannelState) HaveUser(nick string) bool
func (*ChannelState) RemoveUser ¶
func (s *ChannelState) RemoveUser(nick string)
func (*ChannelState) UpdateFromClient ¶
func (s *ChannelState) UpdateFromClient(msg *irc.Message)
func (*ChannelState) UpdateFromServer ¶
func (s *ChannelState) UpdateFromServer(msg *irc.Message)
func (*ChannelState) Users ¶
func (s *ChannelState) Users() []string
Return a slice of nicks for users in the channel
type Handshake ¶
type Handshake struct {
// contains filtered or unexported fields
}
State of the initial handshake. The handshake consist of
1. Client sends NICK and USER messages 2. Server does not reject the NICK (if so, client needs to resend) 3. Server sends welcome sequence up through the MOTD.
func (*Handshake) UpdateFromClient ¶
func (*Handshake) UpdateFromServer ¶
func (Handshake) WantsWelcome ¶
Return true if the handshake is complete on the client side, but still waiting for (some of) the server's welcome sequence.
type Session ¶
Information about the state of the connection. Note that we store one of these independently for both client and server; their views may not always align.
func (*Session) GetChannel ¶
func (s *Session) GetChannel(channelName string) *ChannelState
Get the state for channel `channelName`. If we're not already marked as in the channel, this adds the channel to our list and returns a fresh state.
func (*Session) HaveChannel ¶
Return true if we're in the channel `channelName`, false otherwise.
func (*Session) IsMe ¶
Return true if the prefix identifies the user associated with this session, false otherwise.