2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 /* $ModDesc: Channel half-operator mode provider */
24 class ModeChannelHalfOp : public ModeHandler
27 ModeChannelHalfOp(Module* parent);
28 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
29 unsigned int GetPrefixRank();
30 void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
31 void RemoveMode(User* user, irc::modestacker* stack = NULL);
33 ModResult AccessCheck(User* src, Channel*, std::string& value, bool adding)
35 if (!adding && src->nick == value)
37 return MOD_RES_PASSTHRU;
41 ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
45 levelrequired = OP_VALUE;
46 m_paramtype = TR_NICK;
49 unsigned int ModeChannelHalfOp::GetPrefixRank()
54 void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
56 const UserMembList* clist = channel->GetUsers();
58 for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
62 stack->Push(this->GetModeChar(), i->first->nick);
66 std::vector<std::string> parameters;
67 parameters.push_back(channel->name);
68 parameters.push_back("-h");
69 parameters.push_back(i->first->nick);
70 ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
76 void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack)
80 ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding)
82 return MODEACTION_ALLOW;
85 class ModuleHalfop : public Module
89 ModuleHalfop() : mh(this)
91 if (!ServerInstance->Modes->AddMode(&mh))
92 throw ModuleException("Could not add new modes!");
97 return Version("Channel half-operator mode provider", VF_VENDOR);
101 MODULE_INIT(ModuleHalfop)