diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-03 17:12:36 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-03 17:12:36 +0000 |
commit | 17cc3b8490692ee3a225f052425deb43a45b98db (patch) | |
tree | 124959537dd3607d49302fb78f43a8da188e1fc3 /src/modules/m_halfop.cpp | |
parent | 80df092fa38524a415a3bb258384dde819ec86e3 (diff) |
Create m_halfop
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11997 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_halfop.cpp')
-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) |