mirror of
https://github.com/anope/anope.git
synced 2026-07-02 11:06:37 +02:00
Add config options to ns_suspend and cs_suspend to configure which information is shown to non opers
This commit is contained in:
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user