mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
user: Don't parse the second and third params anymore
This commit is contained in:
parent
9acdeedec6
commit
fb345a2dd4
3 changed files with 8 additions and 66 deletions
|
|
@ -270,50 +270,11 @@ type UserCommand struct {
|
|||
realname Text
|
||||
}
|
||||
|
||||
// USER <username> <hostname> <servername> <realname>
|
||||
type RFC1459UserCommand struct {
|
||||
UserCommand
|
||||
hostname Name
|
||||
servername Name
|
||||
}
|
||||
|
||||
// USER <user> <mode> <unused> <realname>
|
||||
type RFC2812UserCommand struct {
|
||||
UserCommand
|
||||
mode uint8
|
||||
unused string
|
||||
}
|
||||
|
||||
func (cmd *RFC2812UserCommand) Flags() []UserMode {
|
||||
flags := make([]UserMode, 0)
|
||||
if (cmd.mode & 4) == 4 {
|
||||
flags = append(flags, WallOps)
|
||||
}
|
||||
if (cmd.mode & 8) == 8 {
|
||||
flags = append(flags, Invisible)
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
func ParseUserCommand(args []string) (Command, error) {
|
||||
mode, err := strconv.ParseUint(args[1], 10, 8)
|
||||
if err == nil {
|
||||
msg := &RFC2812UserCommand{
|
||||
mode: uint8(mode),
|
||||
unused: args[2],
|
||||
}
|
||||
msg.username = NewName(args[0])
|
||||
msg.realname = NewText(args[3])
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
msg := &RFC1459UserCommand{
|
||||
hostname: NewName(args[1]),
|
||||
servername: NewName(args[2]),
|
||||
}
|
||||
msg.username = NewName(args[0])
|
||||
msg.realname = NewText(args[3])
|
||||
return msg, nil
|
||||
return &UserCommand{
|
||||
username: NewName(args[0]),
|
||||
realname: NewText(args[3]),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// QUIT [ <Quit Command> ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue