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);
26 ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
30 levelrequired = OP_VALUE;
31 m_paramtype = TR_NICK;
34 unsigned int ModeChannelHalfOp::GetPrefixRank()
39 void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
41 const UserMembList* clist = channel->GetUsers();
43 for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
47 stack->Push(this->GetModeChar(), i->first->nick);
51 std::vector<std::string> parameters;
52 parameters.push_back(channel->name);
53 parameters.push_back("-h");
54 parameters.push_back(i->first->nick);
55 ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
61 void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack)
65 ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding)
67 return MODEACTION_ALLOW;
70 class ModuleHalfop : public Module
74 ModuleHalfop() : mh(this)
76 if (!ServerInstance->Modes->AddMode(&mh))
77 throw ModuleException("Could not add new modes!");
82 ServerInstance->Modes->DelMode(&mh);
87 return Version("Channel half-operator mode provider", VF_VENDOR);
91 MODULE_INIT(ModuleHalfop)