diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-12-27 15:34:58 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-01-04 01:59:35 +0100 |
commit | 43cc60e4a9e2859fdf67c89e58ee18cf7571f186 (patch) | |
tree | fcf3335a4bc80a825a798cf80dec97fbe06182c7 /src/irc | |
parent | e8e592d1ace5413a1e7d8b59b9467c78d8d68ea9 (diff) | |
download | biboumi-43cc60e4a9e2859fdf67c89e58ee18cf7571f186.tar.gz biboumi-43cc60e4a9e2859fdf67c89e58ee18cf7571f186.tar.bz2 biboumi-43cc60e4a9e2859fdf67c89e58ee18cf7571f186.tar.xz biboumi-43cc60e4a9e2859fdf67c89e58ee18cf7571f186.zip |
Handle nickname conflicts by sending the correct XMPP error presence
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc_client.cpp | 13 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index afdc629..10a5b12 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -303,6 +303,19 @@ void IrcClient::on_erroneous_nickname(const IrcMessage& message) this->send_gateway_message(error_msg + ": " + message.arguments[1], message.prefix); } +void IrcClient::on_nickname_conflict(const IrcMessage& message) +{ + const std::string nickname = message.arguments[1]; + this->on_generic_error(message); + for (auto it = this->channels.begin(); it != this->channels.end(); ++it) + { + Iid iid; + iid.chan = it->first; + iid.server = this->hostname; + this->bridge->send_nickname_conflict_error(iid, nickname); + } +} + void IrcClient::on_generic_error(const IrcMessage& message) { const std::string error_msg = message.arguments.size() >= 3 ? diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index e695e53..eced4b6 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -149,6 +149,11 @@ public: */ void on_erroneous_nickname(const IrcMessage& message); /** + * When the IRC servers denies our nickname because of a conflict. Send a + * presence conflict from all channels, because the name is server-wide. + */ + void on_nickname_conflict(const IrcMessage& message); + /** * Handles most errors from the server by just forwarding the message to the user. */ void on_generic_error(const IrcMessage& message); @@ -237,6 +242,7 @@ static const std::unordered_map<std::string, irc_callback_t> irc_callbacks = { {"TOPIC", &IrcClient::on_topic_received}, {"366", &IrcClient::on_channel_completely_joined}, {"432", &IrcClient::on_erroneous_nickname}, + {"433", &IrcClient::on_nickname_conflict}, {"461", &IrcClient::on_generic_error}, {"001", &IrcClient::on_welcome_message}, {"PART", &IrcClient::on_part}, |