Redirect welcome NOTICE to their channel, instead of sending a global one

fix #3236
This commit is contained in:
louiz’
2017-05-17 00:31:21 +02:00
parent 0180ea7e40
commit bb150d587f
3 changed files with 25 additions and 1 deletions
+10 -1
View File
@@ -544,9 +544,18 @@ void IrcClient::forward_server_message(const IrcMessage& message)
void IrcClient::on_notice(const IrcMessage& message)
{
std::string from = message.prefix;
const std::string to = message.arguments[0];
std::string to = message.arguments[0];
const std::string body = message.arguments[1];
// Handle notices starting with [#channame] as if they were sent to that channel
if (body.size() > 3 && body[0] == '[')
{
const auto chan_prefix = body[1];
auto end = body.find(']');
if (this->chantypes.find(chan_prefix) != this->chantypes.end() && end != std::string::npos)
to = body.substr(1, end - 1);
}
if (!body.empty() && body[0] == '\01' && body[body.size() - 1] == '\01')
// Do not forward the notice to the user if it's a CTCP command
return ;