3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-02-20 15:40:51 +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, QUIT: NewQuitCommand,
TOPIC: NewTopicCommand, TOPIC: NewTopicCommand,
USER: NewUserCommand, USER: NewUserCommand,
VERSION: NewVersionCommand,
WHO: NewWhoCommand, WHO: NewWhoCommand,
WHOIS: NewWhoisCommand, WHOIS: NewWhoisCommand,
} }
@ -900,3 +901,16 @@ func NewDebugCommand(args []string) (editableCommand, error) {
subCommand: strings.ToUpper(args[0]), subCommand: strings.ToUpper(args[0]),
}, nil }, 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,7 +23,7 @@ var (
) )
const ( const (
VERSION = "1.0.0" SERVER_VERSION = "1.0.0"
CRLF = "\r\n" CRLF = "\r\n"
MAX_REPLY_LEN = 512 - len(CRLF) MAX_REPLY_LEN = 512 - len(CRLF)
@ -56,6 +56,7 @@ const (
QUIT StringCode = "QUIT" QUIT StringCode = "QUIT"
TOPIC StringCode = "TOPIC" TOPIC StringCode = "TOPIC"
USER StringCode = "USER" USER StringCode = "USER"
VERSION StringCode = "VERSION"
WHO StringCode = "WHO" WHO StringCode = "WHO"
WHOIS StringCode = "WHOIS" WHOIS StringCode = "WHOIS"

View File

@ -146,7 +146,7 @@ func (target *Client) RplWelcome() {
func (target *Client) RplYourHost() { func (target *Client) RplYourHost() {
target.NumericReply(RPL_YOURHOST, 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() { func (target *Client) RplCreated() {
@ -156,7 +156,7 @@ func (target *Client) RplCreated() {
func (target *Client) RplMyInfo() { func (target *Client) RplMyInfo() {
target.NumericReply(RPL_MYINFO, 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) { func (target *Client) RplUModeIs(client *Client) {
@ -364,6 +364,11 @@ func (target *Client) RplWhoisChannels(client *Client) {
"%s :%s", client.Nick()) "%s :%s", client.Nick())
} }
func (target *Client) RplVersion() {
target.NumericReply(RPL_VERSION,
"ergonomadic-%s %s", SERVER_VERSION, target.server.name)
}
// //
// errors (also numeric) // errors (also numeric)
// //

View File

@ -762,3 +762,13 @@ func (msg *DebugCommand) HandleServer(server *Server) {
server.Reply(client, "written to ergonomadic-heap.prof") 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()
}