diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 42 | ||||
-rw-r--r-- | src/commands/cmd_list.cpp | 16 | ||||
-rw-r--r-- | src/commands/cmd_names.cpp | 12 | ||||
-rw-r--r-- | src/commands/cmd_privmsg.cpp | 9 | ||||
-rw-r--r-- | src/commands/cmd_topic.cpp | 17 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 36 | ||||
-rw-r--r-- | src/commands/cmd_whois.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_banredirect.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_channames.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_denychans.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_knock.cpp | 27 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 19 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_remove.cpp | 30 |
14 files changed, 171 insertions, 90 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 0cf05f75d..505ef479a 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -28,7 +28,15 @@ #include <cstdarg> #include "mode.h" -static ChanModeReference ban(NULL, "ban"); +namespace +{ + ChanModeReference ban(NULL, "ban"); + ChanModeReference inviteonlymode(NULL, "inviteonly"); + ChanModeReference keymode(NULL, "key"); + ChanModeReference limitmode(NULL, "limit"); + ChanModeReference secretmode(NULL, "secret"); + ChanModeReference privatemode(NULL, "private"); +} Channel::Channel(const std::string &cname, time_t ts) { @@ -47,8 +55,9 @@ void Channel::SetMode(ModeHandler* mh, bool on) modes[mh->GetModeChar() - 65] = on; } -void Channel::SetModeParam(char mode, const std::string& parameter) +void Channel::SetModeParam(ModeHandler* mh, const std::string& parameter) { + char mode = mh->GetModeChar(); if (parameter.empty()) { custom_mode_params.erase(mode); @@ -61,19 +70,6 @@ void Channel::SetModeParam(char mode, const std::string& parameter) } } -void Channel::SetModeParam(ModeHandler* mode, const std::string& parameter) -{ - SetModeParam(mode->GetModeChar(), parameter); -} - -std::string Channel::GetModeParameter(char mode) -{ - CustomModeList::iterator n = custom_mode_params.find(mode); - if (n != custom_mode_params.end()) - return n->second; - return ""; -} - std::string Channel::GetModeParameter(ModeHandler* mode) { CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar()); @@ -264,7 +260,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co // then this entire section is skipped if (MOD_RESULT == MOD_RES_PASSTHRU) { - std::string ckey = chan->GetModeParameter('k'); + std::string ckey = chan->GetModeParameter(keymode); bool invited = user->IsInvited(chan); bool can_bypass = ServerInstance->Config->InvBypassModes && invited; @@ -279,7 +275,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co } } - if (chan->IsModeSet('i')) + if (chan->IsModeSet(inviteonlymode)) { FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan)); if (!MOD_RESULT.check(invited)) @@ -289,7 +285,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co } } - std::string limit = chan->GetModeParameter('l'); + std::string limit = chan->GetModeParameter(limitmode); if (!limit.empty()) { FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); @@ -632,13 +628,17 @@ const char* Channel::ChanModes(bool showkey) if(this->modes[n]) { scratch.push_back(n + 65); + ModeHandler* mh = ServerInstance->Modes->FindMode(n+'A', MODETYPE_CHANNEL); + if (!mh) + continue; + if (n == 'k' - 65 && !showkey) { sparam += " <key>"; } else { - const std::string param = this->GetModeParameter(n + 65); + const std::string param = this->GetModeParameter(mh); if (!param.empty()) { sparam += ' '; @@ -657,7 +657,7 @@ const char* Channel::ChanModes(bool showkey) */ void Channel::UserList(User *user) { - if (this->IsModeSet('s') && !this->HasUser(user) && !user->HasPrivPermission("channels/auspex")) + if (this->IsModeSet(secretmode) && !this->HasUser(user) && !user->HasPrivPermission("channels/auspex")) { user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str()); return; @@ -665,7 +665,7 @@ void Channel::UserList(User *user) std::string list = user->nick; list.push_back(' '); - list.push_back(this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '='); + list.push_back(this->IsModeSet(secretmode) ? '@' : this->IsModeSet(privatemode) ? '*' : '='); list.push_back(' '); list.append(this->name).append(" :"); std::string::size_type pos = list.size(); diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 2f417bc04..5962e2547 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -27,10 +27,20 @@ */ class CommandList : public Command { + ChanModeReference secretmode; + ChanModeReference privatemode; + public: /** Constructor for list. */ - CommandList ( Module* parent) : Command(parent,"LIST", 0, 0) { Penalty = 5; } + CommandList(Module* parent) + : Command(parent,"LIST", 0, 0) + , secretmode(creator, "secret") + , privatemode(creator, "private") + { + Penalty = 5; + } + /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -82,14 +92,14 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User // if the channel is not private/secret, OR the user is on the channel anyway bool n = (i->second->HasUser(user) || user->HasPrivPermission("channels/auspex")); - if (!n && i->second->IsModeSet('p')) + if (!n && i->second->IsModeSet(privatemode)) { /* Channel is +p and user is outside/not privileged */ user->WriteNumeric(322, "%s * %ld :",user->nick.c_str(), users); } else { - if (n || !i->second->IsModeSet('s')) + if (n || !i->second->IsModeSet(secretmode)) { /* User is in the channel/privileged, channel is not +s */ user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str()); diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index 1f0de91f1..c74d18c23 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -27,10 +27,18 @@ */ class CommandNames : public Command { + ChanModeReference secretmode; + public: /** Constructor for names. */ - CommandNames ( Module* parent) : Command(parent,"NAMES",0,0) { syntax = "{<channel>{,<channel>}}"; } + CommandNames(Module* parent) + : Command(parent, "NAMES", 0, 0) + , secretmode(parent, "secret") + { + syntax = "{<channel>{,<channel>}}"; + } + /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -58,7 +66,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User c = ServerInstance->FindChan(parameters[0]); if (c) { - if ((c->IsModeSet('s')) && (!c->HasUser(user))) + if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 7de3bf924..5519be2fa 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -28,9 +28,14 @@ namespace class MessageCommandBase : public Command { + ChanModeReference moderatedmode; + ChanModeReference noextmsgmode; + public: MessageCommandBase(Module* parent, MessageType mt) : Command(parent, MessageTypeString[mt], 2, 2) + , moderatedmode(parent, "moderated") + , noextmsgmode(parent, "noextmsg") { syntax = "<target>{,<target>} <message>"; } @@ -105,13 +110,13 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para { if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE) { - if (chan->IsModeSet('n') && !chan->HasUser(user)) + if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user)) { user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; } - if (chan->IsModeSet('m')) + if (chan->IsModeSet(moderatedmode)) { user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index e8c555e90..997fb6a91 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -29,10 +29,21 @@ */ class CommandTopic : public Command { + ChanModeReference secretmode; + ChanModeReference topiclockmode; + public: /** Constructor for topic. */ - CommandTopic ( Module* parent) : Command(parent,"TOPIC",1, 2) { syntax = "<channel> [<topic>]"; Penalty = 2; } + CommandTopic(Module* parent) + : Command(parent, "TOPIC", 1, 2) + , secretmode(parent, "secret") + , topiclockmode(parent, "topiclock") + { + syntax = "<channel> [<topic>]"; + Penalty = 2; + } + /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -59,7 +70,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User { if (c) { - if ((c->IsModeSet('s')) && (!c->HasUser(user))) + if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; @@ -98,7 +109,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User user->WriteNumeric(442, "%s %s :You're not on that channel!", user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } - if (c->IsModeSet('t') && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE)) + if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE)) { user->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 82d541a2a..a78f03793 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -39,13 +39,32 @@ class CommandWho : public Command bool opt_local; bool opt_far; bool opt_time; + ChanModeReference secretmode; + ChanModeReference privatemode; + + Channel* get_first_visible_channel(User *u) + { + UCListIter i = u->chans.begin(); + while (i != u->chans.end()) + { + Channel* c = *i++; + if (!c->IsModeSet(secretmode)) + return c; + } + return NULL; + } public: /** Constructor for who. */ - CommandWho ( Module* parent) : Command(parent,"WHO", 1) { + CommandWho(Module* parent) + : Command(parent, "WHO", 1) + , secretmode(parent, "secret") + , privatemode(parent, "private") + { syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]"; } + void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults); /** Handle command. * @param parameters The parameters to the comamnd @@ -57,19 +76,6 @@ class CommandWho : public Command bool whomatch(User* cuser, User* user, const char* matchtext); }; - -static Channel* get_first_visible_channel(User *u) -{ - UCListIter i = u->chans.begin(); - while (i != u->chans.end()) - { - Channel* c = *i++; - if (!c->IsModeSet('s')) - return c; - } - return NULL; -} - bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) { bool match = false; @@ -180,7 +186,7 @@ bool CommandWho::CanView(Channel* chan, User* user) if (user->HasPrivPermission("users/auspex")) return true; /* Cant see inside a +s or a +p channel unless we are a member (see above) */ - else if (!chan->IsModeSet('s') && !chan->IsModeSet('p')) + else if (!chan->IsModeSet(secretmode) && !chan->IsModeSet(privatemode)) return true; return false; diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index 9048184f6..4893c1251 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -28,6 +28,9 @@ */ class CommandWhois : public SplitCommand { + ChanModeReference secretmode; + ChanModeReference privatemode; + void SplitChanList(User* source, User* dest, const std::string& cl); void DoWhois(User* user, User* dest, unsigned long signon, unsigned long idle); std::string ChannelList(User* source, User* dest, bool spy); @@ -35,7 +38,15 @@ class CommandWhois : public SplitCommand public: /** Constructor for whois. */ - CommandWhois ( Module* parent) : SplitCommand(parent,"WHOIS", 1) { Penalty = 2; syntax = "<nick>{,<nick>}"; } + CommandWhois(Module* parent) + : SplitCommand(parent, "WHOIS", 1) + , secretmode(parent, "secret") + , privatemode(parent, "private") + { + Penalty = 2; + syntax = "<nick>{,<nick>}"; + } + /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -56,7 +67,7 @@ std::string CommandWhois::ChannelList(User* source, User* dest, bool spy) /* If the target is the sender, neither +p nor +s is set, or * the channel contains the user, it is not a spy channel */ - if (spy != (source == dest || !(c->IsModeSet('p') || c->IsModeSet('s')) || c->HasUser(source))) + if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source))) list.append(c->GetPrefixChar(dest)).append(c->name).append(" "); } diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 496b0c2c9..ddc79bf20 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -217,15 +217,18 @@ class ModuleBanRedirect : public Module { BanRedirect re; bool nofollow; + ChanModeReference limitmode; + ChanModeReference redirectmode; public: ModuleBanRedirect() - : re(this) + : re(this) + , nofollow(false) + , limitmode(this, "limit") + , redirectmode(this, "redirect") { - nofollow = false; } - void init() CXX11_OVERRIDE { ServerInstance->Modes->AddModeWatcher(&re); @@ -311,9 +314,9 @@ class ModuleBanRedirect : public Module std::string destlimit; if (destchan) - destlimit = destchan->GetModeParameter('l'); + destlimit = destchan->GetModeParameter(limitmode); - if(destchan && ServerInstance->Modules->Find("m_redirect.so") && destchan->IsModeSet('L') && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str()))) + if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str()))) { user->WriteNumeric(474, "%s %s :Cannot join channel (You are banned)", user->nick.c_str(), chan->name.c_str()); return MOD_RES_DENY; diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index 29cbdca91..aed3ec226 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -49,9 +49,13 @@ class ModuleChannelNames : public Module NewIsChannelHandler myhandler; caller1<bool, const std::string&> rememberer; bool badchan; + ChanModeReference permchannelmode; public: - ModuleChannelNames() : rememberer(ServerInstance->IsChannel), badchan(false) + ModuleChannelNames() + : rememberer(ServerInstance->IsChannel) + , badchan(false) + , permchannelmode(this, "permanent") { } @@ -76,11 +80,11 @@ class ModuleChannelNames : public Module while (c2 != chanvec.rend()) { Channel* c = *c2++; - if (c->IsModeSet('P') && c->GetUserCounter()) + if (c->IsModeSet(permchannelmode) && c->GetUserCounter()) { std::vector<std::string> modes; modes.push_back(c->name); - modes.push_back("-P"); + modes.push_back("-" + permchannelmode->GetModeChar()); ServerInstance->Modes->Process(modes, ServerInstance->FakeClient); } diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 0b82d0750..60af0e391 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -24,7 +24,14 @@ class ModuleDenyChannels : public Module { + ChanModeReference redirectmode; + public: + ModuleDenyChannels() + : redirectmode(this, "redirect") + { + } + void init() CXX11_OVERRIDE { Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash }; @@ -110,7 +117,7 @@ class ModuleDenyChannels : public Module { /* simple way to avoid potential loops: don't redirect to +L channels */ Channel *newchan = ServerInstance->FindChan(redirect); - if ((!newchan) || (!(newchan->IsModeSet('L')))) + if ((!newchan) || (!newchan->IsModeSet(redirectmode))) { user->WriteNumeric(926, "%s %s :Channel %s is forbidden, redirecting to %s: %s",user->nick.c_str(),cname.c_str(),cname.c_str(),redirect.c_str(), reason.c_str()); Channel::JoinUser(user, redirect); diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index b440328bd..3aa49094e 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -25,10 +25,16 @@ */ class CommandKnock : public Command { + SimpleChannelModeHandler& noknockmode; + ChanModeReference inviteonlymode; + public: bool sendnotice; bool sendnumeric; - CommandKnock(Module* Creator) : Command(Creator,"KNOCK", 2, 2) + CommandKnock(Module* Creator, SimpleChannelModeHandler& Noknockmode) + : Command(Creator,"KNOCK", 2, 2) + , noknockmode(Noknockmode) + , inviteonlymode(Creator, "inviteonly") { syntax = "<channel> <reason>"; Penalty = 5; @@ -49,13 +55,13 @@ class CommandKnock : public Command return CMD_FAILURE; } - if (c->IsModeSet('K')) + if (c->IsModeSet(noknockmode)) { user->WriteNumeric(480, "%s :Can't KNOCK on %s, +K is set.",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } - if (!c->IsModeSet('i')) + if (!c->IsModeSet(inviteonlymode)) { user->WriteNumeric(480, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; @@ -77,20 +83,15 @@ class CommandKnock : public Command } }; -/** Handles channel mode +K - */ -class Knock : public SimpleChannelModeHandler -{ - public: - Knock(Module* Creator) : SimpleChannelModeHandler(Creator, "noknock", 'K') { } -}; - class ModuleKnock : public Module { + SimpleChannelModeHandler kn; CommandKnock cmd; - Knock kn; + public: - ModuleKnock() : cmd(this), kn(this) + ModuleKnock() + : kn(this, "noknock", 'K') + , cmd(this, kn) { } diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 1bc05a4ef..b29c1c676 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -30,8 +30,19 @@ class ModuleOverride : public Module { bool RequireKey; bool NoisyOverride; + ChanModeReference topiclock; + ChanModeReference inviteonly; + ChanModeReference key; + ChanModeReference limit; public: + ModuleOverride() + : topiclock(this, "topiclock") + , inviteonly(this, "inviteonly") + , key(this, "key") + , limit(this, "limit") + { + } void init() CXX11_OVERRIDE { @@ -68,7 +79,7 @@ class ModuleOverride : public Module { if (IS_LOCAL(source) && source->IsOper() && CanOverride(source, "TOPIC")) { - if (!channel->HasUser(source) || (channel->IsModeSet('t') && channel->GetPrefixValue(source) < HALFOP_VALUE)) + if (!channel->HasUser(source) || (channel->IsModeSet(topiclock) && channel->GetPrefixValue(source) < HALFOP_VALUE)) { ServerInstance->SNO->WriteGlobalSno('v',source->nick+" used oper override to change a topic on "+channel->name); } @@ -120,7 +131,7 @@ class ModuleOverride : public Module { if (chan) { - if (chan->IsModeSet('i') && (CanOverride(user,"INVITE"))) + if (chan->IsModeSet(inviteonly) && (CanOverride(user,"INVITE"))) { if (!IS_LOCAL(user)->IsInvited(chan)) { @@ -138,7 +149,7 @@ class ModuleOverride : public Module return MOD_RES_ALLOW; } - if (chan->IsModeSet('k') && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k')) + if (chan->IsModeSet(key) && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter(key)) { if (RequireKey && keygiven != "override") { @@ -153,7 +164,7 @@ class ModuleOverride : public Module return MOD_RES_ALLOW; } - if (chan->IsModeSet('l') && (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter('l'))) && (CanOverride(user,"LIMIT"))) + if (chan->IsModeSet(limit) && (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter(limit))) && (CanOverride(user,"LIMIT"))) { if (RequireKey && keygiven != "override") { diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index cc0fe1976..7af4818c3 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -95,12 +95,14 @@ class ModuleRedirect : public Module { Redirect re; AntiRedirect re_u; + ChanModeReference limitmode; bool UseUsermode; public: ModuleRedirect() : re(this) , re_u(this) + , limitmode(this, "limit") { } @@ -130,9 +132,9 @@ class ModuleRedirect : public Module { if (chan) { - if (chan->IsModeSet(re) && chan->IsModeSet('l')) + if (chan->IsModeSet(re) && chan->IsModeSet(limitmode)) { - if (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter('l'))) + if (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter(limitmode))) { std::string channel = chan->GetModeParameter(&re); diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 7f274f00c..19b774f04 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -35,10 +35,13 @@ class RemoveBase : public Command { bool& supportnokicks; + ChanModeReference& nokicksmode; public: - RemoveBase(Module* Creator, bool& snk, const char* cmdn) - : Command(Creator, cmdn, 2, 3), supportnokicks(snk) + RemoveBase(Module* Creator, bool& snk, ChanModeReference& nkm, const char* cmdn) + : Command(Creator, cmdn, 2, 3) + , supportnokicks(snk) + , nokicksmode(nkm) { } @@ -47,9 +50,6 @@ class RemoveBase : public Command User* target; Channel* channel; std::string reason; - std::string protectkey; - std::string founderkey; - bool hasnokicks; /* Set these to the parameters needed, the new version of this module switches it's parameters around * supplying a new command with the new order while keeping the old /remove with the older order. @@ -81,8 +81,6 @@ class RemoveBase : public Command int ulevel = channel->GetPrefixValue(user); int tlevel = channel->GetPrefixValue(target); - hasnokicks = (ServerInstance->Modules->Find("m_nokicks.so") && channel->IsModeSet('Q')); - if (ServerInstance->ULine(target->server)) { user->WriteNumeric(482, "%s %s :Only a u-line may remove a u-line from a channel.", user->nick.c_str(), channame.c_str()); @@ -90,7 +88,7 @@ class RemoveBase : public Command } /* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */ - if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks)) + if ((!IS_LOCAL(user)) || (!supportnokicks) || (!channel->IsModeSet(nokicksmode))) { /* We'll let everyone remove their level and below, eg: * ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) @@ -128,7 +126,7 @@ class RemoveBase : public Command else { /* m_nokicks.so was loaded and +Q was set, block! */ - user->WriteServ( "484 %s %s :Can't remove user %s from channel (+Q set)", user->nick.c_str(), channel->name.c_str(), target->nick.c_str()); + user->WriteServ( "484 %s %s :Can't remove user %s from channel (nokicks mode is set)", user->nick.c_str(), channel->name.c_str(), target->nick.c_str()); return CMD_FAILURE; } @@ -142,8 +140,8 @@ class RemoveBase : public Command class CommandRemove : public RemoveBase { public: - CommandRemove(Module* Creator, bool& snk) - : RemoveBase(Creator, snk, "REMOVE") + CommandRemove(Module* Creator, bool& snk, ChanModeReference& nkm) + : RemoveBase(Creator, snk, nkm, "REMOVE") { syntax = "<nick> <channel> [<reason>]"; TRANSLATE3(TR_NICK, TR_TEXT, TR_TEXT); @@ -168,8 +166,8 @@ class CommandRemove : public RemoveBase class CommandFpart : public RemoveBase { public: - CommandFpart(Module* Creator, bool& snk) - : RemoveBase(Creator, snk, "FPART") + CommandFpart(Module* Creator, bool& snk, ChanModeReference& nkm) + : RemoveBase(Creator, snk, nkm, "FPART") { syntax = "<channel> <nick> [<reason>]"; TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT); @@ -191,12 +189,16 @@ class CommandFpart : public RemoveBase class ModuleRemove : public Module { + ChanModeReference nokicksmode; CommandRemove cmd1; CommandFpart cmd2; bool supportnokicks; public: - ModuleRemove() : cmd1(this, supportnokicks), cmd2(this, supportnokicks) + ModuleRemove() + : nokicksmode(this, "nokick") + , cmd1(this, supportnokicks, nokicksmode) + , cmd2(this, supportnokicks, nokicksmode) { } |