diff --git a/irc/commands.go b/irc/commands.go index fdb6fbf2..8dec4bb8 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -9,7 +9,7 @@ import "github.com/goshuirc/irc-go/ircmsg" // Command represents a command accepted from a client. type Command struct { - handler func(server *Server, client *Client, msg ircmsg.IrcMessage) bool + handler func(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool oper bool usablePreReg bool leaveClientActive bool // if true, leaves the client active time alone. reversed because we can't default a struct element to True @@ -42,7 +42,12 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b if !cmd.leaveClientIdle { client.Touch() } - exiting := cmd.handler(server, client, msg) + rb := NewResponseBuffer(client) + rb.Label = GetLabel(msg) + + exiting := cmd.handler(server, client, msg, rb) + + rb.Send() // after each command, see if we can send registration to the client if !client.registered { diff --git a/irc/modes.go b/irc/modes.go index ad28982a..c79870e3 100644 --- a/irc/modes.go +++ b/irc/modes.go @@ -210,13 +210,13 @@ func GetLowestChannelModePrefix(prefixes string) *Mode { // // MODE [ [...]] -func modeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { +func modeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { _, errChan := CasefoldChannel(msg.Params[0]) if errChan == nil { - return cmodeHandler(server, client, msg) + return cmodeHandler(server, client, msg, rb) } - return umodeHandler(server, client, msg) + return umodeHandler(server, client, msg, rb) } // ParseUserModeChanges returns the valid changes, and the list of unknown chars. @@ -325,11 +325,7 @@ func (client *Client) applyUserModeChanges(force bool, changes ModeChanges) Mode } // MODE [ [...]] -func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { - rb := NewResponseBuffer(client) - rb.Label = GetLabel(msg) - defer rb.Send() - +func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { nickname, err := CasefoldName(msg.Params[0]) target := server.clients.Get(nickname) if err != nil || target == nil {