ns_set_secure.cpp

Go to the documentation of this file.
00001 /* NickServ core functions
00002  *
00003  * (C) 2003-2012 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church.
00010  */
00011 
00012 /*************************************************************************/
00013 
00014 #include "module.h"
00015 
00016 class CommandNSSetSecure : public Command
00017 {
00018  public:
00019         CommandNSSetSecure(Module *creator, const Anope::string &sname = "nickserv/set/secure", size_t min = 1) : Command(creator, sname, min, min + 1)
00020         {
00021                 this->SetDesc(_("Turn nickname security on or off"));
00022                 this->SetSyntax(_("{ON | OFF}"));
00023         }
00024 
00025         void Run(CommandSource &source, const Anope::string &user, const Anope::string &param)
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_SECURE);
00043                         source.Reply(_("Secure 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_SECURE);
00048                         source.Reply(_("Secure option is now \002off\002 for \002%s\002."), nc->display.c_str());
00049                 }
00050                 else
00051                         this->OnSyntaxError(source, "SECURE");
00052         }
00053 
00054         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00055         {
00056                 this->Run(source, source.nc->display, params[0]);
00057         }
00058 
00059         bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00060         {
00061                 this->SendSyntax(source);
00062                 source.Reply(" ");
00063                 source.Reply(_("Turns %s's security features on or off for your\n"
00064                                 "nick. With \002SECURE\002 set, you must enter your password\n"
00065                                 "before you will be recognized as the owner of the nick,\n"
00066                                 "regardless of whether your address is on the access\n"
00067                                 "list. However, if you are on the access list, %s\n"
00068                                 "will not auto-kill you regardless of the setting of the\n"
00069                                 "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
00070                 return true;
00071         }
00072 };
00073 
00074 class CommandNSSASetSecure : public CommandNSSetSecure
00075 {
00076  public:
00077         CommandNSSASetSecure(Module *creator) : CommandNSSetSecure(creator, "nickserv/saset/secure", 2)
00078         {
00079                 this->ClearSyntax();
00080                 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00081         }
00082 
00083         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00084         {
00085                 this->Run(source, params[0], params[1]);
00086         }
00087 
00088         bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00089         {
00090                 this->SendSyntax(source);
00091                 source.Reply(" ");
00092                 source.Reply(_("Turns %s's security features on or off for your\n"
00093                                 "nick. With \002SECURE\002 set, you must enter your password\n"
00094                                 "before you will be recognized as the owner of the nick,\n"
00095                                 "regardless of whether your address is on the access\n"
00096                                 "list. However, if you are on the access list, %s\n"
00097                                 "will not auto-kill you regardless of the setting of the\n"
00098                                 "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
00099                 return true;
00100         }
00101 };
00102 
00103 class NSSetSecure : public Module
00104 {
00105         CommandNSSetSecure commandnssetsecure;
00106         CommandNSSASetSecure commandnssasetsecure;
00107 
00108  public:
00109         NSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00110                 commandnssetsecure(this), commandnssasetsecure(this)
00111         {
00112                 this->SetAuthor("Anope");
00113 
00114         }
00115 };
00116 
00117 MODULE_INIT(NSSetSecure)