X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_regonlycreate.cpp;h=61f94c0bd1b81f26bc4cf9ea2bcdb10d8d84c0c2;hb=692865acd58c9a475db1fdf4d419188325cd2182;hp=5be3031488f98fdec7b1548844fede667d8a51da;hpb=86775e2e98f55b3b88befe2daff0ca23f02f3155;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_regonlycreate.cpp b/src/modules/m_regonlycreate.cpp index 5be303148..61f94c0bd 100644 --- a/src/modules/m_regonlycreate.cpp +++ b/src/modules/m_regonlycreate.cpp @@ -1,32 +1,40 @@ -/* +------------------------------------+ - * | 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 + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2007 Craig Edwards * - * 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 . */ + #include "inspircd.h" +#include "account.h" -/* $ModDesc: Prevents users who's nicks are not registered from creating new channels */ +/* $ModDesc: Prevents users whose nicks are not registered from creating new channels */ class ModuleRegOnlyCreate : public Module { public: - ModuleRegOnlyCreate(InspIRCd* Me) - : Module(Me) + void init() { Implementation eventlist[] = { I_OnUserPreJoin }; - ServerInstance->Modules->Attach(eventlist, this, 1); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - - virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) + ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) { if (chan) return MOD_RES_PASSTHRU; @@ -34,23 +42,25 @@ class ModuleRegOnlyCreate : public Module if (IS_OPER(user)) return MOD_RES_PASSTHRU; - if ((!user->IsModeSet('r')) && (!user->GetExt("accountname"))) - { - // XXX. there may be a better numeric for this.. - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have a registered nickname to create a new channel", user->nick.c_str(), cname); - return MOD_RES_DENY; - } + if (user->IsModeSet('r')) + return MOD_RES_PASSTHRU; + + const AccountExtItem* ext = GetAccountExtItem(); + if (ext && ext->get(user)) + return MOD_RES_PASSTHRU; - return MOD_RES_PASSTHRU; + // XXX. there may be a better numeric for this.. + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have a registered nickname to create a new channel", user->nick.c_str(), cname); + return MOD_RES_DENY; } - virtual ~ModuleRegOnlyCreate() + ~ModuleRegOnlyCreate() { } - virtual Version GetVersion() + Version GetVersion() { - return Version("$Id$", VF_VENDOR, API_VERSION); + return Version("Prevents users whose nicks are not registered from creating new channels", VF_VENDOR); } };