summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-06-17 15:16:49 +0200
committerlouiz’ <louiz@louiz.org>2018-06-17 15:16:49 +0200
commit2f0e26db4cd91037463e5aa45c7538a942a9eee2 (patch)
treea06a8d0876f70fc9dc388fc7c3a81f5e434aeccd /src/irc
parent354c738dc3cacd302d6961617fbc69e128572470 (diff)
downloadbiboumi-2f0e26db4cd91037463e5aa45c7538a942a9eee2.tar.gz
biboumi-2f0e26db4cd91037463e5aa45c7538a942a9eee2.tar.bz2
biboumi-2f0e26db4cd91037463e5aa45c7538a942a9eee2.tar.xz
biboumi-2f0e26db4cd91037463e5aa45c7538a942a9eee2.zip
Channels’ disco#info includes the number of participants
fix #3311
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp14
-rw-r--r--src/irc/irc_client.hpp4
2 files changed, 17 insertions, 1 deletions
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<IrcChannel>());
+ return this->channels.emplace(name, std::make_unique<IrcChannel>()).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
@@ -68,6 +68,10 @@ public:
*/
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
*/
bool is_channel_joined(const std::string& name);