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

add more modes to arg-having modes

This commit is contained in:
Jeremy Latt 2014-02-17 11:46:40 -08:00
parent f0fc3b492c
commit 2ecc66b9d9

View File

@ -462,18 +462,25 @@ type ChannelModeChange struct {
arg string arg string
} }
func (op *ChannelModeChange) String() string { func (change *ChannelModeChange) String() (str string) {
return fmt.Sprintf("{%s %s %s}", op.op, op.mode, op.arg) if (change.op == Add) || (change.op == Remove) {
str = change.op.String()
}
str += change.mode.String()
if change.arg != "" {
str += " " + change.arg
}
return
} }
type ChannelModeChanges []ChannelModeChange type ChannelModeChanges []ChannelModeChange
func (changes ChannelModeChanges) String() string { func (changes ChannelModeChanges) String() (str string) {
if len(changes) == 0 { if len(changes) == 0 {
return "" return
} }
str := "+" str = "+"
if changes[0].op == Remove { if changes[0].op == Remove {
str = "-" str = "-"
} }
@ -481,9 +488,12 @@ func (changes ChannelModeChanges) String() string {
str += change.mode.String() str += change.mode.String()
} }
for _, change := range changes { for _, change := range changes {
if change.arg == "" {
continue
}
str += " " + change.arg str += " " + change.arg
} }
return str return
} }
type ChannelModeCommand struct { type ChannelModeCommand struct {
@ -517,7 +527,8 @@ func NewChannelModeCommand(args []string) (editableCommand, error) {
op: op, op: op,
} }
switch change.mode { switch change.mode {
case Key, BanMask, ExceptionMask, InviteMask, UserLimit: case Key, BanMask, ExceptionMask, InviteMask, UserLimit,
ChannelOperator, ChannelCreator, Voice:
if len(args) > skipArgs { if len(args) > skipArgs {
change.arg = args[skipArgs] change.arg = args[skipArgs]
skipArgs += 1 skipArgs += 1