-/* +------------------------------------+\r * | Inspire Internet Relay Chat Daemon |\r * +------------------------------------+\r *\r * InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r * the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#include "inspircd.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r\r/* $ModDesc: Provides support for unreal-style channel mode +T */\r\rclass NoNotice : public ModeHandler\r{\r public:\r NoNotice(InspIRCd* Instance) : ModeHandler(Instance, 'T', 0, 0, false, MODETYPE_CHANNEL, false) { }\r\r ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)\r {\r if (adding)\r {\r if (!channel->IsModeSet('T'))\r {\r channel->SetMode('T',true);\r return MODEACTION_ALLOW;\r }\r }\r else\r {\r if (channel->IsModeSet('T'))\r {\r channel->SetMode('T',false);\r return MODEACTION_ALLOW;\r }\r }\r\r return MODEACTION_DENY;\r }\r};\r\rclass ModuleNoNotice : public Module\r{\r \r NoNotice* nt;\r public:\r \r ModuleNoNotice(InspIRCd* Me)\r : Module(Me)\r {\r \r nt = new NoNotice(ServerInstance);\r if (!ServerInstance->AddMode(nt, 'T'))\r throw ModuleException("Could not add new modes!");\r }\r\r void Implements(char* List)\r {\r List[I_OnUserPreNotice] = 1;\r }\r \r virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)\r {\r if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))\r {\r chanrec* c = (chanrec*)dest;\r if (c->IsModeSet('T'))\r {\r if ((ServerInstance->ULine(user->server)) || (c->GetStatus(user) == STATUS_OP) || (c->GetStatus(user) == STATUS_HOP))\r {\r // ops and halfops can still /NOTICE the channel\r return 0;\r }\r else\r {\r user->WriteServ("404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);\r return 1;\r }\r }\r }\r return 0;\r }\r\r virtual ~ModuleNoNotice()\r {\r ServerInstance->Modes->DelMode(nt);\r DELETE(nt);\r }\r \r virtual Version GetVersion()\r {\r return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);\r }\r};\r\rMODULE_INIT(ModuleNoNotice)\r
\ No newline at end of file
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2004, 2008 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *
+ * 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"
+#include "modules/exemption.h"
+
+class ModuleNoNotice : public Module
+{
+ CheckExemption::EventProvider exemptionprov;
+ SimpleChannelModeHandler nt;
+ public:
+
+ ModuleNoNotice()
+ : exemptionprov(this)
+ , nt(this, "nonotice", 'T')
+ {
+ }
+
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
+ {
+ tokens["EXTBAN"].push_back('T');
+ }
+
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
+ {
+ ModResult res;
+ if ((details.type == MSG_NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
+ {
+ Channel* c = target.Get<Channel>();
+ if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt)))
+ {
+ res = CheckExemption::Call(exemptionprov, user, c, "nonotice");
+ if (res == MOD_RES_ALLOW)
+ return MOD_RES_PASSTHRU;
+ else
+ {
+ user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send NOTICE to channel (+T set)");
+ return MOD_RES_DENY;
+ }
+ }
+ }
+ return MOD_RES_PASSTHRU;
+ }
+
+ Version GetVersion() CXX11_OVERRIDE
+ {
+ return Version("Provides channel mode +T to block notices to the channel", VF_VENDOR);
+ }
+};
+
+MODULE_INIT(ModuleNoNotice)