diff options
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_helpop.cpp | 138 | ||||
| -rw-r--r-- | src/modules/m_operjoin.cpp | 66 | ||||
| -rw-r--r-- | src/modules/m_operlevels.cpp | 42 | ||||
| -rw-r--r-- | src/modules/m_operprefix.cpp | 14 |
4 files changed, 130 insertions, 130 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) diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 6f28b2c4d..e44224f4c 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -30,47 +30,47 @@ class ModuleOperjoin final : public Module { - private: - std::vector<std::string> operChans; - bool override; +private: + std::vector<std::string> operChans; + bool override; - public: - ModuleOperjoin() - : Module(VF_VENDOR, "Allows the server administrator to force server operators to join one or more channels when logging into their server operator account.") - { - } +public: + ModuleOperjoin() + : Module(VF_VENDOR, "Allows the server administrator to force server operators to join one or more channels when logging into their server operator account.") + { + } - void ReadConfig(ConfigStatus& status) override - { - auto tag = ServerInstance->Config->ConfValue("operjoin"); + void ReadConfig(ConfigStatus& status) override + { + auto tag = ServerInstance->Config->ConfValue("operjoin"); - override = tag->getBool("override", false); - irc::commasepstream ss(tag->getString("channel")); - operChans.clear(); + override = tag->getBool("override", false); + irc::commasepstream ss(tag->getString("channel")); + operChans.clear(); - for (std::string channame; ss.GetToken(channame); ) - operChans.push_back(channame); - } + for (std::string channame; ss.GetToken(channame); ) + operChans.push_back(channame); + } - void OnPostOper(User* user) override - { - LocalUser* localuser = IS_LOCAL(user); - if (!localuser) - return; + void OnPostOper(User* user) override + { + LocalUser* localuser = IS_LOCAL(user); + if (!localuser) + return; - for (const auto& operchan : operChans) - { - if (ServerInstance->Channels.IsChannel(operchan)) - Channel::JoinUser(localuser, operchan, override); - } + for (const auto& operchan : operChans) + { + if (ServerInstance->Channels.IsChannel(operchan)) + Channel::JoinUser(localuser, operchan, override); + } - irc::commasepstream ss(localuser->oper->getConfig("autojoin")); - for (std::string channame; ss.GetToken(channame); ) - { - if (ServerInstance->Channels.IsChannel(channame)) - Channel::JoinUser(localuser, channame, override); - } + irc::commasepstream ss(localuser->oper->getConfig("autojoin")); + for (std::string channame; ss.GetToken(channame); ) + { + if (ServerInstance->Channels.IsChannel(channame)) + Channel::JoinUser(localuser, channame, override); } + } }; MODULE_INIT(ModuleOperjoin) diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index 0d5d19d1e..04c8e32e0 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -30,34 +30,34 @@ class ModuleOperLevels final : public Module { - public: - ModuleOperLevels() - : Module(VF_VENDOR, "Allows the server administrator to define ranks for server operators which prevent lower ranked server operators from using /KILL on higher ranked server operators.") - { - } +public: + ModuleOperLevels() + : Module(VF_VENDOR, "Allows the server administrator to define ranks for server operators which prevent lower ranked server operators from using /KILL on higher ranked server operators.") + { + } - ModResult OnKill(User* source, User* dest, const std::string& reason) override + ModResult OnKill(User* source, User* dest, const std::string &reason) override + { + // oper killing an oper? + if (dest->IsOper() && source->IsOper()) { - // oper killing an oper? - if (dest->IsOper() && source->IsOper()) - { - unsigned long dest_level = ConvToNum<unsigned long>(dest->oper->getConfig("level")); - unsigned long source_level = ConvToNum<unsigned long>(source->oper->getConfig("level")); + unsigned long dest_level = ConvToNum<unsigned long>(dest->oper->getConfig("level")); + unsigned long source_level = ConvToNum<unsigned long>(source->oper->getConfig("level")); - if (dest_level > source_level) + if (dest_level > source_level) + { + if (IS_LOCAL(source)) { - if (IS_LOCAL(source)) - { - ServerInstance->SNO.WriteGlobalSno('a', "Oper %s (level %lu) attempted to /KILL a higher level oper: %s (level %lu), reason: %s", - source->nick.c_str(), source_level, dest->nick.c_str(), dest_level, reason.c_str()); - } - dest->WriteNotice("*** Oper " + source->nick + " attempted to /KILL you!"); - source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str())); - return MOD_RES_DENY; + ServerInstance->SNO.WriteGlobalSno('a', "Oper %s (level %lu) attempted to /KILL a higher level oper: %s (level %lu), reason: %s", + source->nick.c_str(), source_level, dest->nick.c_str(), dest_level, reason.c_str()); } + dest->WriteNotice("*** Oper " + source->nick + " attempted to /KILL you!"); + source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str())); + return MOD_RES_DENY; } - return MOD_RES_PASSTHRU; } + return MOD_RES_PASSTHRU; + } }; MODULE_INIT(ModuleOperLevels) diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 405f0bce0..e44408f03 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -34,13 +34,13 @@ class OperPrefixMode final : public PrefixMode { - public: - OperPrefixMode(Module* Creator) - : PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE) - { - prefix = ServerInstance->Config->ConfValue("operprefix")->getCharacter("prefix", '!'); - ranktoset = ranktounset = std::numeric_limits<ModeHandler::Rank>::max(); - } +public: + OperPrefixMode(Module* Creator) + : PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE) + { + prefix = ServerInstance->Config->ConfValue("operprefix")->getCharacter("prefix", '!'); + ranktoset = ranktounset = std::numeric_limits<ModeHandler::Rank>::max(); + } }; class ModuleOperPrefixMode; |
