summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-13 01:24:36 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-13 01:24:36 +0100
commit0859801230f999889d0f7356864888e8c5936cda (patch)
tree31b1eed96847157def5c22adb1a55abff6a3dae1 /src/irc
parent3cfaab9a2debe03829b1ff26fe94e775e1d18e0a (diff)
downloadbiboumi-0859801230f999889d0f7356864888e8c5936cda.tar.gz
biboumi-0859801230f999889d0f7356864888e8c5936cda.tar.bz2
biboumi-0859801230f999889d0f7356864888e8c5936cda.tar.xz
biboumi-0859801230f999889d0f7356864888e8c5936cda.zip
Handle KICK in irc channel, both ways
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp20
-rw-r--r--src/irc/irc_client.hpp6
2 files changed, 26 insertions, 0 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 1d2e487..82abbd9 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -113,6 +113,11 @@ void IrcClient::send_nick_command(const std::string& nick)
this->send_message(IrcMessage("NICK", {nick}));
}
+void IrcClient::send_kick_command(const std::string& chan_name, const std::string& target, const std::string& reason)
+{
+ this->send_message(IrcMessage("KICK", {chan_name, target, reason}));
+}
+
void IrcClient::send_join_command(const std::string& chan_name)
{
if (this->welcomed == false)
@@ -311,6 +316,21 @@ void IrcClient::on_nick(const IrcMessage& message)
}
}
+void IrcClient::on_kick(const IrcMessage& message)
+{
+ const std::string target = message.arguments[1];
+ const std::string reason = message.arguments[2];
+ const std::string chan_name = message.arguments[0];
+ IrcChannel* channel = this->get_channel(chan_name);
+ if (channel->get_self()->nick == target)
+ channel->joined = false;
+ IrcUser author(message.prefix);
+ Iid iid;
+ iid.chan = chan_name;
+ iid.server = this->hostname;
+ this->bridge->kick_muc_user(std::move(iid), target, reason, author.nick);
+}
+
void IrcClient::on_mode(const IrcMessage& message)
{
const std::string target = message.arguments[0];
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 07ff02c..3b22fa0 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -92,6 +92,10 @@ public:
*/
void send_mode_command(const std::string& chan_name, const std::vector<std::string>& arguments);
/**
+ * Send the KICK irc command
+ */
+ void send_kick_command(const std::string& chan_name, const std::string& target, const std::string& reason);
+ /**
* Forward the server message received from IRC to the XMPP component
*/
void forward_server_message(const IrcMessage& message);
@@ -124,6 +128,7 @@ public:
void on_welcome_message(const IrcMessage& message);
void on_part(const IrcMessage& message);
void on_nick(const IrcMessage& message);
+ void on_kick(const IrcMessage& message);
void on_mode(const IrcMessage& message);
/**
* A mode towards our own user is received (note, that is different from a
@@ -194,6 +199,7 @@ static const std::unordered_map<std::string, irc_callback_t> irc_callbacks = {
{"NICK", &IrcClient::on_nick},
{"MODE", &IrcClient::on_mode},
{"PING", &IrcClient::send_pong_command},
+ {"KICK", &IrcClient::on_kick},
};
#endif // IRC_CLIENT_INCLUDED