Skip to content

Commit

Permalink
libcommuni IRC backend: support multi-lines messages
Browse files Browse the repository at this point in the history
... by splitting them into one PRIVMSG command per line.
  • Loading branch information
thomas-riccardi authored and vitalyster committed Aug 26, 2018
1 parent 4bb61b9 commit d7ffa36
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backends/libcommuni/ircnetworkplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,16 @@ void IRCNetworkPlugin::handleMessageSendRequest(const std::string &user, const s
return;
}
else {
m_sessions[session]->sendCommand(IrcCommand::createMessage(FROM_UTF8(target), FROM_UTF8(message)));
// IRC does not support newlines in messages, so we split the message into multiple Message commands
std::size_t cur = 0;
while (cur != std::string::npos) {
if (message[cur] == '\n') {
cur++;
}
std::size_t end = message.find('\n', cur);
m_sessions[session]->sendCommand(IrcCommand::createMessage(FROM_UTF8(target), FROM_UTF8(message.substr(cur, end - cur))));
cur = end;
}
}

if (target.find("#") == 0) {
Expand Down

0 comments on commit d7ffa36

Please sign in to comment.