summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/chanserv.example.conf5
-rw-r--r--data/nickserv.example.conf3
-rw-r--r--modules/commands/cs_set_misc.cpp46
-rw-r--r--modules/commands/ns_set_misc.cpp46
4 files changed, 95 insertions, 5 deletions
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf
index 5b7afd43e..fa58d4fc6 100644
--- a/data/chanserv.example.conf
+++ b/data/chanserv.example.conf
@@ -1116,10 +1116,11 @@ command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/sas
* Provides the command chanserv/set/misc.
*
* Allows you to create arbitrary commands to set data, and have that data show up in chanserv/info.
+ * A field named misc_description may be given for use with help output.
*/
module { name = "cs_set_misc" }
-command { service = "ChanServ"; name = "SET URL"; command = "chanserv/set/misc"; }
-command { service = "ChanServ"; name = "SET EMAIL"; command = "chanserv/set/misc"; }
+command { service = "ChanServ"; name = "SET URL"; command = "chanserv/set/misc"; misc_description = _("Associate a URL with the channel") }
+command { service = "ChanServ"; name = "SET EMAIL"; command = "chanserv/set/misc"; misc_description = _("Associate an E-mail address with the channel") }
/*
* cs_status
diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf
index c3606e36f..87cd2f03a 100644
--- a/data/nickserv.example.conf
+++ b/data/nickserv.example.conf
@@ -529,9 +529,10 @@ command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/sas
* Provides the command nickserv/set/misc.
*
* Allows you to create arbitrary commands to set data, and have that data show up in nickserv/info.
+ * A field named misc_description may be given for use with help output.
*/
module { name = "ns_set_misc" }
-command { service = "NickServ"; name = "SET URL"; command = "nickserv/set/misc"; }
+command { service = "NickServ"; name = "SET URL"; command = "nickserv/set/misc"; misc_description = _("Associate a URL with your account") }
#command { service = "NickServ"; name = "SET ICQ"; command = "nickserv/set/misc"; }
#command { service = "NickServ"; name = "SET TWITTER"; command = "nickserv/set/misc"; }
#command { service = "NickServ"; name = "SET FACEBOOK"; command = "nickserv/set/misc"; }
diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp
index baf081f1f..3b6e761a7 100644
--- a/modules/commands/cs_set_misc.cpp
+++ b/modules/commands/cs_set_misc.cpp
@@ -12,6 +12,8 @@
#include "module.h"
+static std::map<Anope::string, Anope::string> descriptions;
+
struct CSMiscData : ExtensibleItem, Serializable
{
Serialize::Reference<ChannelInfo> ci;
@@ -106,6 +108,25 @@ class CommandCSSetMisc : public Command
else
source.Reply(CHAN_SETTING_UNSET, scommand.c_str(), ci->name.c_str());
}
+
+ void OnServHelp(CommandSource &source) anope_override
+ {
+ if (descriptions.count(source.command))
+ {
+ this->SetDesc(descriptions[source.command]);
+ Command::OnServHelp(source);
+ }
+ }
+
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ {
+ if (descriptions.count(source.command))
+ {
+ source.Reply("%s", Language::Translate(source.nc, descriptions[source.command].c_str()));
+ return true;
+ }
+ return false;
+ }
};
class CSSetMisc : public Module
@@ -119,8 +140,31 @@ class CSSetMisc : public Module
{
this->SetAuthor("Anope");
- Implementation i[] = { I_OnChanInfo };
+ Implementation i[] = { I_OnReload, I_OnChanInfo };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+
+ this->OnReload();
+ }
+
+ void OnReload()
+ {
+ ConfigReader config;
+
+ descriptions.clear();
+
+ for (int i = 0; i < config.Enumerate("command"); ++i)
+ {
+ if (config.ReadValue("command", "command", "", i) != "chanserv/set/misc")
+ continue;
+
+ Anope::string cname = config.ReadValue("command", "name", "", i);
+ Anope::string desc = config.ReadValue("command", "misc_description", "", i);
+
+ if (cname.empty() || desc.empty())
+ continue;
+
+ descriptions[cname] = desc;
+ }
}
void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) anope_override
diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp
index 2b82156b2..d3d1bc058 100644
--- a/modules/commands/ns_set_misc.cpp
+++ b/modules/commands/ns_set_misc.cpp
@@ -13,6 +13,8 @@
#include "module.h"
+static std::map<Anope::string, Anope::string> descriptions;
+
struct NSMiscData : ExtensibleItem, Serializable
{
Serialize::Reference<NickCore> nc;
@@ -109,6 +111,25 @@ class CommandNSSetMisc : public Command
{
this->Run(source, source.nc->display, !params.empty() ? params[0] : "");
}
+
+ void OnServHelp(CommandSource &source) anope_override
+ {
+ if (descriptions.count(source.command))
+ {
+ this->SetDesc(descriptions[source.command]);
+ Command::OnServHelp(source);
+ }
+ }
+
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
+ {
+ if (descriptions.count(source.command))
+ {
+ source.Reply("%s", Language::Translate(source.nc, descriptions[source.command].c_str()));
+ return true;
+ }
+ return false;
+ }
};
class CommandNSSASetMisc : public CommandNSSetMisc
@@ -138,8 +159,31 @@ class NSSetMisc : public Module
{
this->SetAuthor("Anope");
- Implementation i[] = { I_OnNickInfo };
+ Implementation i[] = { I_OnReload, I_OnNickInfo };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+
+ this->OnReload();
+ }
+
+ void OnReload()
+ {
+ ConfigReader config;
+
+ descriptions.clear();
+
+ for (int i = 0; i < config.Enumerate("command"); ++i)
+ {
+ if (config.ReadValue("command", "command", "", i) != "nickserv/set/misc")
+ continue;
+
+ Anope::string cname = config.ReadValue("command", "name", "", i);
+ Anope::string desc = config.ReadValue("command", "misc_description", "", i);
+
+ if (cname.empty() || desc.empty())
+ continue;
+
+ descriptions[cname] = desc;
+ }
}
void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) anope_override