Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "module.h"
00014
00015 class CommandCSSetRestricted : public Command
00016 {
00017 public:
00018 CommandCSSetRestricted(Module *creator, const Anope::string &cname = "chanserv/set/restricted") : Command(creator, cname, 2, 2)
00019 {
00020 this->SetDesc(_("Restrict access to the channel"));
00021 this->SetSyntax(_("\037channel\037 {ON | OFF}"));
00022 }
00023
00024 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00025 {
00026 ChannelInfo *ci = ChannelInfo::Find(params[0]);
00027 if (ci == NULL)
00028 {
00029 source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
00030 return;
00031 }
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_RESTRICTED);
00047 source.Reply(_("Restricted access 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_RESTRICTED);
00052 source.Reply(_("Restricted access option for %s is now \002off\002."), ci->name.c_str());
00053 }
00054 else
00055 this->OnSyntaxError(source, "RESTRICTED");
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 \002restricted access\002 option for a\n"
00065 "channel. When \002restricted access\002 is set, users not on the access list will\n"
00066 "instead be kicked and banned from the channel."));
00067 return true;
00068 }
00069 };
00070
00071 class CSSetRestricted : public Module
00072 {
00073 CommandCSSetRestricted commandcssetrestricted;
00074
00075 public:
00076 CSSetRestricted(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00077 commandcssetrestricted(this)
00078 {
00079 this->SetAuthor("Anope");
00080
00081 }
00082 };
00083
00084 MODULE_INIT(CSSetRestricted)