From b0faa27567d7f6e7d10741180a6b3224f75d6e6e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 15 Jan 2020 12:56:41 +0000 Subject: Add support for setting the help topic in helpop. --- docs/conf/helpop.conf.example | 682 +++++++++++++++++++++--------------------- src/modules/m_helpop.cpp | 36 ++- 2 files changed, 369 insertions(+), 349 deletions(-) diff --git a/docs/conf/helpop.conf.example b/docs/conf/helpop.conf.example index 437f30499..4308c9915 100644 --- a/docs/conf/helpop.conf.example +++ b/docs/conf/helpop.conf.example @@ -3,8 +3,9 @@ # or you can customize the responses for your network and/or add more. # # The way the new helpop system works is simple. You use one or more helpop tags. -# -# key is what the user is looking for (i.e. /helpop moo), and value is what they get back +# +# key is what the user is looking for (i.e. /helpop moo), title is the title, and +# value is what they get back # (note that it can span multiple lines!). # -- w00t 16/dec/2006 # @@ -15,8 +16,7 @@ - - - + - - +WHO WHOIS WHOWAS +"> - + - - +target user. +"> - + - - + Duration is optional, and may be specified in seconds or in the form of 1y2w3d4h5m6s - meaning one year, two weeks, three days, four hours, five minutes and six seconds. All fields in this -format are optional."> - - + - - + - - + - - + /WATCH - - Remove a nick This command accepts multiple nicks like so: -/WATCH + - +"> - - + - - +/MONITOR - ,, +"> - + - - + - - + - - + - - +Any combination of flags is valid. +"> - + - - - - - - -Returns the server's version information."> + - -Ping a server. The server will answer with a PONG."> + - + - - - - - - - - -Joins one or more channels you provide the names for."> + - -Return a list of users on the channel(s) you provide."> + - -Leaves one or more channels you specify."> + - + - - + - - + - - + - + - - + - - + - - +, e.g. *chat* or bot*. +"> - + - - + - - + - - + - - + - - + - - +the time they were last seen and their server. +"> - + - - + - - + - - + - - +IRC server possible. +"> + - - - +USERIP WALLOPS ZLINE +"> - + - - + - - +service is temporarily closed and to try again later. +"> - + - - + - - + - - + - - +online on a remote server. +"> - + - - + - - +the network. +"> - + - - + - - - - - - - - -Kicks the given user from the specified channel, with an optional reason."> + - -Applies the given topic to the specified channel."> + - -Forces user to quit with the specified reason."> + - + - - - - -Sets your ident to the specified ident."> + - + - - + - - +the result. +"> - + - - - - - - -Changes the real name of the user to the specified real name."> + - -Changes the ident of the user to the specified ident."> + - + - - + - - + - - - - -This command will disconnect a user from IRC with the given reason."> + - + - - + - - +before trying to link them. +"> - + - - - - - - - - -Loads the specified module on all linked servers."> + - -Unloads a module from all linked servers."> + - -Unloads and reloads a module on all linked servers."> + - + - - + - - + - - + - - + - - +can be negated by any E-line that matches. +"> - + - - + - - + - - + - - + S Strips formatting codes out of private messages to the user (requires the stripcolor module). W Receives notifications when a user uses WHOIS on them - (server operators only, requires the showwhois module)."> - - + stripcolor Channel mode +S topiclock Channel mode +t -------------- NOTE: A large number of these modes are dependent upon server-side modules being loaded by a server/network administrator. The actual modes available on your network may be very different to this list. Please consult your -help channel if you have any questions."> - - + - - + t Allows receipt of attempts to use /STATS (local and remote). v Allows receipt of oper override notices (requires the override module). x Allows receipt of local X-line notices (G/Z/Q/K/E/R/SHUN/CBan). - X Allows receipt of remote X-line notices (G/Z/Q/K/E/R/SHUN/CBan)."> - - + + when they try to join (requires the banredirect module). +"> diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index a34e3ff94..e7ee65748 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -41,7 +41,22 @@ enum typedef std::vector HelpMessage; -typedef std::map HelpMap; +struct HelpTopic +{ + // The body of the help topic. + const HelpMessage body; + + // The title of the help topic. + const std::string title; + + HelpTopic(const HelpMessage& Body, const std::string& Title) + : body(Body) + , title(Title) + { + } +}; + +typedef std::map HelpMap; class CommandHelpop : public Command { @@ -69,10 +84,11 @@ class CommandHelpop : public Command return CMD_FAILURE; } - user->WriteNumeric(RPL_HELPSTART, topic, InspIRCd::Format("*** Help for %s", topic.c_str())); - for (HelpMessage::const_iterator liter = titer->second.begin(); liter != titer->second.end(); ++liter) + const HelpTopic& entry = titer->second; + user->WriteNumeric(RPL_HELPSTART, topic, entry.title); + for (HelpMessage::const_iterator liter = entry.body.begin(); liter != entry.body.end(); ++liter) user->WriteNumeric(RPL_HELPTXT, topic, *liter); - user->WriteNumeric(RPL_ENDOFHELP, topic, "*** End of help"); + user->WriteNumeric(RPL_ENDOFHELP, topic, "End of /HELPOP."); return CMD_SUCCESS; } }; @@ -126,11 +142,18 @@ class ModuleHelpop irc::sepstream linestream(value, '\n', true); for (std::string line; linestream.GetToken(line); ) helpmsg.push_back(line.empty() ? " " : line); - newhelp[key] = helpmsg; + + // 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.insert(std::make_pair(key, HelpTopic(helpmsg, title))).second) + { + throw ModuleException(InspIRCd::Format(" tag with duplicate key '%s' at %s", + key.c_str(), tag->getTagLocation().c_str())); + } } // The number of items we can fit on a page. - HelpMessage& indexmsg = newhelp["index"]; + HelpMessage indexmsg; size_t maxcolumns = 80 / (longestkey + 2); for (HelpMap::iterator iter = newhelp.begin(); iter != newhelp.end(); ) { @@ -147,6 +170,7 @@ class ModuleHelpop } indexmsg.push_back(indexline); } + newhelp.insert(std::make_pair("index", HelpTopic(indexmsg, "List of help topics"))); cmd.help.swap(newhelp); ConfigTag* tag = ServerInstance->Config->ConfValue("helpmsg"); -- cgit v1.2.3