diff options
author | Adam <Adam@anope.org> | 2013-05-08 11:13:48 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-08 11:13:48 -0400 |
commit | f843e7bd9032923bd231bc83536a89d32e59d857 (patch) | |
tree | 8897524a20e2a0d48fa8b38414a8d912ce7e3aae | |
parent | d7e2ab688b73a9316a75fd8cd39dc676a6e39a7f (diff) |
Fix suspend info output in info and improved it
-rw-r--r-- | modules/commands/cs_info.cpp | 6 | ||||
-rw-r--r-- | modules/commands/cs_suspend.cpp | 20 | ||||
-rw-r--r-- | modules/commands/ns_suspend.cpp | 21 |
3 files changed, 37 insertions, 10 deletions
diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index e26dc1970..61511aaaf 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -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)); diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 5fc6fe287..e19710e60 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -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; } diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index e0bb6bf93..5ca9ca81d 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -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; } |