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 CommandNSSetAutoOp : public Command
00017 {
00018 public:
00019 CommandNSSetAutoOp(Module *creator, const Anope::string &sname = "nickserv/set/autoop", size_t min = 1) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(_("Should services op you automatically."));
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 == NULL)
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_AUTOOP);
00043 source.Reply(_("Services will now autoop %s in channels."), nc->display.c_str());
00044 }
00045 else if (param.equals_ci("OFF"))
00046 {
00047 nc->UnsetFlag(NI_AUTOOP);
00048 source.Reply(_("Services will no longer autoop %s in channels."), nc->display.c_str());
00049 }
00050 else
00051 this->OnSyntaxError(source, "AUTOOP");
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(_("Sets whether you will be opped automatically. Set to ON to \n"
00066 "allow ChanServ to op you automatically when entering channels."));
00067 return true;
00068 }
00069 };
00070
00071 class CommandNSSASetAutoOp : public CommandNSSetAutoOp
00072 {
00073 public:
00074 CommandNSSASetAutoOp(Module *creator) : CommandNSSetAutoOp(creator, "nickserv/saset/autoop", 2)
00075 {
00076 this->ClearSyntax();
00077 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00078 }
00079
00080 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00081 {
00082 this->Run(source, params[0], params[1]);
00083 }
00084
00085 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00086 {
00087 this->SendSyntax(source);
00088 source.Reply(" ");
00089 source.Reply(_("Sets whether the given nickname will be opped automatically.\n"
00090 "Set to \002ON\002 to allow ChanServ to op the given nickname \n"
00091 "omatically when joining channels."));
00092 return true;
00093 }
00094 };
00095
00096 class NSSetAutoOp : public Module
00097 {
00098 CommandNSSetAutoOp commandnssetautoop;
00099 CommandNSSASetAutoOp commandnssasetautoop;
00100
00101 public:
00102 NSSetAutoOp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00103 commandnssetautoop(this), commandnssasetautoop(this)
00104 {
00105 this->SetAuthor("Anope");
00106
00107 }
00108 };
00109
00110 MODULE_INIT(NSSetAutoOp)