From 2f0e26db4cd91037463e5aa45c7538a942a9eee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 17 Jun 2018 15:16:49 +0200 Subject: =?UTF-8?q?Channels=E2=80=99=20disco#info=20includes=20the=20numbe?= =?UTF-8?q?r=20of=20participants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #3311 --- src/irc/irc_client.cpp | 14 +++++++++++++- src/irc/irc_client.hpp | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index d7fa2cd..0f3d43c 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -317,9 +317,21 @@ IrcChannel* IrcClient::get_channel(const std::string& n) } catch (const std::out_of_range& exception) { - this->channels.emplace(name, std::make_unique()); + return this->channels.emplace(name, std::make_unique()).first->second.get(); + } +} + +const IrcChannel* IrcClient::find_channel(const std::string& n) const +{ + const std::string name = utils::tolower(n); + try + { return this->channels.at(name).get(); } + catch (const std::out_of_range& exception) + { + return nullptr; + } } bool IrcClient::is_channel_joined(const std::string& name) diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index fd97fe6..70046be 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -67,6 +67,10 @@ public: * Return the channel with this name, create it if it does not yet exist */ IrcChannel* get_channel(const std::string& name); + /** + * Return the channel with this name. Nullptr if it is not found + */ + const IrcChannel* find_channel(const std::string& name) const; /** * Returns true if the channel is joined */ -- cgit v1.2.3