From c8b5fb65e01f41d4b5c249462edc1387bc7cfad1 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 23 Jan 2017 09:03:49 +1000 Subject: [PATCH] WHOIS: Use inbuilt functionality to force trailing, as suggested by @vegax87 --- irc/client.go | 6 +++++- irc/server.go | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/irc/client.go b/irc/client.go index bd23cf03..983b36bf 100644 --- a/irc/client.go +++ b/irc/client.go @@ -535,10 +535,14 @@ func (client *Client) SendFromClient(msgid string, from *Client, tags *map[strin } var ( - // these are all the output commands that MUST have their last param be a trailing + // these are all the output commands that MUST have their last param be a trailing. + // this is needed because silly clients like to treat trailing as separate from the + // other params in messages. commandsThatMustUseTrailing = map[string]bool{ "PRIVMSG": true, "NOTICE": true, + + RPL_WHOISCHANNELS: true, } ) diff --git a/irc/server.go b/irc/server.go index 41ca180a..b404b153 100644 --- a/irc/server.go +++ b/irc/server.go @@ -1093,8 +1093,7 @@ func (client *Client) getWhoisOf(target *Client) { whoischannels := client.WhoisChannelsNames(target) if whoischannels != nil { - // the dodgy +" " hack here is to work around some silly clients that don't parse trailing params correctly. This forces last param to be a trailing always. - client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, strings.Join(whoischannels, " ")+" ") + client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, strings.Join(whoischannels, " ")) } if target.class != nil { client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine)