X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_nonotice.cpp;h=3d6d0bb099422808e9f8af07c8fe385e50fbc2db;hb=da29af8cba49d51e53d6e68237ccbf6370b6dd1f;hp=12b36c23fd5efd74428e368888b776b3923509c8;hpb=e21214f274c9bd4e831c3512e3365d16d79ef8d2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 12b36c23f..3d6d0bb09 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -1,102 +1,71 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * Copyright (C) 2004, 2008 Craig Edwards + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2007 Robin Burchell * - * 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" -/* $ModDesc: Provides support for unreal-style channel mode +T */ +#include "inspircd.h" -class NoNotice : public ModeHandler +class NoNotice : public SimpleChannelModeHandler { public: - NoNotice(InspIRCd* Instance) : ModeHandler(Instance, 'T', 0, 0, false, MODETYPE_CHANNEL, false) { } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) - { - if (adding) - { - if (!channel->IsModeSet('T')) - { - channel->SetMode('T',true); - return MODEACTION_ALLOW; - } - } - else - { - if (channel->IsModeSet('T')) - { - channel->SetMode('T',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + NoNotice(Module* Creator) : SimpleChannelModeHandler(Creator, "nonotice", 'T') { } }; class ModuleNoNotice : public Module { - - NoNotice* nt; + NoNotice nt; public: - - ModuleNoNotice(InspIRCd* Me) - : Module(Me) + + ModuleNoNotice() + : nt(this) + { + } + + void On005Numeric(std::map& tokens) CXX11_OVERRIDE { - - nt = new NoNotice(ServerInstance); - if (!ServerInstance->Modes->AddMode(nt)) - throw ModuleException("Could not add new modes!"); - Implementation eventlist[] = { I_OnUserPreNotice }; - ServerInstance->Modules->Attach(eventlist, this, 1); + tokens["EXTBAN"].push_back('T'); } - - virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { - if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) + ModResult res; + if ((msgtype == MSG_NOTICE) && (target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; - if (c->IsModeSet('T')) + if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt))) { - if (ServerInstance->ULine(user->server)) - { - // ulines are exempt. - return 0; - } - else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP) - { - // channel ops are exempt if set in conf. - return 0; - } + res = ServerInstance->OnCheckExemption(user,c,"nonotice"); + if (res == MOD_RES_ALLOW) + return MOD_RES_PASSTHRU; else { - user->WriteServ("404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name); - return 1; + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send NOTICE to channel (+T set)"); + return MOD_RES_DENY; } } } - return 0; + return MOD_RES_PASSTHRU; } - virtual ~ModuleNoNotice() - { - ServerInstance->Modes->DelMode(nt); - delete nt; - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { - return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION); + return Version("Provides channel mode +T to block notices to the channel", VF_VENDOR); } };