summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
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);