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 CommandCSSetChanstats : public Command
00017 {
00018 public:
00019 CommandCSSetChanstats(Module *creator) : Command(creator, "chanserv/set/chanstats", 2, 2)
00020 {
00021 this->SetDesc(_("Turn chanstat statistics on or off"));
00022 this->SetSyntax(_("\037channel\037 {ON | OFF}"));
00023 }
00024
00025 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00026 {
00027 ChannelInfo *ci = ChannelInfo::Find(params[0]);
00028 if (!ci)
00029 {
00030 source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
00031 return;
00032 }
00033
00034 EventReturn MOD_RESULT;
00035 FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
00036 if (MOD_RESULT == EVENT_STOP)
00037 return;
00038
00039 if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
00040 {
00041 source.Reply(ACCESS_DENIED);
00042 return;
00043 }
00044
00045 if (params[1].equals_ci("ON"))
00046 {
00047 ci->SetFlag(CI_STATS);
00048 source.Reply(_("Chanstats statistics are now enabled for this channel"));
00049 }
00050 else if (params[1].equals_ci("OFF"))
00051 {
00052 ci->UnsetFlag(CI_STATS);
00053 source.Reply(_("Chanstats statistics are now disabled for this channel"));
00054 }
00055 else
00056 this->OnSyntaxError(source, "");
00057 return;
00058 }
00059
00060 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00061 {
00062 this->SendSyntax(source);
00063 source.Reply(" ");
00064 source.Reply("Turn Chanstats channel statistics ON or OFF");
00065 return true;
00066 }
00067 };
00068
00069 class CSSetChanstats : public Module
00070 {
00071 CommandCSSetChanstats commandcssetchanstats;
00072 bool CSDefChanstats;
00073 public:
00074 CSSetChanstats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00075 commandcssetchanstats(this)
00076 {
00077 this->SetAuthor("Anope");
00078 Implementation i[] = { I_OnReload, I_OnChanRegistered };
00079 ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
00080 this->OnReload();
00081 }
00082 void OnReload() anope_override
00083 {
00084 ConfigReader config;
00085 CSDefChanstats = config.ReadFlag("chanstats", "CSDefChanstats", "0", 0);
00086 }
00087 void OnChanRegistered(ChannelInfo *ci) anope_override
00088 {
00089 if (CSDefChanstats)
00090 ci->SetFlag(CI_STATS);
00091 }
00092 };
00093
00094 MODULE_INIT(CSSetChanstats)