3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

add a version command for sumeet

This commit is contained in:
Jeremy Latt 2014-02-24 22:04:11 -08:00
parent 994200bf46
commit d6ec1e719b
4 changed files with 35 additions and 5 deletions

View File

@ -48,6 +48,7 @@ var (
QUIT: NewQuitCommand,
TOPIC: NewTopicCommand,
USER: NewUserCommand,
VERSION: NewVersionCommand,
WHO: NewWhoCommand,
WHOIS: NewWhoisCommand,
}
@ -900,3 +901,16 @@ func NewDebugCommand(args []string) (editableCommand, error) {
subCommand: strings.ToUpper(args[0]),
}, nil
}
type VersionCommand struct {
BaseCommand
target string
}
func NewVersionCommand(args []string) (editableCommand, error) {
cmd := &VersionCommand{}
if len(args) > 0 {
cmd.target = args[0]
}
return cmd, nil
}

View File

@ -23,9 +23,9 @@ var (
)
const (
VERSION = "1.0.0"
CRLF = "\r\n"
MAX_REPLY_LEN = 512 - len(CRLF)
SERVER_VERSION = "1.0.0"
CRLF = "\r\n"
MAX_REPLY_LEN = 512 - len(CRLF)
LOGIN_TIMEOUT = time.Minute / 2 // how long the client has to login
IDLE_TIMEOUT = time.Minute // how long before a client is considered idle
@ -56,6 +56,7 @@ const (
QUIT StringCode = "QUIT"
TOPIC StringCode = "TOPIC"
USER StringCode = "USER"
VERSION StringCode = "VERSION"
WHO StringCode = "WHO"
WHOIS StringCode = "WHOIS"

View File

@ -146,7 +146,7 @@ func (target *Client) RplWelcome() {
func (target *Client) RplYourHost() {
target.NumericReply(RPL_YOURHOST,
":Your host is %s, running version %s", target.server.name, VERSION)
":Your host is %s, running version %s", target.server.name, SERVER_VERSION)
}
func (target *Client) RplCreated() {
@ -156,7 +156,7 @@ func (target *Client) RplCreated() {
func (target *Client) RplMyInfo() {
target.NumericReply(RPL_MYINFO,
"%s %s aiOorsw abeIikmntpqrsl", target.server.name, VERSION)
"%s %s aiOorsw abeIikmntpqrsl", target.server.name, SERVER_VERSION)
}
func (target *Client) RplUModeIs(client *Client) {
@ -364,6 +364,11 @@ func (target *Client) RplWhoisChannels(client *Client) {
"%s :%s", client.Nick())
}
func (target *Client) RplVersion() {
target.NumericReply(RPL_VERSION,
"ergonomadic-%s %s", SERVER_VERSION, target.server.name)
}
//
// errors (also numeric)
//

View File

@ -762,3 +762,13 @@ func (msg *DebugCommand) HandleServer(server *Server) {
server.Reply(client, "written to ergonomadic-heap.prof")
}
}
func (msg *VersionCommand) HandleServer(server *Server) {
client := msg.Client()
if (msg.target != "") && (msg.target != server.name) {
client.ErrNoSuchServer(msg.target)
return
}
client.RplVersion()
}