implement CModes.Get()

This commit is contained in:
Liam Stanley 2017-02-08 02:18:53 -05:00
parent c164d69de5
commit de697eb4e5

View File

@ -82,6 +82,22 @@ func (c *CModes) HasMode(mode string) bool {
return false
}
// Get returns the arguments for a given mode within this session, if it
// supports args.
func (c *CModes) Get(mode string) (args string, ok bool) {
for i := 0; i < len(c.modes); i++ {
if string(c.modes[i].name) == mode {
if len(c.modes[i].args) == 0 {
return "", false
}
return c.modes[i].args, true
}
}
return "", false
}
// hasArg checks to see if the mode supports arguments. What ones support this?:
// A = Mode that adds or removes a nick or address to a list. Always has a parameter.
// B = Mode that changes a setting and always has a parameter.