mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +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.
|
// SendRawMessage sends a raw message to the client.
|
||||||
func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool) error {
|
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
|
// use dumb hack to force the last param to be a trailing param if required
|
||||||
var usedTrailingHack bool
|
|
||||||
config := session.client.server.Config()
|
config := session.client.server.Config()
|
||||||
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] && len(message.Params) > 0 {
|
if config.Server.Compatibility.forceTrailing && commandsThatMustUseTrailing[message.Command] {
|
||||||
lastParam := message.Params[len(message.Params)-1]
|
message.ForceTrailing()
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble message
|
// assemble message
|
||||||
@ -1446,12 +1440,6 @@ func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool)
|
|||||||
return err
|
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() {
|
if session.client.server.logger.IsLoggingRawIO() {
|
||||||
logline := string(line[:len(line)-2]) // strip "\r\n"
|
logline := string(line[:len(line)-2]) // strip "\r\n"
|
||||||
session.client.server.logger.Debug("useroutput", session.client.Nick(), " ->", logline)
|
session.client.server.logger.Debug("useroutput", session.client.Nick(), " ->", logline)
|
||||||
|
Loading…
Reference in New Issue
Block a user