diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-12-29 11:19:39 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2016-01-04 13:47:27 +0100 |
commit | a38b17692e0297cbd5d719f059bd0a1b6ef39fe4 (patch) | |
tree | 9780d21d143ac49baa3117bb12fff85922c3988d /src | |
parent | dfcb0a6e0e975b7a4fd3b9ca3cb340fc1859d7f9 (diff) | |
download | biboumi-a38b17692e0297cbd5d719f059bd0a1b6ef39fe4.tar.gz biboumi-a38b17692e0297cbd5d719f059bd0a1b6ef39fe4.tar.bz2 biboumi-a38b17692e0297cbd5d719f059bd0a1b6ef39fe4.tar.xz biboumi-a38b17692e0297cbd5d719f059bd0a1b6ef39fe4.zip |
Support multi-prefix
See http://ircv3.net/specs/extensions/multi-prefix-3.1.html
ref #3103
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/irc_client.cpp | 3 | ||||
-rw-r--r-- | src/irc/irc_user.cpp | 18 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 4aa45ac..e71d38c 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -151,6 +151,9 @@ void IrcClient::on_connected() } } + this->send_message({"CAP", {"REQ", "multi-prefix"}}); + this->send_message({"CAP", {"END"}}); + #ifdef USE_DATABASE auto options = Database::get_irc_server_options(this->bridge.get_bare_jid(), this->get_hostname()); diff --git a/src/irc/irc_user.cpp b/src/irc/irc_user.cpp index 8785270..9fa3612 100644 --- a/src/irc/irc_user.cpp +++ b/src/irc/irc_user.cpp @@ -7,8 +7,20 @@ IrcUser::IrcUser(const std::string& name, { if (name.empty()) return ; - const std::map<char, char>::const_iterator prefix = prefix_to_mode.find(name[0]); - const std::string::size_type name_begin = prefix == prefix_to_mode.end()? 0: 1; + + // One or more prefix (with multi-prefix support) may come before the + // actual nick + std::string::size_type name_begin = 0; + while (name_begin != name.size()) + { + const auto prefix = prefix_to_mode.find(name[name_begin]); + // This is not a prefix + if (prefix == prefix_to_mode.end()) + break; + this->modes.insert(prefix->second); + name_begin++; + } + const std::string::size_type sep = name.find("!", name_begin); if (sep == std::string::npos) this->nick = name.substr(name_begin); @@ -17,8 +29,6 @@ IrcUser::IrcUser(const std::string& name, this->nick = name.substr(name_begin, sep-name_begin); this->host = name.substr(sep+1); } - if (prefix != prefix_to_mode.end()) - this->modes.insert(prefix->second); } IrcUser::IrcUser(const std::string& name): |