-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2006-2009 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
+ * Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
+ * Copyright (C) 2004-2008 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2007 John Brooks <john.brooks@dereferenced.net>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
*
- * This program is free but copyrighted software; see
- * the file COPYING for details.
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
*
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "inspircd.h"
/* $ModDesc: Provides channel modes +a and +q */
{
}
- ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter)
- {
- User* x = ServerInstance->FindNick(parameter);
- if (x)
- {
- Membership* memb = channel->GetUser(x);
- if (!memb)
- {
- return std::make_pair(false, parameter);
- }
- else
- {
- if (memb->hasMode(mode))
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
- }
- return std::make_pair(false, parameter);
- }
-
void RemoveMode(Channel* channel, irc::modestacker* stack)
{
const UserMembList* cl = channel->GetUsers();
return FOUNDER_VALUE;
}
- ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter)
- {
- return FounderProtectBase::ModeSet(source, dest, channel, parameter);
- }
-
void RemoveMode(Channel* channel, irc::modestacker* stack)
{
FounderProtectBase::RemoveMode(channel, stack);
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
- User* theuser = ServerInstance->FindNick(parameter);
-
- if (!theuser)
- return MODEACTION_DENY;
return MODEACTION_ALLOW;
}
{
public:
ChanProtect(Module* Creator)
- : ModeHandler(Creator, "protected", 'a', PARAM_ALWAYS, MODETYPE_CHANNEL),
+ : ModeHandler(Creator, "admin", 'a', PARAM_ALWAYS, MODETYPE_CHANNEL),
FounderProtectBase('a',"protected user", 388, 389)
{
ModeHandler::list = true;
return PROTECT_VALUE;
}
- ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter)
- {
- return FounderProtectBase::ModeSet(source, dest, channel, parameter);
- }
-
void RemoveMode(Channel* channel, irc::modestacker* stack)
{
FounderProtectBase::RemoveMode(channel, stack);
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
- User* theuser = ServerInstance->FindNick(parameter);
-
- if (!theuser)
- return MODEACTION_DENY;
-
return MODEACTION_ALLOW;
}
ChanFounder cf;
public:
ModuleChanProtect() : cp(this), cf(this)
+ {
+ }
+
+ void init()
{
/* Load config stuff */
LoadSettings();
settings.booting = false;
- if (!ServerInstance->Modes->AddMode(&cp) || !ServerInstance->Modes->AddMode(&cf))
- {
- throw ModuleException("Could not add new modes!");
- }
+ ServerInstance->Modules->AddService(cf);
+ ServerInstance->Modules->AddService(cp);
Implementation eventlist[] = { I_OnUserPreJoin };
- ServerInstance->Modules->Attach(eventlist, this, 1);
+ ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
void LoadSettings()
{
- ConfigReader Conf;
+ ConfigTag* tag = ServerInstance->Config->ConfValue("chanprotect");
- settings.FirstInGetsFounder = Conf.ReadFlag("chanprotect", "noservices", 0);
+ settings.FirstInGetsFounder = tag->getBool("noservices");
- std::string qpre = Conf.ReadValue("chanprotect", "qprefix", 0);
+ std::string qpre = tag->getString("qprefix");
char QPrefix = qpre.empty() ? 0 : qpre[0];
- std::string apre = Conf.ReadValue("chanprotect", "aprefix", 0);
+ std::string apre = tag->getString("aprefix");
char APrefix = apre.empty() ? 0 : apre[0];
if ((APrefix && QPrefix) && APrefix == QPrefix)
throw ModuleException("What the smeg, why are both your +q and +a prefixes the same character?");
- if (ServerInstance->Modes->FindPrefix(APrefix) && ServerInstance->Modes->FindPrefix(APrefix) != &cp)
- throw ModuleException("Looks like the +a prefix you picked for m_chanprotect is already in use. Pick another.");
-
- if (ServerInstance->Modes->FindPrefix(QPrefix) && ServerInstance->Modes->FindPrefix(QPrefix) != &cf)
- throw ModuleException("Looks like the +q prefix you picked for m_chanprotect is already in use. Pick another.");
-
if (settings.booting)
{
+ if (APrefix && ServerInstance->Modes->FindPrefix(APrefix) && ServerInstance->Modes->FindPrefix(APrefix) != &cp)
+ throw ModuleException("Looks like the +a prefix you picked for m_chanprotect is already in use. Pick another.");
+
+ if (QPrefix && ServerInstance->Modes->FindPrefix(QPrefix) && ServerInstance->Modes->FindPrefix(QPrefix) != &cf)
+ throw ModuleException("Looks like the +q prefix you picked for m_chanprotect is already in use. Pick another.");
+
cp.setPrefix(APrefix);
cf.setPrefix(QPrefix);
}
- settings.DeprivSelf = Conf.ReadFlag("chanprotect","deprotectself", "yes", 0);
- settings.DeprivOthers = Conf.ReadFlag("chanprotect","deprotectothers", "yes", 0);
+ settings.DeprivSelf = tag->getBool("deprotectself", true);
+ settings.DeprivOthers = tag->getBool("deprotectothers", true);
}
ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
Version GetVersion()
{
- return Version("Founder and Protect modes (+qa)", VF_COMMON | VF_VENDOR);
+ return Version("Founder and Protect modes (+qa)", VF_VENDOR);
}
};