1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 class ModeChannelHalfOp : public ModeHandler
19 ModeChannelHalfOp(Module* parent);
20 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
21 unsigned int GetPrefixRank();
22 void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
23 void RemoveMode(User* user, irc::modestacker* stack = NULL);
25 ModResult AccessCheck(User* src, Channel*, std::string& value, bool adding)
27 if (!adding && src->nick == value)
29 return MOD_RES_PASSTHRU;
33 ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
37 levelrequired = OP_VALUE;
38 m_paramtype = TR_NICK;
41 unsigned int ModeChannelHalfOp::GetPrefixRank()
46 void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
48 const UserMembList* clist = channel->GetUsers();
50 for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
54 stack->Push(this->GetModeChar(), i->first->nick);
58 std::vector<std::string> parameters;
59 parameters.push_back(channel->name);
60 parameters.push_back("-h");
61 parameters.push_back(i->first->nick);
62 ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
68 void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack)
72 ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding)
74 return MODEACTION_ALLOW;
77 class ModuleHalfop : public Module
81 ModuleHalfop() : mh(this)
83 if (!ServerInstance->Modes->AddMode(&mh))
84 throw ModuleException("Could not add new modes!");
89 ServerInstance->Modes->DelMode(&mh);
94 return Version("Channel half-operator mode provider", VF_VENDOR);
98 MODULE_INIT(ModuleHalfop)