3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00

add +u and +U to CHANMODES token

This commit is contained in:
Shivaram Lingamneni 2020-10-20 21:24:47 -04:00
parent f019f62167
commit a30e369225
5 changed files with 45 additions and 1 deletions

View File

@ -184,3 +184,14 @@ We also support grabbing translations directly from CrowdIn. To do this:
4. Run `crowdin download`
This will download a bunch of updated files and put them in the right place
## Adding a mode
When adding a mode, keep in mind the following places it may need to be referenced:
1. The mode needs to be defined in the `irc/modes` subpackage
1. It may need to be special-cased in `modes.RplMyInfo()`
1. It may need to be added to the `CHANMODES` ISUPPORT token
1. It may need special handling in `ApplyUserModeChanges` or `ApplyChannelModeChanges`
1. It may need special persistence handling code

View File

@ -1287,7 +1287,7 @@ func (config *Config) generateISupport() (err error) {
isupport.Add("BOT", "B")
isupport.Add("CASEMAPPING", "ascii")
isupport.Add("CHANLIMIT", fmt.Sprintf("%s:%d", chanTypes, config.Channels.MaxChannelsPerClient))
isupport.Add("CHANMODES", strings.Join([]string{modes.Modes{modes.BanMask, modes.ExceptMask, modes.InviteMask}.String(), modes.Modes{modes.Key}.String(), modes.Modes{modes.UserLimit}.String(), modes.Modes{modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.ChanRoleplaying, modes.Secret, modes.NoCTCP, modes.RegisteredOnly, modes.RegisteredOnlySpeak}.String()}, ","))
isupport.Add("CHANMODES", chanmodesToken)
if config.History.Enabled && config.History.ChathistoryMax > 0 {
isupport.Add("draft/CHATHISTORY", strconv.Itoa(config.History.ChathistoryMax))
}

View File

@ -6,6 +6,7 @@
package modes
import (
"fmt"
"sort"
"strings"
@ -450,3 +451,22 @@ func RplMyInfo() (param1, param2, param3 string) {
return userModes.String(), channelModes.String(), channelParametrizedModes.String()
}
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
C := Modes{UserLimit}
// 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())
}

View File

@ -5,6 +5,7 @@ package modes
import (
"reflect"
"strings"
"testing"
)
@ -219,6 +220,15 @@ func TestHighestChannelUserMode(t *testing.T) {
}
}
func TestChanmodesToken(t *testing.T) {
tok := ChanmodesToken()
for _, mode := range SupportedChannelModes {
if strings.IndexRune(tok, rune(mode)) == -1 {
t.Errorf("+%s not included in ChanmodesToken()", mode)
}
}
}
func TestModeChangesString(t *testing.T) {
m := ModeChanges{
ModeChange{Op: Add, Mode: RegisteredOnly},

View File

@ -39,6 +39,9 @@ var (
// three final parameters of 004 RPL_MYINFO, enumerating our supported modes
rplMyInfo1, rplMyInfo2, rplMyInfo3 = modes.RplMyInfo()
// CHANMODES isupport token
chanmodesToken = modes.ChanmodesToken()
// whitelist of caps to serve on the STS-only listener. In particular,
// never advertise SASL, to discourage people from sending their passwords:
stsOnlyCaps = caps.NewSet(caps.STS, caps.MessageTags, caps.ServerTime, caps.Batch, caps.LabeledResponse, caps.EchoMessage, caps.Nope)