mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
WHOWAS command
This commit is contained in:
parent
69cdad45ac
commit
b2055595e1
@ -54,6 +54,7 @@ var (
|
|||||||
VERSION: NewVersionCommand,
|
VERSION: NewVersionCommand,
|
||||||
WHO: NewWhoCommand,
|
WHO: NewWhoCommand,
|
||||||
WHOIS: NewWhoisCommand,
|
WHOIS: NewWhoisCommand,
|
||||||
|
WHOWAS: NewWhoWasCommand,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -968,3 +969,26 @@ func NewKillCommand(args []string) (editableCommand, error) {
|
|||||||
comment: args[1],
|
comment: args[1],
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WhoWasCommand struct {
|
||||||
|
BaseCommand
|
||||||
|
nicknames []string
|
||||||
|
count int64
|
||||||
|
target string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWhoWasCommand(args []string) (editableCommand, error) {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return nil, NotEnoughArgsError
|
||||||
|
}
|
||||||
|
cmd := &WhoWasCommand{
|
||||||
|
nicknames: strings.Split(args[0], ","),
|
||||||
|
}
|
||||||
|
if len(args) > 1 {
|
||||||
|
cmd.count, _ = strconv.ParseInt(args[1], 10, 64)
|
||||||
|
}
|
||||||
|
if len(args) > 2 {
|
||||||
|
cmd.target = args[2]
|
||||||
|
}
|
||||||
|
return cmd, nil
|
||||||
|
}
|
||||||
|
@ -61,6 +61,7 @@ const (
|
|||||||
VERSION StringCode = "VERSION"
|
VERSION StringCode = "VERSION"
|
||||||
WHO StringCode = "WHO"
|
WHO StringCode = "WHO"
|
||||||
WHOIS StringCode = "WHOIS"
|
WHOIS StringCode = "WHOIS"
|
||||||
|
WHOWAS StringCode = "WHOWAS"
|
||||||
|
|
||||||
// numeric codes
|
// numeric codes
|
||||||
RPL_WELCOME NumericCode = 1
|
RPL_WELCOME NumericCode = 1
|
||||||
|
15
irc/reply.go
15
irc/reply.go
@ -394,6 +394,16 @@ func (target *Client) RplTime() {
|
|||||||
"%s :%s", target.server.name, time.Now().Format(time.RFC1123))
|
"%s :%s", target.server.name, time.Now().Format(time.RFC1123))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (target *Client) RplWhoWasUser(nickname, username, hostname, realname string) {
|
||||||
|
target.NumericReply(RPL_WHOWASUSER,
|
||||||
|
"%s %s %s * :%s", nickname, username, hostname, realname)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (target *Client) RplEndOfWhoWas(nickname string) {
|
||||||
|
target.NumericReply(RPL_ENDOFWHOWAS,
|
||||||
|
"%s :End of WHOWAS", nickname)
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// errors (also numeric)
|
// errors (also numeric)
|
||||||
//
|
//
|
||||||
@ -512,3 +522,8 @@ func (target *Client) ErrChannelIsFull(channel *Channel) {
|
|||||||
target.NumericReply(ERR_CHANNELISFULL,
|
target.NumericReply(ERR_CHANNELISFULL,
|
||||||
"%s :Cannot join channel (+l)", channel)
|
"%s :Cannot join channel (+l)", channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (target *Client) ErrWasNoSuchNick(nickname string) {
|
||||||
|
target.NumericReply(ERR_WASNOSUCHNICK,
|
||||||
|
"%s :There was no such nickname", nickname)
|
||||||
|
}
|
||||||
|
@ -844,6 +844,15 @@ func (msg *KillCommand) HandleServer(server *Server) {
|
|||||||
target.Quit(quitMsg)
|
target.Quit(quitMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (msg *WhoWasCommand) HandleServer(server *Server) {
|
||||||
|
client := msg.Client()
|
||||||
|
for _, nickname := range msg.nicknames {
|
||||||
|
// TODO implement nick history
|
||||||
|
client.ErrWasNoSuchNick(nickname)
|
||||||
|
client.RplEndOfWhoWas(nickname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// keeping track of clients
|
// keeping track of clients
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user