diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_halfop.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/modules/m_halfop.cpp b/src/modules/m_halfop.cpp new file mode 100644 index 000000000..4ddf083d9 --- /dev/null +++ b/src/modules/m_halfop.cpp @@ -0,0 +1,91 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" + +class ModeChannelHalfOp : public ModeHandler +{ + public: + ModeChannelHalfOp(Module* parent); + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); + unsigned int GetPrefixRank(); + void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); + void RemoveMode(User* user, irc::modestacker* stack = NULL); +}; + +ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL) +{ + list = true; + prefix = '%'; + levelrequired = OP_VALUE; + m_paramtype = TR_NICK; +} + +unsigned int ModeChannelHalfOp::GetPrefixRank() +{ + return HALFOP_VALUE; +} + +void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack) +{ + const UserMembList* clist = channel->GetUsers(); + + for (UserMembCIter i = clist->begin(); i != clist->end(); i++) + { + if (stack) + { + stack->Push(this->GetModeChar(), i->first->nick); + } + else + { + std::vector<std::string> parameters; + parameters.push_back(channel->name); + parameters.push_back("-h"); + parameters.push_back(i->first->nick); + ServerInstance->SendMode(parameters, ServerInstance->FakeClient); + } + } + +} + +void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack) +{ +} + +ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) +{ + return MODEACTION_ALLOW; +} + +class ModuleHalfop : public Module +{ + ModeChannelHalfOp mh; + public: + ModuleHalfop() : mh(this) + { + if (!ServerInstance->Modes->AddMode(&mh)) + throw ModuleException("Could not add new modes!"); + } + + ~ModuleHalfop() + { + ServerInstance->Modes->DelMode(&mh); + } + + Version GetVersion() + { + return Version("Channel half-operator mode provider", VF_VENDOR|VF_COMMON); + } +}; + +MODULE_INIT(ModuleHalfop) |