mirror of
https://github.com/anope/anope.git
synced 2026-06-28 19:36:39 +02:00
Allow ns_set_misc/cs_set_misc to have configurable help descriptions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user