Added more test utilities for client_test.go, added NAMES and MODE handling for channels

This commit is contained in:
2018-06-25 10:58:14 +02:00
parent 65e4385b71
commit 6256f6a6fe
6 changed files with 237 additions and 50 deletions
+24
View File
@@ -218,6 +218,30 @@ func (isupport *ISupport) IsPermissionMode(flag rune) bool {
return strings.ContainsRune(isupport.modeOrder, flag)
}
// ModeTakesArgument returns true if the mode takes an argument
func (isupport *ISupport) ModeTakesArgument(flag rune, plus bool) bool {
isupport.lock.RLock()
defer isupport.lock.RUnlock()
// Permission modes always take an argument.
if strings.ContainsRune(isupport.modeOrder, flag) {
return true
}
// Modes in category A and B always takes an argument
if strings.ContainsRune(isupport.chanModes[0], flag) || strings.ContainsRune(isupport.chanModes[1], flag) {
return true
}
// Modes in category C only takes one when added
if plus && strings.ContainsRune(isupport.chanModes[1], flag) {
return true
}
// Modes in category D and outside never does
return false
}
// ChannelModeType returns a number from 0 to 3 based on what block of mode
// in the CHANMODES variable it fits into. If it's not found at all, it will
// return -1