aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_helpop.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-10-05 19:36:56 +0100
committerGravatar Sadie Powell2022-10-05 19:36:56 +0100
commit08918dca94f13ce4cbf3674a9541c750540fd056 (patch)
treec40d45852121c03971583f79a171c7089b55532f /src/modules/m_helpop.cpp
parentModernize an old-style loop that was previously missed. (diff)
Fix the indentation of various modules.
Diffstat (limited to 'src/modules/m_helpop.cpp')
-rw-r--r--src/modules/m_helpop.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index 19afb3228..7969fab1e 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -96,89 +96,89 @@ class ModuleHelpop final
, public Whois::EventListener
{
private:
- CommandHelpop cmd;
- SimpleUserMode ho;
+ CommandHelpop cmd;
+ SimpleUserMode ho;
- public:
- ModuleHelpop()
- : Module(VF_VENDOR, "Adds the /HELPOP command which allows users to view help on various topics and user mode h (helpop) which marks a server operator as being available for help.")
- , Whois::EventListener(this)
- , cmd(this)
- , ho(this, "helpop", 'h', true)
- {
- }
+public:
+ ModuleHelpop()
+ : Module(VF_VENDOR, "Adds the /HELPOP command which allows users to view help on various topics and user mode h (helpop) which marks a server operator as being available for help.")
+ , Whois::EventListener(this)
+ , cmd(this)
+ , ho(this, "helpop", 'h', true)
+ {
+ }
- void ReadConfig(ConfigStatus& status) override
- {
- size_t longestkey = 0;
+ void ReadConfig(ConfigStatus& status) override
+ {
+ size_t longestkey = 0;
- HelpMap newhelp;
- auto tags = ServerInstance->Config->ConfTags("helpop");
- if (tags.empty())
- throw ModuleException(this, "You have loaded the helpop module but not configured any help topics!");
+ HelpMap newhelp;
+ auto tags = ServerInstance->Config->ConfTags("helpop");
+ if (tags.empty())
+ throw ModuleException(this, "You have loaded the helpop module but not configured any help topics!");
- for (const auto& [_, tag] : tags)
- {
- // Attempt to read the help key.
- const std::string key = tag->getString("key");
- if (key.empty())
- throw ModuleException(this, InspIRCd::Format("<helpop:key> is empty at %s", tag->source.str().c_str()));
- else if (irc::equals(key, "index"))
- throw ModuleException(this, InspIRCd::Format("<helpop:key> is set to \"index\" which is reserved at %s", tag->source.str().c_str()));
- else if (key.length() > longestkey)
- longestkey = key.length();
+ for (const auto& [_, tag] : tags)
+ {
+ // Attempt to read the help key.
+ const std::string key = tag->getString("key");
+ if (key.empty())
+ throw ModuleException(this, InspIRCd::Format("<helpop:key> is empty at %s", tag->source.str().c_str()));
+ else if (irc::equals(key, "index"))
+ throw ModuleException(this, InspIRCd::Format("<helpop:key> is set to \"index\" which is reserved at %s", tag->source.str().c_str()));
+ else if (key.length() > longestkey)
+ longestkey = key.length();
- // Attempt to read the help value.
- std::string value;
- if (!tag->readString("value", value, true) || value.empty())
- throw ModuleException(this, InspIRCd::Format("<helpop:value> is empty at %s", tag->source.str().c_str()));
+ // Attempt to read the help value.
+ std::string value;
+ if (!tag->readString("value", value, true) || value.empty())
+ throw ModuleException(this, InspIRCd::Format("<helpop:value> is empty at %s", tag->source.str().c_str()));
- // Parse the help body. Empty lines are replaced with a single
- // space because some clients are unable to show blank lines.
- HelpMessage helpmsg;
- irc::sepstream linestream(value, '\n', true);
- for (std::string line; linestream.GetToken(line); )
- helpmsg.push_back(line.empty() ? " " : line);
+ // Parse the help body. Empty lines are replaced with a single
+ // space because some clients are unable to show blank lines.
+ HelpMessage helpmsg;
+ irc::sepstream linestream(value, '\n', true);
+ for (std::string line; linestream.GetToken(line); )
+ helpmsg.push_back(line.empty() ? " " : line);
- // Read the help title and store the topic.
- const std::string title = tag->getString("title", InspIRCd::Format("*** Help for %s", key.c_str()), 1);
- if (!newhelp.emplace(key, HelpTopic(helpmsg, title)).second)
- {
- throw ModuleException(this, InspIRCd::Format("<helpop> tag with duplicate key '%s' at %s",
- key.c_str(), tag->source.str().c_str()));
- }
+ // Read the help title and store the topic.
+ const std::string title = tag->getString("title", InspIRCd::Format("*** Help for %s", key.c_str()), 1);
+ if (!newhelp.emplace(key, HelpTopic(helpmsg, title)).second)
+ {
+ throw ModuleException(this, InspIRCd::Format("<helpop> tag with duplicate key '%s' at %s",
+ key.c_str(), tag->source.str().c_str()));
}
+ }
- // The number of items we can fit on a page.
- HelpMessage indexmsg;
- size_t maxcolumns = 80 / (longestkey + 2);
- for (HelpMap::iterator iter = newhelp.begin(); iter != newhelp.end(); )
+ // The number of items we can fit on a page.
+ HelpMessage indexmsg;
+ size_t maxcolumns = 80 / (longestkey + 2);
+ for (HelpMap::iterator iter = newhelp.begin(); iter != newhelp.end(); )
+ {
+ std::string indexline;
+ for (size_t column = 0; column != maxcolumns; )
{
- std::string indexline;
- for (size_t column = 0; column != maxcolumns; )
- {
- if (iter == newhelp.end())
- break;
+ if (iter == newhelp.end())
+ break;
- indexline.append(iter->first);
- if (++column != maxcolumns)
- indexline.append(longestkey - iter->first.length() + 2, ' ');
- iter++;
- }
- indexmsg.push_back(indexline);
+ indexline.append(iter->first);
+ if (++column != maxcolumns)
+ indexline.append(longestkey - iter->first.length() + 2, ' ');
+ iter++;
}
- newhelp.emplace("index", HelpTopic(indexmsg, "List of help topics"));
- cmd.help.swap(newhelp);
-
- auto tag = ServerInstance->Config->ConfValue("helpmsg");
- cmd.nohelp = tag->getString("nohelp", "There is no help for the topic you searched for. Please try again.", 1);
+ indexmsg.push_back(indexline);
}
+ newhelp.emplace("index", HelpTopic(indexmsg, "List of help topics"));
+ cmd.help.swap(newhelp);
- void OnWhois(Whois::Context& whois) override
- {
- if (whois.GetTarget()->IsModeSet(ho))
- whois.SendLine(RPL_WHOISHELPOP, "is available for help.");
- }
+ auto tag = ServerInstance->Config->ConfValue("helpmsg");
+ cmd.nohelp = tag->getString("nohelp", "There is no help for the topic you searched for. Please try again.", 1);
+ }
+
+ void OnWhois(Whois::Context& whois) override
+ {
+ if (whois.GetTarget()->IsModeSet(ho))
+ whois.SendLine(RPL_WHOISHELPOP, "is available for help.");
+ }
};
MODULE_INIT(ModuleHelpop)