2018-02-03 11:21:32 +01:00
|
|
|
// Copyright (c) 2012-2014 Jeremy Latt
|
|
|
|
// Copyright (c) 2014-2015 Edmund Huber
|
|
|
|
// Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
|
|
|
|
// released under the MIT license
|
|
|
|
|
|
|
|
package modes
|
|
|
|
|
|
|
|
import (
|
2020-10-21 03:24:47 +02:00
|
|
|
"fmt"
|
2020-05-28 20:27:41 +02:00
|
|
|
"sort"
|
2018-02-03 11:21:32 +01:00
|
|
|
"strings"
|
2018-06-26 00:08:15 +02:00
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
"github.com/ergochat/ergo/irc/utils"
|
2018-02-03 11:21:32 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// SupportedUserModes are the user modes that we actually support (modifying).
|
|
|
|
SupportedUserModes = Modes{
|
2019-04-28 21:10:03 +02:00
|
|
|
Bot, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying,
|
2020-10-02 01:21:42 +02:00
|
|
|
UserNoCTCP,
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// SupportedChannelModes are the channel modes that we support.
|
|
|
|
SupportedChannelModes = Modes{
|
|
|
|
BanMask, ChanRoleplaying, ExceptMask, InviteMask, InviteOnly, Key,
|
2020-09-19 20:01:58 +02:00
|
|
|
Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, RegisteredOnlySpeak,
|
2020-12-14 11:00:21 +01:00
|
|
|
Secret, UserLimit, NoCTCP, Auditorium, OpModerated, Forward,
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// ModeOp is an operation performed with modes
|
|
|
|
type ModeOp rune
|
|
|
|
|
|
|
|
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 = '-'
|
|
|
|
)
|
|
|
|
|
|
|
|
// Mode represents a user/channel/server mode
|
|
|
|
type Mode rune
|
|
|
|
|
|
|
|
func (mode Mode) String() string {
|
|
|
|
return string(mode)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModeChange is a single mode changing
|
|
|
|
type ModeChange struct {
|
|
|
|
Mode Mode
|
|
|
|
Op ModeOp
|
|
|
|
Arg string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModeChanges are a collection of 'ModeChange's
|
|
|
|
type ModeChanges []ModeChange
|
|
|
|
|
2020-03-25 17:08:08 +01:00
|
|
|
func (changes ModeChanges) Strings() (result []string) {
|
2018-02-03 11:21:32 +01:00
|
|
|
if len(changes) == 0 {
|
2020-03-25 17:08:08 +01:00
|
|
|
return
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
2020-03-25 17:08:08 +01:00
|
|
|
var builder strings.Builder
|
|
|
|
|
2018-02-03 11:21:32 +01:00
|
|
|
op := changes[0].Op
|
2020-03-25 17:08:08 +01:00
|
|
|
builder.WriteRune(rune(op))
|
2018-02-03 11:21:32 +01:00
|
|
|
|
|
|
|
for _, change := range changes {
|
|
|
|
if change.Op != op {
|
|
|
|
op = change.Op
|
2020-03-25 17:08:08 +01:00
|
|
|
builder.WriteRune(rune(op))
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
2020-03-25 17:08:08 +01:00
|
|
|
builder.WriteRune(rune(change.Mode))
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
2020-03-25 17:08:08 +01:00
|
|
|
result = append(result, builder.String())
|
|
|
|
|
2018-02-03 11:21:32 +01:00
|
|
|
for _, change := range changes {
|
|
|
|
if change.Arg == "" {
|
|
|
|
continue
|
|
|
|
}
|
2020-03-25 17:08:08 +01:00
|
|
|
result = append(result, change.Arg)
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
2020-03-25 17:08:08 +01:00
|
|
|
return
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modes is just a raw list of modes
|
|
|
|
type Modes []Mode
|
|
|
|
|
|
|
|
func (modes Modes) String() string {
|
2020-10-12 21:06:17 +02:00
|
|
|
var builder strings.Builder
|
|
|
|
for _, m := range modes {
|
|
|
|
builder.WriteRune(rune(m))
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
2020-10-12 21:06:17 +02:00
|
|
|
return builder.String()
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// User Modes
|
|
|
|
const (
|
|
|
|
Bot Mode = 'B'
|
|
|
|
Invisible Mode = 'i'
|
|
|
|
Operator Mode = 'o'
|
|
|
|
Restricted Mode = 'r'
|
|
|
|
RegisteredOnly Mode = 'R'
|
|
|
|
ServerNotice Mode = 's'
|
|
|
|
TLS Mode = 'Z'
|
2020-06-08 20:43:58 +02:00
|
|
|
UserNoCTCP Mode = 'T'
|
2018-02-03 11:21:32 +01:00
|
|
|
UserRoleplaying Mode = 'E'
|
|
|
|
WallOps Mode = 'w'
|
|
|
|
)
|
|
|
|
|
|
|
|
// Channel Modes
|
|
|
|
const (
|
2020-10-02 14:13:52 +02:00
|
|
|
Auditorium Mode = 'u' // flag
|
2018-02-03 11:21:32 +01:00
|
|
|
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
|
2020-09-19 20:01:58 +02:00
|
|
|
RegisteredOnlySpeak Mode = 'M' // flag
|
|
|
|
Secret Mode = 's' // flag
|
|
|
|
UserLimit Mode = 'l' // flag arg
|
|
|
|
NoCTCP Mode = 'C' // flag
|
2020-10-20 19:37:38 +02:00
|
|
|
OpModerated Mode = 'U' // flag
|
2020-12-14 11:00:21 +01:00
|
|
|
Forward Mode = 'f' // flag arg
|
2018-02-03 11:21:32 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ChannelFounder Mode = 'q' // arg
|
|
|
|
ChannelAdmin Mode = 'a' // arg
|
|
|
|
ChannelOperator Mode = 'o' // arg
|
|
|
|
Halfop Mode = 'h' // arg
|
|
|
|
Voice Mode = 'v' // arg
|
|
|
|
|
2018-05-23 21:35:50 +02:00
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
|
2018-02-03 11:21:32 +01:00
|
|
|
ChannelModePrefixes = map[Mode]string{
|
|
|
|
ChannelFounder: "~",
|
|
|
|
ChannelAdmin: "&",
|
|
|
|
ChannelOperator: "@",
|
|
|
|
Halfop: "%",
|
|
|
|
Voice: "+",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
//
|
|
|
|
// channel membership prefixes
|
|
|
|
//
|
|
|
|
|
|
|
|
// SplitChannelMembershipPrefixes takes a target and returns the prefixes on it, then the name.
|
|
|
|
func SplitChannelMembershipPrefixes(target string) (prefixes string, name string) {
|
|
|
|
name = target
|
2019-04-23 06:05:12 +02:00
|
|
|
for i := 0; i < len(name); i++ {
|
|
|
|
switch name[i] {
|
|
|
|
case '~', '&', '@', '%', '+':
|
|
|
|
prefixes = target[:i+1]
|
|
|
|
name = target[i+1:]
|
|
|
|
default:
|
2019-05-10 07:44:14 +02:00
|
|
|
return
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 06:05:12 +02:00
|
|
|
return
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetLowestChannelModePrefix returns the lowest channel prefix mode out of the given prefixes.
|
2019-04-23 06:05:12 +02:00
|
|
|
func GetLowestChannelModePrefix(prefixes string) (lowest Mode) {
|
2018-05-23 21:35:50 +02:00
|
|
|
for i, mode := range ChannelUserModes {
|
|
|
|
if strings.Contains(prefixes, ChannelModePrefixes[mode]) {
|
2019-04-23 06:05:12 +02:00
|
|
|
lowest = ChannelUserModes[i]
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-23 21:35:50 +02:00
|
|
|
return
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// commands
|
|
|
|
//
|
|
|
|
|
|
|
|
// ParseUserModeChanges returns the valid changes, and the list of unknown chars.
|
|
|
|
func ParseUserModeChanges(params ...string) (ModeChanges, map[rune]bool) {
|
|
|
|
changes := make(ModeChanges, 0)
|
|
|
|
unknown := make(map[rune]bool)
|
|
|
|
|
|
|
|
op := List
|
|
|
|
|
|
|
|
if 0 < len(params) {
|
|
|
|
modeArg := params[0]
|
|
|
|
skipArgs := 1
|
|
|
|
|
|
|
|
for _, mode := range modeArg {
|
|
|
|
if mode == '-' || mode == '+' {
|
|
|
|
op = ModeOp(mode)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
change := ModeChange{
|
|
|
|
Mode: Mode(mode),
|
|
|
|
Op: op,
|
|
|
|
}
|
|
|
|
|
|
|
|
// put arg into modechange if needed
|
|
|
|
switch Mode(mode) {
|
|
|
|
case ServerNotice:
|
2021-02-08 17:43:13 +01:00
|
|
|
// arg is optional for ServerNotice (we accept bare `-s`)
|
2018-02-03 11:21:32 +01:00
|
|
|
if len(params) > skipArgs {
|
|
|
|
change.Arg = params[skipArgs]
|
|
|
|
skipArgs++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isKnown bool
|
|
|
|
for _, supportedMode := range SupportedUserModes {
|
|
|
|
if rune(supportedMode) == mode {
|
|
|
|
isKnown = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !isKnown {
|
|
|
|
unknown[mode] = true
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
changes = append(changes, change)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return changes, unknown
|
|
|
|
}
|
|
|
|
|
2018-04-23 00:47:10 +02:00
|
|
|
// ParseChannelModeChanges returns the valid changes, and the list of unknown chars.
|
|
|
|
func ParseChannelModeChanges(params ...string) (ModeChanges, map[rune]bool) {
|
|
|
|
changes := make(ModeChanges, 0)
|
|
|
|
unknown := make(map[rune]bool)
|
|
|
|
|
|
|
|
op := List
|
|
|
|
|
|
|
|
if 0 < len(params) {
|
|
|
|
modeArg := params[0]
|
|
|
|
skipArgs := 1
|
|
|
|
|
|
|
|
for _, mode := range modeArg {
|
|
|
|
if mode == '-' || mode == '+' {
|
|
|
|
op = ModeOp(mode)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
change := ModeChange{
|
|
|
|
Mode: Mode(mode),
|
|
|
|
Op: op,
|
|
|
|
}
|
|
|
|
|
|
|
|
// put arg into modechange if needed
|
|
|
|
switch Mode(mode) {
|
|
|
|
case BanMask, ExceptMask, InviteMask:
|
|
|
|
if len(params) > skipArgs {
|
|
|
|
change.Arg = params[skipArgs]
|
|
|
|
skipArgs++
|
|
|
|
} else {
|
|
|
|
change.Op = List
|
|
|
|
}
|
|
|
|
case ChannelFounder, ChannelAdmin, ChannelOperator, Halfop, Voice:
|
|
|
|
if len(params) > skipArgs {
|
|
|
|
change.Arg = params[skipArgs]
|
|
|
|
skipArgs++
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
2020-12-14 11:00:21 +01:00
|
|
|
case UserLimit, Forward:
|
2018-04-23 00:47:10 +02:00
|
|
|
// don't require value when removing
|
|
|
|
if change.Op == Add {
|
|
|
|
if len(params) > skipArgs {
|
|
|
|
change.Arg = params[skipArgs]
|
|
|
|
skipArgs++
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
2020-03-20 13:11:12 +01:00
|
|
|
case Key:
|
|
|
|
// #874: +k is technically a type B mode, requiring a parameter
|
|
|
|
// both for add and remove. so attempt to consume a parameter,
|
|
|
|
// but allow remove (but not add) even if no parameter is available.
|
|
|
|
// however, the remove parameter should always display as "*", matching
|
|
|
|
// the freenode behavior.
|
|
|
|
if len(params) > skipArgs {
|
|
|
|
if change.Op == Add {
|
|
|
|
change.Arg = params[skipArgs]
|
|
|
|
}
|
|
|
|
skipArgs++
|
|
|
|
} else if change.Op == Add {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if change.Op == Remove {
|
|
|
|
change.Arg = "*"
|
|
|
|
}
|
2018-04-23 00:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var isKnown bool
|
|
|
|
for _, supportedMode := range SupportedChannelModes {
|
|
|
|
if rune(supportedMode) == mode {
|
|
|
|
isKnown = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2018-05-23 21:35:50 +02:00
|
|
|
for _, supportedMode := range ChannelUserModes {
|
2018-04-23 00:47:10 +02:00
|
|
|
if rune(supportedMode) == mode {
|
|
|
|
isKnown = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !isKnown {
|
|
|
|
unknown[mode] = true
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
changes = append(changes, change)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return changes, unknown
|
|
|
|
}
|
|
|
|
|
2018-02-03 11:21:32 +01:00
|
|
|
// ModeSet holds a set of modes.
|
2019-05-27 21:17:28 +02:00
|
|
|
type ModeSet [2]uint32
|
2018-06-26 00:08:15 +02:00
|
|
|
|
|
|
|
// valid modes go from 65 ('A') to 122 ('z'), making at most 58 possible values;
|
2019-05-27 21:17:28 +02:00
|
|
|
// subtract 65 from the mode value and use that bit of the uint32 to represent it
|
2018-06-26 00:08:15 +02:00
|
|
|
const (
|
2019-05-27 21:17:28 +02:00
|
|
|
minMode = 65 // 'A'
|
|
|
|
maxMode = 122 // 'z'
|
2018-06-26 00:08:15 +02:00
|
|
|
)
|
2018-04-23 00:47:10 +02:00
|
|
|
|
|
|
|
// returns a pointer to a new ModeSet
|
|
|
|
func NewModeSet() *ModeSet {
|
2018-06-26 00:08:15 +02:00
|
|
|
var set ModeSet
|
|
|
|
return &set
|
2018-04-23 00:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// test whether `mode` is set
|
|
|
|
func (set *ModeSet) HasMode(mode Mode) bool {
|
2018-08-23 16:30:28 +02:00
|
|
|
if set == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-06-26 00:08:15 +02:00
|
|
|
return utils.BitsetGet(set[:], uint(mode)-minMode)
|
2018-04-23 00:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set `mode` to be on or off, return whether the value actually changed
|
|
|
|
func (set *ModeSet) SetMode(mode Mode, on bool) (applied bool) {
|
2018-06-26 00:08:15 +02:00
|
|
|
return utils.BitsetSet(set[:], uint(mode)-minMode, on)
|
2018-04-23 00:47:10 +02:00
|
|
|
}
|
|
|
|
|
2018-11-26 11:23:27 +01:00
|
|
|
// copy the contents of another modeset on top of this one
|
|
|
|
func (set *ModeSet) Copy(other *ModeSet) {
|
|
|
|
utils.BitsetCopy(set[:], other[:])
|
|
|
|
}
|
|
|
|
|
2018-04-23 00:47:10 +02:00
|
|
|
// return the modes in the set as a slice
|
|
|
|
func (set *ModeSet) AllModes() (result []Mode) {
|
2018-05-23 21:39:30 +02:00
|
|
|
if set == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-05-27 21:17:28 +02:00
|
|
|
var i Mode
|
|
|
|
for i = minMode; i <= maxMode; i++ {
|
|
|
|
if set.HasMode(i) {
|
|
|
|
result = append(result, i)
|
2018-06-26 00:08:15 +02:00
|
|
|
}
|
2018-04-23 00:47:10 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-02-03 11:21:32 +01:00
|
|
|
|
|
|
|
// String returns the modes in this set.
|
2018-05-23 21:39:30 +02:00
|
|
|
func (set *ModeSet) String() (result string) {
|
|
|
|
if set == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var buf strings.Builder
|
2018-06-26 00:08:15 +02:00
|
|
|
for _, mode := range set.AllModes() {
|
2018-05-23 21:39:30 +02:00
|
|
|
buf.WriteRune(rune(mode))
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
2018-05-23 21:39:30 +02:00
|
|
|
return buf.String()
|
2018-02-03 11:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prefixes returns a list of prefixes for the given set of channel modes.
|
2018-04-23 00:47:10 +02:00
|
|
|
func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
|
2018-05-23 21:39:30 +02:00
|
|
|
if set == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-02-03 11:21:32 +01:00
|
|
|
// add prefixes in order from highest to lowest privs
|
2018-05-23 21:35:50 +02:00
|
|
|
for _, mode := range ChannelUserModes {
|
2018-06-26 00:08:15 +02:00
|
|
|
if set.HasMode(mode) {
|
2018-02-03 11:21:32 +01:00
|
|
|
prefixes += ChannelModePrefixes[mode]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !isMultiPrefix && len(prefixes) > 1 {
|
|
|
|
prefixes = string(prefixes[0])
|
|
|
|
}
|
|
|
|
|
|
|
|
return prefixes
|
|
|
|
}
|
2019-04-23 06:05:12 +02:00
|
|
|
|
|
|
|
// 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 (set *ModeSet) HighestChannelUserMode() (result Mode) {
|
|
|
|
for _, mode := range ChannelUserModes {
|
|
|
|
if set.HasMode(mode) {
|
|
|
|
return mode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2020-05-28 20:27:41 +02:00
|
|
|
|
|
|
|
type ByCodepoint Modes
|
|
|
|
|
|
|
|
func (a ByCodepoint) Len() int { return len(a) }
|
|
|
|
func (a ByCodepoint) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
|
|
func (a ByCodepoint) Less(i, j int) bool { return a[i] < a[j] }
|
|
|
|
|
|
|
|
func RplMyInfo() (param1, param2, param3 string) {
|
2020-10-02 01:52:50 +02:00
|
|
|
userModes := make(Modes, len(SupportedUserModes), len(SupportedUserModes)+1)
|
2020-05-28 20:27:41 +02:00
|
|
|
copy(userModes, SupportedUserModes)
|
2020-10-02 01:52:50 +02:00
|
|
|
// TLS is not in SupportedUserModes because it can't be modified
|
|
|
|
userModes = append(userModes, TLS)
|
2020-05-28 20:27:41 +02:00
|
|
|
sort.Sort(ByCodepoint(userModes))
|
|
|
|
|
|
|
|
channelModes := make(Modes, len(SupportedChannelModes)+len(ChannelUserModes))
|
|
|
|
copy(channelModes, SupportedChannelModes)
|
|
|
|
copy(channelModes[len(SupportedChannelModes):], ChannelUserModes)
|
|
|
|
sort.Sort(ByCodepoint(channelModes))
|
|
|
|
|
|
|
|
// XXX enumerate these by hand, i can't see any way to DRY this
|
2020-12-14 11:00:21 +01:00
|
|
|
channelParametrizedModes := Modes{BanMask, ExceptMask, InviteMask, Key, UserLimit, Forward}
|
2020-05-28 20:27:41 +02:00
|
|
|
channelParametrizedModes = append(channelParametrizedModes, ChannelUserModes...)
|
|
|
|
sort.Sort(ByCodepoint(channelParametrizedModes))
|
|
|
|
|
|
|
|
return userModes.String(), channelModes.String(), channelParametrizedModes.String()
|
|
|
|
}
|
2020-10-21 03:24:47 +02:00
|
|
|
|
|
|
|
func ChanmodesToken() (result string) {
|
|
|
|
// https://modern.ircdocs.horse#chanmodes-parameter
|
|
|
|
// type A: listable modes with parameters
|
|
|
|
A := Modes{BanMask, ExceptMask, InviteMask}
|
|
|
|
// type B: modes with parameters
|
|
|
|
B := Modes{Key}
|
|
|
|
// type C: modes that take a parameter only when set, never when unset
|
2020-12-14 11:00:21 +01:00
|
|
|
C := Modes{UserLimit, Forward}
|
2020-10-21 03:24:47 +02:00
|
|
|
// type D: modes without parameters
|
|
|
|
D := Modes{InviteOnly, Moderated, NoOutside, OpOnlyTopic, ChanRoleplaying, Secret, NoCTCP, RegisteredOnly, RegisteredOnlySpeak, Auditorium, OpModerated}
|
|
|
|
|
|
|
|
sort.Sort(ByCodepoint(A))
|
|
|
|
sort.Sort(ByCodepoint(B))
|
|
|
|
sort.Sort(ByCodepoint(C))
|
|
|
|
sort.Sort(ByCodepoint(D))
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s,%s,%s,%s", A.String(), B.String(), C.String(), D.String())
|
|
|
|
}
|