diff options
author | Adam <Adam@anope.org> | 2014-05-01 21:03:32 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-05-01 21:03:32 -0400 |
commit | 1f2c385bb9b7a78094024d226440a2ec4cfb6b80 (patch) | |
tree | 87ba22b2f91a06034b256254568e52c340f1f790 | |
parent | d79dd0b7d705e8f18ae0d6494a8bc65c2b0c2819 (diff) |
Add config options to ns_suspend and cs_suspend to configure which information is shown to non opers
-rw-r--r-- | data/chanserv.example.conf | 7 | ||||
-rw-r--r-- | data/nickserv.example.conf | 7 | ||||
-rw-r--r-- | modules/commands/cs_suspend.cpp | 37 | ||||
-rw-r--r-- | modules/commands/ns_suspend.cpp | 44 |
4 files changed, 73 insertions, 22 deletions
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf index d4a2f841c..720738403 100644 --- a/data/chanserv.example.conf +++ b/data/chanserv.example.conf @@ -1215,6 +1215,13 @@ module * If not set, the default is never. */ expire = 90d + + /* + * Settings to show to non-opers in ChanServ's INFO output. + * Comment to completely disable showing any information about + * suspended channels to non-opers. + */ + show = "suspended, by, reason, on, expires" } command { service = "ChanServ"; name = "SUSPEND"; command = "chanserv/suspend"; permission = "chanserv/suspend"; group = "chanserv/admin"; } command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspend"; permission = "chanserv/suspend"; group = "chanserv/admin"; } diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index 87804e0fa..deca9164f 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -616,6 +616,13 @@ module * This directive is optional. If not set, the default is never. */ #suspendexpire = 90d + + /* + * Settings to show to non-opers in NickServ's INFO output. + * Comment to completely disable showing any information about + * suspended nicknames to non-opers. + */ + show = "suspended, by, reason, on, expires" } command { service = "NickServ"; name = "SUSPEND"; command = "nickserv/suspend"; permission = "nickserv/suspend"; group = "nickserv/admin"; } command { service = "NickServ"; name = "UNSUSPEND"; command = "nickserv/unsuspend"; permission = "nickserv/suspend"; group = "nickserv/admin"; } diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 4ebb6eecb..faec2a8c1 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -200,6 +200,20 @@ class CSSuspend : public Module CommandCSUnSuspend commandcsunsuspend; ExtensibleItem<CSSuspendInfo> 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: CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), @@ -211,18 +225,19 @@ class CSSuspend : public Module void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override { CSSuspendInfo *si = suspend.Get(ci); - if (si) - { + if (!si) + return; + + if (show_hidden || Show(source, "suspended")) info[_("Suspended")] = _("This channel is \002suspended\002."); - if (!si->by.empty()) - info[_("Suspended by")] = si->by; - if (!si->reason.empty()) - info[_("Suspend reason")] = si->reason; - if (si->when) - info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); - if (si->expires) - info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); - } + if (!si->by.empty() && (show_hidden || Show(source, "by"))) + info[_("Suspended by")] = si->by; + if (!si->reason.empty() && (show_hidden || Show(source, "reason"))) + info[_("Suspend reason")] = si->reason; + if (si->when && (show_hidden || Show(source, "on"))) + info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); + if (si->expires && (show_hidden || Show(source, "expires"))) + info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); } void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override 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 |