diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-05-07 17:01:17 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-05-07 17:01:17 +0200 |
commit | 0a6b673b14efc4f623ea445045e6fc60e9842a25 (patch) | |
tree | 88fef4dced68ef3c616fe1575d5c542b0474b56a /src | |
parent | e24ed4f70c22142029fa8e6cf5b874e8bc261bc3 (diff) | |
download | biboumi-0a6b673b14efc4f623ea445045e6fc60e9842a25.tar.gz biboumi-0a6b673b14efc4f623ea445045e6fc60e9842a25.tar.bz2 biboumi-0a6b673b14efc4f623ea445045e6fc60e9842a25.tar.xz biboumi-0a6b673b14efc4f623ea445045e6fc60e9842a25.zip |
Support raw IRC messages
Messages received on an IRC server JID are forwarded as raw IRC messages.
fix #2486
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge/bridge.cpp | 11 | ||||
-rw-r--r-- | src/bridge/bridge.hpp | 1 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 5 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 1 | ||||
-rw-r--r-- | src/xmpp/biboumi_component.cpp | 5 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 85049b9..45cdc01 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -273,6 +273,17 @@ void Bridge::send_private_message(const Iid& iid, const std::string& body, const } } +void Bridge::send_raw_message(const std::string& hostname, const std::string& body) +{ + IrcClient* irc = this->get_irc_client(hostname); + if (!irc) + { + log_warning("Cannot send message: no client exist for server " << hostname); + return ; + } + irc->send_raw(body); +} + void Bridge::leave_irc_channel(Iid&& iid, std::string&& status_message) { IrcClient* irc = this->get_irc_client(iid.get_server()); diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index c50b7ab..cc9d042 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -61,6 +61,7 @@ public: bool join_irc_channel(const Iid& iid, const std::string& username, const std::string& password); void send_channel_message(const Iid& iid, const std::string& body); void send_private_message(const Iid& iid, const std::string& body, const std::string& type="PRIVMSG"); + void send_raw_message(const std::string& hostname, const std::string& body); void leave_irc_channel(Iid&& iid, std::string&& status_message); void send_irc_nick_change(const Iid& iid, const std::string& new_nick); void send_irc_kick(const Iid& iid, const std::string& target, const std::string& reason, diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index b0ce93a..717f7e3 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -181,6 +181,11 @@ void IrcClient::send_message(IrcMessage&& message) this->send_data(std::move(res)); } +void IrcClient::send_raw(const std::string& txt) +{ + this->send_data(txt + "\r\n"); +} + void IrcClient::send_user_command(const std::string& username, const std::string& realname) { this->send_message(IrcMessage("USER", {username, "ignored", "ignored", realname})); diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 03951be..08021c1 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -66,6 +66,7 @@ public: * for send events to be ready) */ void send_message(IrcMessage&& message); + void send_raw(const std::string& txt); /** * Send the PONG irc command */ diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index ba8cb49..37383a8 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -211,6 +211,11 @@ void BiboumiComponent::handle_message(const Stanza& stanza) bridge->send_private_message(user_iid, body->get_inner()); bridge->set_preferred_from_jid(user_iid.get_local(), to_str); } + else if (!iid.is_user && !iid.is_channel) + { // Message sent to the server JID + // Convert the message body into a raw IRC message + bridge->send_raw_message(iid.get_server(), body->get_inner()); + } } } else if (iid.is_user) |