3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00
This commit is contained in:
Shivaram Lingamneni 2020-05-08 05:44:40 -04:00
parent d187cc5512
commit 6f688a4644
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]
if !exists {
if len(msg.Command) > 0 {
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
cmd = unknownCommand
}
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
}
// 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.
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)
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
}