From 9e5ce1fce6a422c92ca444fbfd1704f5ffdf6033 Mon Sep 17 00:00:00 2001 From: Jessica James Date: Tue, 3 Jan 2017 21:45:03 -0500 Subject: [PATCH] Reworked auto join for new format --- Jupiter/IRC_Client.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Jupiter/IRC_Client.cpp b/Jupiter/IRC_Client.cpp index 40c078e..05bd9f3 100644 --- a/Jupiter/IRC_Client.cpp +++ b/Jupiter/IRC_Client.cpp @@ -782,14 +782,22 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) Jupiter::IRC::Client::send(value); i++; } - key = "Channel."; - i = 1; - while (config_loop_condition()) + + auto auto_join_channels_callback = [this](Jupiter::Config::SectionHashTable::Bucket::Entry &in_entry) { - key.truncate(offset); - Jupiter::IRC::Client::joinChannel(value); - i++; - } + if (in_entry.value.get("AutoJoin"_jrs, false)) + this->joinChannel(in_entry.value.getName()); + }; + + Jupiter::Config *config = m_primary_section->getSection("Channels"_jrs); + + if (config != nullptr) + config->getSections().callback(auto_join_channels_callback); + + config = m_secondary_section->getSection("Channels"_jrs); + + if (config != nullptr) + config->getSections().callback(auto_join_channels_callback); m_connection_status = 5; m_reconnect_attempts = 0;