mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
clean up trailing hack
This commit is contained in:
parent
3d13c1bc5f
commit
bbe9e09d46
@ -1418,15 +1418,9 @@ var (
|
||||
// SendRawMessage sends a raw message to the client.
|
||||
func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool) error {
|
||||
// use dumb hack to force the last param to be a trailing param if required
|
||||
var usedTrailingHack bool
|
||||
config := session.client.server.Config()
|
||||
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] && len(message.Params) > 0 {
|
||||
lastParam := message.Params[len(message.Params)-1]
|
||||
// to force trailing, we ensure the final param contains a space
|
||||
if strings.IndexByte(lastParam, ' ') == -1 {
|
||||
message.Params[len(message.Params)-1] = lastParam + " "
|
||||
usedTrailingHack = true
|
||||
}
|
||||
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] {
|
||||
message.ForceTrailing()
|
||||
}
|
||||
|
||||
// assemble message
|
||||
@ -1446,12 +1440,6 @@ func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool)
|
||||
return err
|
||||
}
|
||||
|
||||
// if we used the trailing hack, we need to strip the final space we appended earlier on
|
||||
if usedTrailingHack {
|
||||
copy(line[len(line)-3:], "\r\n")
|
||||
line = line[:len(line)-1]
|
||||
}
|
||||
|
||||
if session.client.server.logger.IsLoggingRawIO() {
|
||||
logline := string(line[:len(line)-2]) // strip "\r\n"
|
||||
session.client.server.logger.Debug("useroutput", session.client.Nick(), " ->", logline)
|
||||
|
Loading…
Reference in New Issue
Block a user