Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "module.h"
00015
00016 class CommandNSSetPrivate : public Command
00017 {
00018 public:
00019 CommandNSSetPrivate(Module *creator, const Anope::string &sname = "nickserv/set/private", size_t min = 1) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(Anope::printf(_("Prevent the nickname from appearing in a \002%s%s LIST\002"), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str()));
00022 this->SetSyntax(_("{ON | OFF}"));
00023 }
00024
00025 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00026 {
00027 const NickAlias *na = NickAlias::Find(user);
00028 if (!na)
00029 {
00030 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00031 return;
00032 }
00033 NickCore *nc = na->nc;
00034
00035 EventReturn MOD_RESULT;
00036 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00037 if (MOD_RESULT == EVENT_STOP)
00038 return;
00039
00040 if (param.equals_ci("ON"))
00041 {
00042 nc->SetFlag(NI_PRIVATE);
00043 source.Reply(_("Private option is now \002on\002 for \002%s\002."), nc->display.c_str());
00044 }
00045 else if (param.equals_ci("OFF"))
00046 {
00047 nc->UnsetFlag(NI_PRIVATE);
00048 source.Reply(_("Private option is now \002off\002 for \002%s\002."), nc->display.c_str());
00049 }
00050 else
00051 this->OnSyntaxError(source, "PRIVATE");
00052
00053 return;
00054 }
00055
00056 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00057 {
00058 this->Run(source, source.nc->display, params[0]);
00059 }
00060
00061 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00062 {
00063 this->SendSyntax(source);
00064 source.Reply(" ");
00065 source.Reply(_("Turns %s's privacy option on or off for your nick.\n"
00066 "With \002PRIVATE\002 set, your nickname will not appear in\n"
00067 "nickname lists generated with %s's \002LIST\002 command.\n"
00068 "(However, anyone who knows your nickname can still get\n"
00069 "information on it using the \002INFO\002 command.)"),
00070 Config->NickServ.c_str(), Config->NickServ.c_str());
00071 return true;
00072 }
00073 };
00074
00075 class CommandNSSASetPrivate : public CommandNSSetPrivate
00076 {
00077 public:
00078 CommandNSSASetPrivate(Module *creator) : CommandNSSetPrivate(creator, "nickserv/saset/private", 2)
00079 {
00080 this->ClearSyntax();
00081 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00082 }
00083
00084 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00085 {
00086 this->Run(source, params[0], params[1]);
00087 }
00088
00089 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00090 {
00091 this->SendSyntax(source);
00092 source.Reply(" ");
00093 source.Reply(_("Turns %s's privacy option on or off for the nick.\n"
00094 "With \002PRIVATE\002 set, the nickname will not appear in\n"
00095 "nickname lists generated with %s's \002LIST\002 command.\n"
00096 "(However, anyone who knows the nickname can still get\n"
00097 "information on it using the \002INFO\002 command.)"),
00098 Config->NickServ.c_str(), Config->NickServ.c_str());
00099 return true;
00100 }
00101 };
00102
00103 class NSSetPrivate : public Module
00104 {
00105 CommandNSSetPrivate commandnssetprivate;
00106 CommandNSSASetPrivate commandnssasetprivate;
00107
00108 public:
00109 NSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00110 commandnssetprivate(this), commandnssasetprivate(this)
00111 {
00112 this->SetAuthor("Anope");
00113
00114 }
00115 };
00116
00117 MODULE_INIT(NSSetPrivate)