state

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: BSD-3-Clause Imports: 5 Imported by: 79

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) Copy

func (cm *ChanMode) Copy() *ChanMode

Duplicates a ChanMode struct.

func (*ChanMode) Equals

func (cm *ChanMode) Equals(other *ChanMode) bool

Test ChanMode equality.

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) Copy

func (cp *ChanPrivs) Copy() *ChanPrivs

Duplicates a ChanPrivs struct.

func (*ChanPrivs) Equals

func (cp *ChanPrivs) Equals(other *ChanPrivs) bool

Test ChanPrivs equality.

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
	Nicks       map[string]*ChanPrivs
}

A Channel is returned from the state tracker and contains a copy of the channel state at a particular time.

func (*Channel) Equals

func (ch *Channel) Equals(other *Channel) bool

Test Channel equality.

func (*Channel) IsOn

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

Returns true if the Nick is associated with the 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 MockTracker

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

Mock of Tracker interface

func NewMockTracker

func NewMockTracker(ctrl *gomock.Controller) *MockTracker

func (*MockTracker) Associate

func (_m *MockTracker) Associate(channel string, nick string) *ChanPrivs

func (*MockTracker) ChannelModes

func (_m *MockTracker) ChannelModes(channel string, modestr string, modeargs ...string) *Channel

func (*MockTracker) DelChannel

func (_m *MockTracker) DelChannel(channel string) *Channel

func (*MockTracker) DelNick

func (_m *MockTracker) DelNick(nick string) *Nick

func (*MockTracker) Dissociate

func (_m *MockTracker) Dissociate(channel string, nick string)

func (*MockTracker) EXPECT

func (_m *MockTracker) EXPECT() *_MockTrackerRecorder

func (*MockTracker) GetChannel

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

func (*MockTracker) GetNick

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

func (*MockTracker) IsOn

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

func (*MockTracker) Me

func (_m *MockTracker) Me() *Nick

func (*MockTracker) NewChannel

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

func (*MockTracker) NewNick

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

func (*MockTracker) NickInfo

func (_m *MockTracker) NickInfo(nick string, ident string, host string, name string) *Nick

func (*MockTracker) NickModes

func (_m *MockTracker) NickModes(nick string, modestr string) *Nick

func (*MockTracker) ReNick

func (_m *MockTracker) ReNick(old string, neu string) *Nick

func (*MockTracker) String

func (_m *MockTracker) String() string

func (*MockTracker) Topic

func (_m *MockTracker) Topic(channel string, topic string) *Channel

func (*MockTracker) Wipe

func (_m *MockTracker) Wipe()

type Nick

type Nick struct {
	Nick, Ident, Host, Name string
	Modes                   *NickMode
	Channels                map[string]*ChanPrivs
}

A Nick is returned from the state tracker and contains a copy of the nick state at a particular time.

func (*Nick) Equals

func (nk *Nick) Equals(other *Nick) bool

Tests Nick equality.

func (*Nick) IsOn

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

Returns true if the Nick is associated with the Channel.

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) Copy

func (nm *NickMode) Copy() *NickMode

Duplicates a NickMode struct.

func (*NickMode) Equals

func (nm *NickMode) Equals(other *NickMode) bool

Tests NickMode equality.

func (*NickMode) String

func (nm *NickMode) String() string

Returns a string representing the nick modes. Looks like:

+iwx

type Tracker

type Tracker interface {
	// Nick methods
	NewNick(nick string) *Nick
	GetNick(nick string) *Nick
	ReNick(old, neu string) *Nick
	DelNick(nick string) *Nick
	NickInfo(nick, ident, host, name string) *Nick
	NickModes(nick, modestr string) *Nick
	// Channel methods
	NewChannel(channel string) *Channel
	GetChannel(channel string) *Channel
	DelChannel(channel string) *Channel
	Topic(channel, topic string) *Channel
	ChannelModes(channel, modestr string, modeargs ...string) *Channel
	// Information about ME!
	Me() *Nick
	// And the tracking operations
	IsOn(channel, nick string) (*ChanPrivs, bool)
	Associate(channel, nick string) *ChanPrivs
	Dissociate(channel, nick string)
	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