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/>.
22 class ModeChannelHalfOp : public ModeHandler
25 ModeChannelHalfOp(Module* parent);
26 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
27 unsigned int GetPrefixRank();
28 void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
29 void RemoveMode(User* user, irc::modestacker* stack = NULL);
31 ModResult AccessCheck(User* src, Channel*, std::string& value, bool adding)
33 if (!adding && src->nick == value)
35 return MOD_RES_PASSTHRU;
39 ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
43 levelrequired = OP_VALUE;
44 m_paramtype = TR_NICK;
47 unsigned int ModeChannelHalfOp::GetPrefixRank()
52 void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
54 const UserMembList* clist = channel->GetUsers();
56 for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
60 stack->Push(this->GetModeChar(), i->first->nick);
64 std::vector<std::string> parameters;
65 parameters.push_back(channel->name);
66 parameters.push_back("-h");
67 parameters.push_back(i->first->nick);
68 ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
74 void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack)
78 ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding)
80 return MODEACTION_ALLOW;
83 class ModuleHalfop : public Module
87 ModuleHalfop() : mh(this)
89 if (!ServerInstance->Modes->AddMode(&mh))
90 throw ModuleException("Could not add new modes!");
95 ServerInstance->Modes->DelMode(&mh);
100 return Version("Channel half-operator mode provider", VF_VENDOR);
104 MODULE_INIT(ModuleHalfop)