diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-12-21 21:04:41 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-01-04 01:59:14 +0100 |
commit | 3afb63a650b8b925ce1ba722dd42b7418f623713 (patch) | |
tree | 594cdfdd2a0abf302229ec000c2177ec001bfeaf /src/irc | |
parent | df59a09163bd988ad4da533c4f39de057a3701ba (diff) | |
download | biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.gz biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.bz2 biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.xz biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.zip |
Shutdown cleanly on SIGINT
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc_client.cpp | 20 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index ed98653..2115bdc 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -118,6 +118,11 @@ void IrcClient::send_kick_command(const std::string& chan_name, const std::strin this->send_message(IrcMessage("KICK", {chan_name, target, reason})); } +void IrcClient::send_quit_command() +{ + this->send_message(IrcMessage("QUIT", {"gateway shutdown"})); +} + void IrcClient::send_join_command(const std::string& chan_name) { if (this->welcomed == false) @@ -310,6 +315,21 @@ void IrcClient::on_part(const IrcMessage& message) } } +void IrcClient::on_error(const IrcMessage& message) +{ + const std::string leave_message = message.arguments[0]; + // The user is out of all the channels + for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + { + Iid iid; + iid.chan = it->first; + iid.server = this->hostname; + IrcChannel* channel = it->second.get(); + std::string own_nick = channel->get_self()->nick; + this->bridge->send_muc_leave(std::move(iid), std::move(own_nick), leave_message, true); + } +} + void IrcClient::on_quit(const IrcMessage& message) { std::string txt; diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 4749cac..4038cdf 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -96,6 +96,10 @@ public: */ void send_kick_command(const std::string& chan_name, const std::string& target, const std::string& reason); /** + * Send the QUIT irc command + */ + void send_quit_command(); + /** * Forward the server message received from IRC to the XMPP component */ void forward_server_message(const IrcMessage& message); @@ -139,6 +143,7 @@ public: */ void on_welcome_message(const IrcMessage& message); void on_part(const IrcMessage& message); + void on_error(const IrcMessage& message); void on_nick(const IrcMessage& message); void on_kick(const IrcMessage& message); void on_mode(const IrcMessage& message); @@ -216,6 +221,7 @@ static const std::unordered_map<std::string, irc_callback_t> irc_callbacks = { {"366", &IrcClient::on_channel_completely_joined}, {"001", &IrcClient::on_welcome_message}, {"PART", &IrcClient::on_part}, + {"ERROR", &IrcClient::on_error}, {"QUIT", &IrcClient::on_quit}, {"NICK", &IrcClient::on_nick}, {"MODE", &IrcClient::on_mode}, |