mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
time command
This commit is contained in:
parent
f0305cf01a
commit
4d2d18caf1
@ -47,6 +47,7 @@ var (
|
||||
PRIVMSG: NewPrivMsgCommand,
|
||||
PROXY: NewProxyCommand,
|
||||
QUIT: NewQuitCommand,
|
||||
TIME: NewTimeCommand,
|
||||
TOPIC: NewTopicCommand,
|
||||
USER: NewUserCommand,
|
||||
VERSION: NewVersionCommand,
|
||||
@ -932,3 +933,16 @@ func NewInviteCommand(args []string) (editableCommand, error) {
|
||||
channel: args[1],
|
||||
}, nil
|
||||
}
|
||||
|
||||
type TimeCommand struct {
|
||||
BaseCommand
|
||||
target string
|
||||
}
|
||||
|
||||
func NewTimeCommand(args []string) (editableCommand, error) {
|
||||
cmd := &TimeCommand{}
|
||||
if len(args) > 0 {
|
||||
cmd.target = args[0]
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ const (
|
||||
PRIVMSG StringCode = "PRIVMSG"
|
||||
PROXY StringCode = "PROXY"
|
||||
QUIT StringCode = "QUIT"
|
||||
TIME StringCode = "TIME"
|
||||
TOPIC StringCode = "TOPIC"
|
||||
USER StringCode = "USER"
|
||||
VERSION StringCode = "VERSION"
|
||||
|
@ -374,6 +374,11 @@ func (target *Client) RplInviting(invitee *Client, channel string) {
|
||||
"%s %s", invitee.Nick(), channel)
|
||||
}
|
||||
|
||||
func (target *Client) RplTime() {
|
||||
target.NumericReply(RPL_TIME,
|
||||
"%s :%s", target.server.name, time.Now().Format(time.RFC1123))
|
||||
}
|
||||
|
||||
//
|
||||
// errors (also numeric)
|
||||
//
|
||||
|
@ -791,3 +791,11 @@ func (msg *InviteCommand) HandleServer(server *Server) {
|
||||
|
||||
channel.Invite(target, client)
|
||||
}
|
||||
|
||||
func (msg *TimeCommand) HandleServer(server *Server) {
|
||||
if (msg.target != "") && (msg.target != server.name) {
|
||||
msg.Client().ErrNoSuchServer(msg.target)
|
||||
return
|
||||
}
|
||||
msg.Client().RplTime()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user