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 CommandNSSetChanstats : public Command
00017 {
00018 public:
00019 CommandNSSetChanstats(Module *creator, const Anope::string &sname = "nickserv/set/chanstats", size_t min = 1 ) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(_("Turn chanstat statistic on or off"));
00022 this->SetSyntax(_("{ON | OFF}"));
00023 }
00024 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00025 {
00026 NickAlias *na = NickAlias::Find(user);
00027 if (!na)
00028 {
00029 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00030 return;
00031 }
00032
00033 EventReturn MOD_RESULT;
00034 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, na->nc, param));
00035 if (MOD_RESULT == EVENT_STOP)
00036 return;
00037
00038 if (param.equals_ci("ON"))
00039 {
00040 na->nc->SetFlag(NI_STATS);
00041 source.Reply(_("Chanstat statistics are now enabled for your nick"));
00042 }
00043 else if (param.equals_ci("OFF"))
00044 {
00045 na->nc->UnsetFlag(NI_STATS);
00046 source.Reply(_("Chanstat statistics are now disabled for your nick"));
00047 }
00048 else
00049 this->OnSyntaxError(source, "CHANSTATS");
00050
00051 return;
00052 }
00053
00054 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) 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 Chanstats statistics ON or OFF"));
00064 return true;
00065 }
00066 };
00067
00068 class CommandNSSASetChanstats : public CommandNSSetChanstats
00069 {
00070 public:
00071 CommandNSSASetChanstats(Module *creator) : CommandNSSetChanstats(creator, "nickserv/saset/chanstats", 2)
00072 {
00073 this->ClearSyntax();
00074 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00075 }
00076
00077 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00078 {
00079 this->Run(source, params[0], params[1]);
00080 }
00081
00082 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00083 {
00084 this->SendSyntax(source);
00085 source.Reply(" ");
00086 source.Reply(_("Turns chanstats channel statistics ON or OFF for this user"));
00087 return true;
00088 }
00089 };
00090
00091 class NSSetChanstats : public Module
00092 {
00093 CommandNSSetChanstats commandnssetchanstats;
00094 CommandNSSASetChanstats commandnssasetchanstats;
00095 bool NSDefChanstats;
00096
00097 public:
00098 NSSetChanstats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00099 commandnssetchanstats(this), commandnssasetchanstats(this)
00100 {
00101 this->SetAuthor("Anope");
00102
00103 Implementation i[] = { I_OnReload, I_OnNickRegister };
00104 ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
00105
00106 this->OnReload();
00107 }
00108 void OnReload() anope_override
00109 {
00110 ConfigReader config;
00111 NSDefChanstats = config.ReadFlag("chanstats", "NSDefChanstats", "0", 0);
00112 }
00113 void OnNickRegister(NickAlias *na) anope_override
00114 {
00115 if (NSDefChanstats)
00116 na->nc->SetFlag(NI_STATS);
00117 }
00118 };
00119
00120 MODULE_INIT(NSSetChanstats)