minimal whois implementation

This commit is contained in:
Jeremy Latt 2014-02-08 17:43:59 -08:00
parent 06648393a1
commit c4f457705a
5 changed files with 81 additions and 23 deletions

View file

@ -35,6 +35,7 @@ var (
"QUIT": NewQuitCommand,
"TOPIC": NewTopicCommand,
"USER": NewUserMsgCommand,
"WHOIS": NewWhoisCommand,
}
)
@ -451,3 +452,30 @@ func NewModeCommand(args []string) (EditableCommand, error) {
return cmd, nil
}
type WhoisCommand struct {
BaseCommand
target string
masks []string
}
func NewWhoisCommand(args []string) (EditableCommand, error) {
if len(args) < 1 {
return nil, NotEnoughArgsError
}
var masks string
var target string
if len(args) > 1 {
target = args[0]
masks = args[1]
} else {
masks = args[0]
}
return &WhoisCommand{
target: target,
masks: strings.Split(masks, ","),
}, nil
}