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 CommandCSSetPeace : public Command
00017 {
00018 public:
00019 CommandCSSetPeace(Module *creator, const Anope::string &cname = "chanserv/set/peace") : Command(creator, cname, 2, 2)
00020 {
00021 this->SetDesc(_("Regulate the use of critical commands"));
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 == NULL)
00029 {
00030 source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
00031 return;
00032 }
00033 EventReturn MOD_RESULT;
00034 FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
00035 if (MOD_RESULT == EVENT_STOP)
00036 return;
00037
00038 if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
00039 {
00040 source.Reply(ACCESS_DENIED);
00041 return;
00042 }
00043
00044 if (params[1].equals_ci("ON"))
00045 {
00046 ci->SetFlag(CI_PEACE);
00047 source.Reply(_("Peace option for %s is now \002on\002."), ci->name.c_str());
00048 }
00049 else if (params[1].equals_ci("OFF"))
00050 {
00051 ci->UnsetFlag(CI_PEACE);
00052 source.Reply(_("Peace option for %s is now \002off\002."), ci->name.c_str());
00053 }
00054 else
00055 this->OnSyntaxError(source, "PEACE");
00056
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(_("Enables or disables the \002peace\002 option for a channel.\n"
00065 "When \002peace\002 is set, a user won't be able to kick,\n"
00066 "ban or remove a channel status of a user that has\n"
00067 "a level superior or equal to his via %s commands."), source.service->nick.c_str());
00068 return true;
00069 }
00070 };
00071
00072 class CSSetPeace : public Module
00073 {
00074 CommandCSSetPeace commandcssetpeace;
00075
00076 public:
00077 CSSetPeace(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00078 commandcssetpeace(this)
00079 {
00080 this->SetAuthor("Anope");
00081
00082 }
00083 };
00084
00085 MODULE_INIT(CSSetPeace)