summaryrefslogtreecommitdiff
path: root/modules/commands/ns_suspend.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-05-01 21:03:32 -0400
committerAdam <Adam@anope.org>2014-05-01 21:03:32 -0400
commit1f2c385bb9b7a78094024d226440a2ec4cfb6b80 (patch)
tree87ba22b2f91a06034b256254568e52c340f1f790 /modules/commands/ns_suspend.cpp
parentd79dd0b7d705e8f18ae0d6494a8bc65c2b0c2819 (diff)
Add config options to ns_suspend and cs_suspend to configure which information is shown to non opers
Diffstat (limited to 'modules/commands/ns_suspend.cpp')
-rw-r--r--modules/commands/ns_suspend.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp
index 241997d1c..72e82cadf 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -207,6 +207,20 @@ class NSSuspend : public Module
CommandNSUnSuspend commandnsunsuspend;
ExtensibleItem<NSSuspendInfo> suspend;
Serialize::Type suspend_type;
+ std::vector<Anope::string> show;
+
+ struct trim
+ {
+ Anope::string operator()(Anope::string s) const
+ {
+ return s.trim();
+ }
+ };
+
+ bool Show(CommandSource &source, const Anope::string &what) const
+ {
+ return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
+ }
public:
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
@@ -215,21 +229,29 @@ class NSSuspend : public Module
{
}
+ void OnReload(Configuration::Conf *conf) anope_override
+ {
+ Anope::string s = conf->GetModule(this)->Get<Anope::string>("show");
+ commasepstream(s).GetTokens(show);
+ std::transform(show.begin(), show.end(), show.begin(), trim());
+ }
+
void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
{
NSSuspendInfo *s = suspend.Get(na->nc);
- if (s)
- {
+ if (!s)
+ return;
+
+ if (show_hidden || Show(source, "suspended"))
info[_("Suspended")] = _("This nickname is \002suspended\002.");
- if (!s->by.empty())
- info[_("Suspended by")] = s->by;
- if (!s->reason.empty())
- info[_("Suspend reason")] = s->reason;
- if (s->when)
- info[_("Suspended on")] = Anope::strftime(s->when, source.GetAccount(), true);
- if (s->expires)
- info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount(), true);
- }
+ if (!s->by.empty() && (show_hidden || Show(source, "by")))
+ info[_("Suspended by")] = s->by;
+ if (!s->reason.empty() && (show_hidden || Show(source, "reason")))
+ info[_("Suspend reason")] = s->reason;
+ if (s->when && (show_hidden || Show(source, "on")))
+ info[_("Suspended on")] = Anope::strftime(s->when, source.GetAccount(), true);
+ if (s->expires && (show_hidden || Show(source, "expires")))
+ info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount(), true);
}
void OnPreNickExpire(NickAlias *na, bool &expire) anope_override