diff options
author | Adam <Adam@anope.org> | 2013-07-01 22:17:52 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-07-01 22:17:52 -0400 |
commit | 1a3d9a016d3adc49788bbff73aac9b3b5ea85b17 (patch) | |
tree | c0ecf92ed768473bc82ff64a7fce827245f37ba9 /modules/commands/ns_list.cpp | |
parent | 518182ac9204f815258b0de91b3f884d8efa1502 (diff) |
Change extensible keys to require explicitly having a type defined for it. Completely modularize more features like bs_kick, entrymsg, log, mode, etc. Move fantasy to its own module. Move greet to its own module.
Diffstat (limited to 'modules/commands/ns_list.cpp')
-rw-r--r-- | modules/commands/ns_list.cpp | 112 |
1 files changed, 108 insertions, 4 deletions
diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index a4e73e857..b1ab19971 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -83,9 +83,9 @@ class CommandNSList : public Command const NickAlias *na = it->second; /* Don't show private nicks to non-services admins. */ - if (na->nc->HasExt("PRIVATE") && !is_servadmin && na->nc != mync) + if (na->nc->HasExt("NS_PRIVATE") && !is_servadmin && na->nc != mync) continue; - else if (nsnoexpire && !na->HasExt("NO_EXPIRE")) + else if (nsnoexpire && !na->HasExt("NS_NO_EXPIRE")) continue; else if (suspended && !na->nc->HasExt("SUSPENDED")) continue; @@ -101,7 +101,7 @@ class CommandNSList : public Command if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= listmax) { bool isnoexpire = false; - if (is_servadmin && na->HasExt("NO_EXPIRE")) + if (is_servadmin && na->HasExt("NS_NO_EXPIRE")) isnoexpire = true; ListFormatter::ListEntry entry; @@ -177,14 +177,118 @@ class CommandNSList : public Command } }; + +class CommandNSSetPrivate : public Command +{ + public: + CommandNSSetPrivate(Module *creator, const Anope::string &sname = "nickserv/set/private", size_t min = 1) : Command(creator, sname, min, min + 1) + { + this->SetDesc(_("Prevent the nickname from appearing in the LIST command")); + this->SetSyntax(_("{ON | OFF}")); + } + + void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) + { + const NickAlias *na = NickAlias::Find(user); + if (!na) + { + source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); + return; + } + NickCore *nc = na->nc; + + EventReturn MOD_RESULT; + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + if (MOD_RESULT == EVENT_STOP) + return; + + if (param.equals_ci("ON")) + { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable private for " << nc->display; + nc->Extend<bool>("NS_PRIVATE"); + source.Reply(_("Private option is now \002on\002 for \002%s\002."), nc->display.c_str()); + } + else if (param.equals_ci("OFF")) + { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable private for " << nc->display; + nc->Shrink<bool>("NS_PRIVATE"); + source.Reply(_("Private option is now \002off\002 for \002%s\002."), nc->display.c_str()); + } + else + this->OnSyntaxError(source, "PRIVATE"); + } + + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + this->Run(source, source.nc->display, params[0]); + } + + bool OnHelp(CommandSource &source, const Anope::string &) anope_override + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Turns %s's privacy option on or off for your nick.\n" + "With \002PRIVATE\002 set, your nickname will not appear in\n" + "nickname lists generated with %s's \002LIST\002 command.\n" + "(However, anyone who knows your nickname can still get\n" + "information on it using the \002INFO\002 command.)"), + source.service->nick.c_str(), source.service->nick.c_str()); + return true; + } +}; + +class CommandNSSASetPrivate : public CommandNSSetPrivate +{ + public: + CommandNSSASetPrivate(Module *creator) : CommandNSSetPrivate(creator, "nickserv/saset/private", 2) + { + this->ClearSyntax(); + this->SetSyntax(_("\037nickname\037 {ON | OFF}")); + } + + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + this->Run(source, params[0], params[1]); + } + + bool OnHelp(CommandSource &source, const Anope::string &) anope_override + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Turns %s's privacy option on or off for the nick.\n" + "With \002PRIVATE\002 set, the nickname will not appear in\n" + "nickname lists generated with %s's \002LIST\002 command.\n" + "(However, anyone who knows the nickname can still get\n" + "information on it using the \002INFO\002 command.)"), + source.service->nick.c_str(), source.service->nick.c_str()); + return true; + } +}; + + class NSList : public Module { CommandNSList commandnslist; + CommandNSSetPrivate commandnssetprivate; + CommandNSSASetPrivate commandnssasetprivate; + + SerializableExtensibleItem<bool> priv; + public: NSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnslist(this) + commandnslist(this), commandnssetprivate(this), commandnssasetprivate(this), + priv(this, "NS_PRIVATE") + { + } + + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_all) anope_override { + if (!show_all) + return; + + if (priv.HasExt(na->nc)) + info.AddOption(_("Private")); } }; |