summaryrefslogtreecommitdiff
path: root/modules/commands/ns_suspend.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-06-23 09:45:15 -0400
committerAdam <Adam@anope.org>2014-06-23 09:45:15 -0400
commitfd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (patch)
tree1d68e86065e0b012aee41533d4f9b289ee0707ac /modules/commands/ns_suspend.cpp
parent148b26f687ce85dc01e852a2358b03d493757ada (diff)
parent9a947fa4359c667be58ebae4634d9ac0e53d5db4 (diff)
Merge branch '2.0' into 2.1
Conflicts: cmake/Anope.cmake cmake/FindGettext.cmake include/access.h include/messages.h include/modes.h include/modules.h include/users.h modules/CMakeLists.txt modules/commands/bs_bot.cpp modules/commands/cs_access.cpp modules/commands/cs_ban.cpp modules/commands/cs_clone.cpp modules/commands/cs_flags.cpp modules/commands/cs_info.cpp modules/commands/cs_list.cpp modules/commands/cs_log.cpp modules/commands/cs_mode.cpp modules/commands/cs_status.cpp modules/commands/cs_suspend.cpp modules/commands/cs_updown.cpp modules/commands/cs_xop.cpp modules/commands/ms_check.cpp modules/commands/ns_access.cpp modules/commands/ns_cert.cpp modules/commands/ns_group.cpp modules/commands/ns_register.cpp modules/commands/ns_set.cpp modules/commands/ns_suspend.cpp modules/commands/os_session.cpp modules/commands/os_svs.cpp modules/extra/m_ldap_authentication.cpp modules/extra/m_regex_pcre.cpp modules/extra/m_sql_authentication.cpp modules/extra/stats/m_chanstats.cpp modules/protocol/bahamut.cpp modules/protocol/hybrid.cpp modules/protocol/inspircd12.cpp modules/protocol/inspircd20.cpp modules/protocol/unreal.cpp modules/pseudoclients/chanserv.cpp modules/pseudoclients/chanserv/channel.cpp modules/pseudoclients/nickserv/nickserv.cpp modules/webcpanel/pages/chanserv/access.cpp src/access.cpp src/bots.cpp src/channels.cpp src/language.cpp src/modes.cpp src/modulemanager.cpp src/process.cpp src/users.cpp src/version.sh
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 1dfc48995..8c29afecc 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -210,6 +210,20 @@ class NSSuspend : public Module
Serialize::Type suspend_type;
EventHandlers<Event::NickSuspend> onnicksuspend;
EventHandlers<Event::NickUnsuspended> onnickunsuspend;
+ 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)
@@ -225,21 +239,29 @@ class NSSuspend : public Module
{
}
+ void OnReload(Configuration::Conf *conf) 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, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) 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(NickServ::Nick *na, bool &expire) override