mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
ison command
This commit is contained in:
parent
08d9d5ab79
commit
a203a3ca16
@ -20,6 +20,7 @@ var (
|
|||||||
parseCommandFuncs = map[string]parseCommandFunc{
|
parseCommandFuncs = map[string]parseCommandFunc{
|
||||||
"AWAY": NewAwayCommand,
|
"AWAY": NewAwayCommand,
|
||||||
"CAP": NewCapCommand,
|
"CAP": NewCapCommand,
|
||||||
|
"ISON": NewIsOnCommand,
|
||||||
"JOIN": NewJoinCommand,
|
"JOIN": NewJoinCommand,
|
||||||
"MODE": NewModeCommand,
|
"MODE": NewModeCommand,
|
||||||
"NICK": NewNickCommand,
|
"NICK": NewNickCommand,
|
||||||
@ -631,3 +632,22 @@ func NewAwayCommand(args []string) (editableCommand, error) {
|
|||||||
|
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IsOnCommand struct {
|
||||||
|
BaseCommand
|
||||||
|
nicks []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *IsOnCommand) String() string {
|
||||||
|
return fmt.Sprintf("ISON(nicks=%s)", msg.nicks)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIsOnCommand(args []string) (editableCommand, error) {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return nil, NotEnoughArgsError
|
||||||
|
}
|
||||||
|
|
||||||
|
return &IsOnCommand{
|
||||||
|
nicks: args,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
@ -271,7 +271,14 @@ func RplAway(server *Server, client *Client) Reply {
|
|||||||
"%s :%s", client.nick, client.awayMessage)
|
"%s :%s", client.nick, client.awayMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RplIsOn(server *Server, nicks []string) Reply {
|
||||||
|
return NewNumericReply(server, RPL_ISON,
|
||||||
|
":%s", strings.Join(nicks, " "))
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// errors (also numeric)
|
// errors (also numeric)
|
||||||
|
//
|
||||||
|
|
||||||
func ErrAlreadyRegistered(source Identifier) Reply {
|
func ErrAlreadyRegistered(source Identifier) Reply {
|
||||||
return NewNumericReply(source, ERR_ALREADYREGISTRED,
|
return NewNumericReply(source, ERR_ALREADYREGISTRED,
|
||||||
|
@ -422,3 +422,16 @@ func (msg *AwayCommand) HandleServer(server *Server) {
|
|||||||
client.Reply(RplUnAway(server))
|
client.Reply(RplUnAway(server))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (msg *IsOnCommand) HandleServer(server *Server) {
|
||||||
|
client := msg.Client()
|
||||||
|
|
||||||
|
ison := make([]string, 0)
|
||||||
|
for _, nick := range msg.nicks {
|
||||||
|
if _, ok := server.clients[nick]; ok {
|
||||||
|
ison = append(ison, nick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Reply(RplIsOn(server, ison))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user