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 CommandCSSetFounder : public Command
00017 {
00018 public:
00019 CommandCSSetFounder(Module *creator, const Anope::string &cname = "chanserv/set/founder") : Command(creator, cname, 2, 2)
00020 {
00021 this->SetDesc(_("Set the founder of a channel"));
00022 this->SetSyntax(_("\037channel\037 \037nick\037"));
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
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 (source.permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")))
00046 {
00047 source.Reply(ACCESS_DENIED);
00048 return;
00049 }
00050
00051 const NickAlias *na = NickAlias::Find(params[1]);
00052 if (!na)
00053 {
00054 source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str());
00055 return;
00056 }
00057
00058 NickCore *nc = na->nc;
00059 if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !source.HasPriv("chanserv/no-register-limit"))
00060 {
00061 source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str());
00062 return;
00063 }
00064
00065 Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to change the founder from " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << " to " << nc->display;
00066
00067 ci->SetFounder(nc);
00068
00069 source.Reply(_("Founder of \002%s\002 changed to \002%s\002."), ci->name.c_str(), na->nick.c_str());
00070
00071 return;
00072 }
00073
00074 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00075 {
00076 this->SendSyntax(source);
00077 source.Reply(" ");
00078 source.Reply(_("Changes the founder of a channel. The new nickname must\n"
00079 "be a registered one."), this->name.c_str());
00080 return true;
00081 }
00082 };
00083
00084 class CSSetFounder : public Module
00085 {
00086 CommandCSSetFounder commandcssetfounder;
00087
00088 public:
00089 CSSetFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00090 commandcssetfounder(this)
00091 {
00092 this->SetAuthor("Anope");
00093
00094 }
00095 };
00096
00097 MODULE_INIT(CSSetFounder)