summaryrefslogtreecommitdiff
path: root/src/bridge/bridge.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-18 20:48:42 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-25 17:50:03 +0200
commit7fb0b671bbe6150d60b9f1efd4d8abc885c23844 (patch)
treec4d7444498a7400ab8c3deea810a9b57e3134886 /src/bridge/bridge.cpp
parent01cd6eb5166c99a83facda804bfa3150e24e8b1e (diff)
downloadbiboumi-7fb0b671bbe6150d60b9f1efd4d8abc885c23844.tar.gz
biboumi-7fb0b671bbe6150d60b9f1efd4d8abc885c23844.tar.bz2
biboumi-7fb0b671bbe6150d60b9f1efd4d8abc885c23844.tar.xz
biboumi-7fb0b671bbe6150d60b9f1efd4d8abc885c23844.zip
Also do that cut of message on \n for private messages, and handle /me
Diffstat (limited to 'src/bridge/bridge.cpp')
-rw-r--r--src/bridge/bridge.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 7a60267..d803e5e 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -180,8 +180,21 @@ void Bridge::send_private_message(const Iid& iid, const std::string& body, const
if (iid.chan.empty() || iid.server.empty())
return ;
IrcClient* irc = this->get_irc_client(iid.server);
- if (irc)
- irc->send_private_message(iid.chan, body, type);
+ if (!irc)
+ {
+ log_warning("Cannot send message: no client exist for server " << iid.server);
+ return;
+ }
+ std::vector<std::string> lines = utils::split(body, '\n', true);
+ if (lines.empty())
+ return ;
+ for (const std::string& line: lines)
+ {
+ if (line.substr(0, 4) == "/me ")
+ irc->send_private_message(iid.chan, action_prefix + line.substr(4) + "\01", type);
+ else
+ irc->send_private_message(iid.chan, line, type);
+ }
}
void Bridge::leave_irc_channel(Iid&& iid, std::string&& status_message)