3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-23 04:19:25 +01:00

Merge pull request #995 from slingamn/issue994_unknowncommand.1

fix #994
This commit is contained in:
Shivaram Lingamneni 2020-05-08 13:12:16 -07:00 committed by GitHub
commit 93f1e5b5b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -661,12 +661,7 @@ func (client *Client) run(session *Session) {
cmd, exists := Commands[msg.Command] cmd, exists := Commands[msg.Command]
if !exists { if !exists {
if len(msg.Command) > 0 { cmd = unknownCommand
session.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.Nick(), msg.Command, client.t("Unknown command"))
} else {
session.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.Nick(), "lastcmd", client.t("No command given"))
}
continue
} }
isExiting := cmd.Run(client.server, client, session, msg) isExiting := cmd.Run(client.server, client, session, msg)

View File

@ -73,6 +73,12 @@ func (cmd *Command) Run(server *Server, client *Client, session *Session, msg ir
return exiting return exiting
} }
// fake handler for unknown commands (see #994: this ensures the response tags are correct)
var unknownCommand = Command{
handler: unknownCommandHandler,
usablePreReg: true,
}
// Commands holds all commands executable by a client connected to us. // Commands holds all commands executable by a client connected to us.
var Commands map[string]Command var Commands map[string]Command

View File

@ -2760,3 +2760,9 @@ func zncHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
zncModuleHandler(client, msg.Params[0], msg.Params[1:], rb) zncModuleHandler(client, msg.Params[0], msg.Params[1:], rb)
return false return false
} }
// fake handler for unknown commands
func unknownCommandHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
rb.Add(nil, server.name, ERR_UNKNOWNCOMMAND, client.Nick(), utils.SafeErrorParam(msg.Command), client.t("Unknown command"))
return false
}