state

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2014 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChanModeToString = map[string]string{
	"Private":        "p",
	"Secret":         "s",
	"ProtectedTopic": "t",
	"NoExternalMsg":  "n",
	"Moderated":      "m",
	"InviteOnly":     "i",
	"OperOnly":       "O",
	"SSLOnly":        "z",
	"Registered":     "r",
	"AllSSL":         "Z",
	"Key":            "k",
	"Limit":          "l",
}
View Source
var ChanPrivToModeChar = map[string]byte{
	"Owner":  '~',
	"Admin":  '&',
	"Op":     '@',
	"HalfOp": '%',
	"Voice":  '+',
}
View Source
var ChanPrivToString = map[string]string{
	"Owner":  "q",
	"Admin":  "a",
	"Op":     "o",
	"HalfOp": "h",
	"Voice":  "v",
}
View Source
var ModeCharToChanPriv = map[byte]string{}

Map *irc.ChanPrivs fields to the symbols used to represent these modes in NAMES and WHOIS responses

View Source
var NickModeToString = map[string]string{
	"Bot":        "B",
	"Invisible":  "i",
	"Oper":       "o",
	"WallOps":    "w",
	"HiddenHost": "x",
	"SSL":        "z",
}
View Source
var StringToChanMode = map[string]string{}

Map ChanMode fields to IRC mode characters

View Source
var StringToChanPriv = map[string]string{}

Map *irc.ChanPrivs fields to IRC mode characters

View Source
var StringToNickMode = map[string]string{}

Map *irc.NickMode fields to IRC mode characters and vice versa

Functions

func NewTracker

func NewTracker(mynick string) *stateTracker

... and a constructor to make it ...

Types

type ChanMode

type ChanMode struct {
	// MODE +p, +s, +t, +n, +m
	Private, Secret, ProtectedTopic, NoExternalMsg, Moderated bool

	// MODE +i, +O, +z
	InviteOnly, OperOnly, SSLOnly bool

	// MODE +r, +Z
	Registered, AllSSL bool

	// MODE +k
	Key string

	// MODE +l
	Limit int
}

A struct representing the modes of an IRC Channel (the ones we care about, at least). http://www.unrealircd.com/files/docs/unreal32docs.html#userchannelmodes

func (*ChanMode) String

func (cm *ChanMode) String() string

Returns a string representing the channel modes. Looks like:

+npk key

type ChanPrivs

type ChanPrivs struct {
	// MODE +q, +a, +o, +h, +v
	Owner, Admin, Op, HalfOp, Voice bool
}

A struct representing the modes a Nick can have on a Channel

func (*ChanPrivs) String

func (cp *ChanPrivs) String() string

Returns a string representing the channel privileges. Looks like:

+o

type Channel

type Channel struct {
	Name, Topic string
	Modes       *ChanMode
	// contains filtered or unexported fields
}

A struct representing an IRC channel

func NewChannel

func NewChannel(name string) *Channel

func (*Channel) IsOn

func (ch *Channel) IsOn(nk *Nick) (*ChanPrivs, bool)

Returns true if the Nick is associated with the Channel

func (*Channel) IsOnStr

func (ch *Channel) IsOnStr(n string) (*Nick, bool)

func (*Channel) Nicks

func (ch *Channel) Nicks() []*Nick

Nicks returns a list of *Nick that are on the channel.

func (*Channel) NicksStr

func (ch *Channel) NicksStr() []string

NicksStr returns a list of nick strings that are on the channel.

func (*Channel) ParseModes

func (ch *Channel) ParseModes(modes string, modeargs ...string)

Parses mode strings for a channel.

func (*Channel) String

func (ch *Channel) String() string

Returns a string representing the channel. Looks like:

Channel: <channel name> e.g. #moo
Topic: <channel topic> e.g. Discussing the merits of cows!
Mode: <channel modes> e.g. +nsti
Nicks:
	<nick>: <privs> e.g. CowMaster: +o
	...

type MockStateTracker

type MockStateTracker struct {
	// contains filtered or unexported fields
}

Mock of StateTracker interface

func NewMockStateTracker

func NewMockStateTracker(ctrl *gomock.Controller) *MockStateTracker

func (*MockStateTracker) Associate

func (_m *MockStateTracker) Associate(channel *Channel, nick *Nick) *ChanPrivs

func (*MockStateTracker) DelChannel

func (_m *MockStateTracker) DelChannel(channel string)

func (*MockStateTracker) DelNick

func (_m *MockStateTracker) DelNick(nick string)

func (*MockStateTracker) Dissociate

func (_m *MockStateTracker) Dissociate(channel *Channel, nick *Nick)

func (*MockStateTracker) EXPECT

func (_m *MockStateTracker) EXPECT() *_MockStateTrackerRecorder

func (*MockStateTracker) GetChannel

func (_m *MockStateTracker) GetChannel(channel string) *Channel

func (*MockStateTracker) GetNick

func (_m *MockStateTracker) GetNick(nick string) *Nick

func (*MockStateTracker) IsOn

func (_m *MockStateTracker) IsOn(channel string, nick string) (*ChanPrivs, bool)

func (*MockStateTracker) Me

func (_m *MockStateTracker) Me() *Nick

func (*MockStateTracker) NewChannel

func (_m *MockStateTracker) NewChannel(channel string) *Channel

func (*MockStateTracker) NewNick

func (_m *MockStateTracker) NewNick(nick string) *Nick

func (*MockStateTracker) ReNick

func (_m *MockStateTracker) ReNick(old string, neu string)

func (*MockStateTracker) String

func (_m *MockStateTracker) String() string

func (*MockStateTracker) Wipe

func (_m *MockStateTracker) Wipe()

type Nick

type Nick struct {
	Nick, Ident, Host, Name string
	Modes                   *NickMode
	// contains filtered or unexported fields
}

A struct representing an IRC nick

func NewNick

func NewNick(n string) *Nick

func (*Nick) Channels

func (nk *Nick) Channels() []*Channel

Channels returns a list of *Channel the nick is on.

func (*Nick) ChannelsStr

func (nk *Nick) ChannelsStr() []string

ChannelsStr returns a list of channel strings the nick is on.

func (*Nick) IsOn

func (nk *Nick) IsOn(ch *Channel) (*ChanPrivs, bool)

Returns true if the Nick is associated with the Channel.

func (*Nick) IsOnStr

func (nk *Nick) IsOnStr(c string) (*Channel, bool)

func (*Nick) ParseModes

func (nk *Nick) ParseModes(modes string)

Parse mode strings for a Nick.

func (*Nick) String

func (nk *Nick) String() string

Returns a string representing the nick. Looks like:

Nick: <nick name> e.g. CowMaster
Hostmask: <ident@host> e.g. moo@cows.org
Real Name: <real name> e.g. Steve "CowMaster" Bush
Modes: <nick modes> e.g. +z
Channels:
	<channel>: <privs> e.g. #moo: +o
	...

type NickMode

type NickMode struct {
	// MODE +B, +i, +o, +w, +x, +z
	Bot, Invisible, Oper, WallOps, HiddenHost, SSL bool
}

A struct representing the modes of an IRC Nick (User Modes) (again, only the ones we care about)

This is only really useful for me, as we can't see other people's modes without IRC operator privileges (and even then only on some IRCd's).

func (*NickMode) String

func (nm *NickMode) String() string

Returns a string representing the nick modes. Looks like:

+iwx

type StateTracker

type StateTracker interface {
	// Nick methods
	NewNick(nick string) *Nick
	GetNick(nick string) *Nick
	ReNick(old, neu string)
	DelNick(nick string)
	// Channel methods
	NewChannel(channel string) *Channel
	GetChannel(channel string) *Channel
	DelChannel(channel string)
	// Information about ME!
	Me() *Nick
	// And the tracking operations
	IsOn(channel, nick string) (*ChanPrivs, bool)
	Associate(channel *Channel, nick *Nick) *ChanPrivs
	Dissociate(channel *Channel, nick *Nick)
	Wipe()
	// The state tracker can output a debugging string
	String() string
}

The state manager interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL