From 17cc3b8490692ee3a225f052425deb43a45b98db Mon Sep 17 00:00:00 2001 From: danieldg Date: Tue, 3 Nov 2009 17:12:36 +0000 Subject: Create m_halfop git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11997 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_halfop.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/modules/m_halfop.cpp (limited to 'src/modules') 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 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) -- cgit v1.2.3