summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-05-07 17:17:01 +0200
committerFlorent Le Coz <louiz@louiz.org>2015-05-07 17:17:01 +0200
commit163ace553f3e65dcf9f97070faa5dbab0d31bac0 (patch)
tree3340c27c98275fdda65b2e5f6ffb48dbc64c240d /src
parent0a6b673b14efc4f623ea445045e6fc60e9842a25 (diff)
downloadbiboumi-163ace553f3e65dcf9f97070faa5dbab0d31bac0.tar.gz
biboumi-163ace553f3e65dcf9f97070faa5dbab0d31bac0.tar.bz2
biboumi-163ace553f3e65dcf9f97070faa5dbab0d31bac0.tar.xz
biboumi-163ace553f3e65dcf9f97070faa5dbab0d31bac0.zip
Handle all unknown IRC command by forwarding the arguments as a message body
This way, the users can receive the result of any IRC command (although not parsed nor formatted in anyway) when biboumi doesn’t support it fix #2884
Diffstat (limited to 'src')
-rw-r--r--src/irc/irc_client.cpp23
-rw-r--r--src/irc/irc_client.hpp1
2 files changed, 23 insertions, 1 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 717f7e3..677f6be 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -8,6 +8,7 @@
#include <utils/tolower.hpp>
#include <utils/split.hpp>
+#include <sstream>
#include <iostream>
#include <stdexcept>
@@ -154,7 +155,11 @@ void IrcClient::parse_in_buffer(const size_t)
}
}
else
- log_info("No handler for command " << message.command);
+ {
+ log_info("No handler for command " << message.command <<
+ ", forwarding the arguments to the user");
+ this->on_unknown_message(message);
+ }
// Try to find a waiting_iq, which response will be triggered by this IrcMessage
this->bridge->trigger_on_irc_message(this->hostname, message);
}
@@ -797,6 +802,22 @@ void IrcClient::on_user_mode(const IrcMessage& message)
" is [" + message.arguments[1] + "]");
}
+void IrcClient::on_unknown_message(const IrcMessage& message)
+{
+ if (message.arguments.size() < 2)
+ return ;
+ std::string from = message.prefix;
+ const std::string to = message.arguments[0];
+ std::stringstream ss;
+ for (auto it = message.arguments.begin() + 1; it != message.arguments.end(); ++it)
+ {
+ ss << *it;
+ if (it + 1 != message.arguments.end())
+ ss << " ";
+ }
+ this->bridge->send_xmpp_message(this->hostname, from, ss.str());
+}
+
size_t IrcClient::number_of_joined_channels() const
{
if (this->dummy_channel.joined)
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 08021c1..4ab0fcb 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -211,6 +211,7 @@ public:
*/
void on_channel_mode(const IrcMessage& message);
void on_quit(const IrcMessage& message);
+ void on_unknown_message(const IrcMessage& message);
/**
* Return the number of joined channels
*/