-/* +------------------------------------+\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
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+
+/* $ModDesc: Provides support for unreal-style channel mode +T */
+
+class NoNotice : public SimpleChannelModeHandler
+{
+ public:
+ NoNotice(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'T') { }
+};
+
+class ModuleNoNotice : public Module
+{
+
+ NoNotice* nt;
+ public:
+
+ ModuleNoNotice(InspIRCd* Me)
+ : Module(Me)
+ {
+
+ nt = new NoNotice(ServerInstance);
+ if (!ServerInstance->Modes->AddMode(nt))
+ throw ModuleException("Could not add new modes!");
+ Implementation eventlist[] = { I_OnUserPreNotice, I_On005Numeric };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
+ }
+
+ virtual void On005Numeric(std::string &output)
+ {
+ ServerInstance->AddExtBanChar('T');
+ }
+
+ virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+ {
+ if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
+ {
+ Channel* c = (Channel*)dest;
+ if (c->IsModeSet('T') || c->IsExtBanned(user, 'T'))
+ {
+ 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;
+ }
+ else
+ {
+ user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
+ return 1;
+ }
+ }
+ }
+ return 0;
+ }
+
+ virtual ~ModuleNoNotice()
+ {
+ ServerInstance->Modes->DelMode(nt);
+ delete nt;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+ }
+};
+
+MODULE_INIT(ModuleNoNotice)