Version: v1.2.0 Latest Latest

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 2 Imported by: 0




This section is empty.


View Source
var (
	// SupportedUserModes are the user modes that we actually support (modifying).
	SupportedUserModes = Modes{
		Bot, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying,

	// SupportedChannelModes are the channel modes that we support.
	SupportedChannelModes = Modes{
		BanMask, ChanRoleplaying, ExceptMask, InviteMask, InviteOnly, Key,
		Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, Secret, UserLimit,


func SplitChannelMembershipPrefixes

func SplitChannelMembershipPrefixes(target string) (prefixes string, name string)

SplitChannelMembershipPrefixes takes a target and returns the prefixes on it, then the name.


type Mode

type Mode rune

Mode represents a user/channel/server mode

const (
	Bot             Mode = 'B'
	Invisible       Mode = 'i'
	LocalOperator   Mode = 'O'
	Operator        Mode = 'o'
	Restricted      Mode = 'r'
	RegisteredOnly  Mode = 'R'
	ServerNotice    Mode = 's'
	TLS             Mode = 'Z'
	UserRoleplaying Mode = 'E'
	WallOps         Mode = 'w'

User Modes

const (
	BanMask         Mode = 'b' // arg
	ChanRoleplaying Mode = 'E' // flag
	ExceptMask      Mode = 'e' // arg
	InviteMask      Mode = 'I' // arg
	InviteOnly      Mode = 'i' // flag
	Key             Mode = 'k' // flag arg
	Moderated       Mode = 'm' // flag
	NoOutside       Mode = 'n' // flag
	OpOnlyTopic     Mode = 't' // flag
	// RegisteredOnly mode is reused here from umode definition
	Secret    Mode = 's' // flag
	UserLimit Mode = 'l' // flag arg

Channel Modes

var (
	ChannelFounder  Mode = 'q' // arg
	ChannelAdmin    Mode = 'a' // arg
	ChannelOperator Mode = 'o' // arg
	Halfop          Mode = 'h' // arg
	Voice           Mode = 'v' // arg

	// ChannelUserModes holds the list of all modes that can be applied to a user in a channel,
	// including Voice, in descending order of precedence
	ChannelUserModes = Modes{
		ChannelFounder, ChannelAdmin, ChannelOperator, Halfop, Voice,

	ChannelModePrefixes = map[Mode]string{
		ChannelFounder:  "~",
		ChannelAdmin:    "&",
		ChannelOperator: "@",
		Halfop:          "%",
		Voice:           "+",

func GetLowestChannelModePrefix

func GetLowestChannelModePrefix(prefixes string) (lowest Mode)

GetLowestChannelModePrefix returns the lowest channel prefix mode out of the given prefixes.

func (Mode) String

func (mode Mode) String() string

type ModeChange

type ModeChange struct {
	Mode Mode
	Op   ModeOp
	Arg  string

ModeChange is a single mode changing

func (*ModeChange) String

func (change *ModeChange) String() (str string)

type ModeChanges

type ModeChanges []ModeChange

ModeChanges are a collection of 'ModeChange's

func ParseChannelModeChanges added in v0.12.0

func ParseChannelModeChanges(params ...string) (ModeChanges, map[rune]bool)

ParseChannelModeChanges returns the valid changes, and the list of unknown chars.

func ParseUserModeChanges

func ParseUserModeChanges(params ...string) (ModeChanges, map[rune]bool)

ParseUserModeChanges returns the valid changes, and the list of unknown chars.

func (ModeChanges) String

func (changes ModeChanges) String() string

type ModeOp

type ModeOp rune

ModeOp is an operation performed with modes

const (
	// Add is used when adding the given key.
	Add ModeOp = '+'
	// List is used when listing modes (for instance, listing the current bans on a channel).
	List ModeOp = '='
	// Remove is used when taking away the given key.
	Remove ModeOp = '-'

func (ModeOp) String

func (op ModeOp) String() string

type ModeSet

type ModeSet [2]uint32

ModeSet holds a set of modes.

func NewModeSet added in v0.12.0

func NewModeSet() *ModeSet

returns a pointer to a new ModeSet

func (*ModeSet) AllModes added in v0.12.0

func (set *ModeSet) AllModes() (result []Mode)

return the modes in the set as a slice

func (*ModeSet) Copy added in v1.0.0

func (set *ModeSet) Copy(other *ModeSet)

copy the contents of another modeset on top of this one

func (*ModeSet) HasMode added in v0.12.0

func (set *ModeSet) HasMode(mode Mode) bool

test whether `mode` is set

func (*ModeSet) HighestChannelUserMode added in v1.1.0

func (set *ModeSet) HighestChannelUserMode() (result Mode)

HighestChannelUserMode returns the most privileged channel-user mode (e.g., ChannelFounder, Halfop, Voice) present in the ModeSet. If no such modes are present, or `set` is nil, returns the zero mode.

func (*ModeSet) Prefixes

func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string)

Prefixes returns a list of prefixes for the given set of channel modes.

func (*ModeSet) SetMode added in v0.12.0

func (set *ModeSet) SetMode(mode Mode, on bool) (applied bool)

set `mode` to be on or off, return whether the value actually changed

func (*ModeSet) String

func (set *ModeSet) String() (result string)

String returns the modes in this set.

type Modes

type Modes []Mode

Modes is just a raw list of modes

func (Modes) String

func (modes Modes) String() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL