1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 18:23:12 +02:00

Fix suspend info output in info and improved it

This commit is contained in:
Adam
2013-05-08 11:13:48 -04:00
parent d7e2ab688b
commit f843e7bd90
3 changed files with 37 additions and 10 deletions
-6
View File
@@ -108,12 +108,6 @@ class CommandCSInfo : public Command
if (!ci->HasExt("NO_EXPIRE") && chanserv_expire && !Anope::NoExpire)
info["Expires on"] = Anope::strftime(ci->last_used + chanserv_expire);
}
if (ci->HasExt("SUSPENDED"))
{
Anope::string *by = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend_by"), *reason = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend_reason");
if (by != NULL)
info["Suspended"] = Anope::printf("[%s] %s", by->c_str(), (reason && !reason->empty() ? reason->c_str() : NO_REASON));
}
FOREACH_MOD(I_OnChanInfo, OnChanInfo(source, ci, info, show_all));
+18 -2
View File
@@ -52,6 +52,7 @@ class CommandCSSuspend : public Command
ci->ExtendMetadata("suspend:by", source.GetNick());
if (!reason.empty())
ci->ExtendMetadata("suspend:reason", reason);
ci->ExtendMetadata("suspend:time", stringify(Anope::CurTime));
if (ci->c)
{
@@ -133,6 +134,7 @@ class CommandCSUnSuspend : public Command
ci->Shrink("suspend:by");
ci->Shrink("suspend:reason");
ci->Shrink("suspend:expire");
ci->Shrink("suspend:time");
source.Reply(_("Channel \002%s\002 is now released."), ci->name.c_str());
@@ -161,11 +163,24 @@ class CSSuspend : public Module
commandcssuspend(this), commandcsunsuspend(this)
{
Implementation i[] = { I_OnPreChanExpire, I_OnCheckKick };
Implementation i[] = { I_OnChanInfo, I_OnPreChanExpire, I_OnCheckKick };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
// cs info output?
void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override
{
if (ci->HasExt("SUSPENDED"))
{
Anope::string *by = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:by"), *reason = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:reason"), *t = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:time");
info["Suspended"] = "This channel is \2suspended\2.";
if (by)
info["Suspended by"] = *by;
if (reason)
info["Suspend reason"] = *reason;
if (t)
info["Suspended on"] = Anope::strftime(convertTo<time_t>(*t), source.GetAccount(), true);
}
}
void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override
{
@@ -188,6 +203,7 @@ class CSSuspend : public Module
ci->Shrink("suspend:expire");
ci->Shrink("suspend:by");
ci->Shrink("suspend:reason");
ci->Shrink("suspend:time");
Log(LOG_NORMAL, "expire", ChanServ) << "Expiring suspend for " << ci->name;
}
+19 -2
View File
@@ -73,7 +73,7 @@ class CommandNSSuspend : public Command
nc->ExtendMetadata("suspend:reason", reason);
if (expiry_secs > 0)
nc->ExtendMetadata("suspend:expire", stringify(Anope::CurTime + expiry_secs));
nc->ExtendMetadata("suspend:time", stringify(Anope::CurTime));
for (unsigned i = 0; i < nc->aliases->size(); ++i)
{
@@ -148,6 +148,7 @@ class CommandNSUnSuspend : public Command
na->nc->Shrink("suspend:expire");
na->nc->Shrink("suspend:by");
na->nc->Shrink("suspend:reason");
na->nc->Shrink("suspend:time");
Log(LOG_ADMIN, source, this) << "for " << na->nick;
source.Reply(_("Nick %s is now released."), nick.c_str());
@@ -175,10 +176,25 @@ class NSSuspend : public Module
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnssuspend(this), commandnsunsuspend(this)
{
Implementation i[] = { I_OnPreNickExpire };
Implementation i[] = { I_OnPreNickExpire, I_OnNickInfo };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override
{
if (na->nc->HasExt("SUSPENDED"))
{
Anope::string *by = na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:by"), *reason = na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:reason"), *t = na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("suspend:time");
info["Suspended"] = "This nickname is \2suspended\2.";
if (by)
info["Suspended by"] = *by;
if (reason)
info["Suspend reason"] = *reason;
if (t)
info["Suspended on"] = Anope::strftime(convertTo<time_t>(*t), source.GetAccount(), true);
}
}
void OnPreNickExpire(NickAlias *na, bool &expire) anope_override
{
if (!na->nc->HasExt("SUSPENDED"))
@@ -200,6 +216,7 @@ class NSSuspend : public Module
na->nc->Shrink("suspend:expire");
na->nc->Shrink("suspend:by");
na->nc->Shrink("suspend:reason");
na->nc->Shrink("suspend:time");
Log(LOG_NORMAL, "expire", NickServ) << "Expiring suspend for " << na->nick;
}