]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonotice.cpp
OOPS! We try again, since I'm smoking craq. LF is 0x0a NOT CR.
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
index fd4c474cb42d7eb35347db6d741baa130952110c..ae926b4bbb5d1ec7b93fe4ef224e98cc8ba4ec48 100644 (file)
@@ -1 +1,103 @@
-/*       +------------------------------------+\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 &parameter, 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-2007 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"
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+
+/* $ModDesc: Provides support for unreal-style channel mode +T */
+
+class NoNotice : public ModeHandler
+{
+ public:
+       NoNotice(InspIRCd* Instance) : ModeHandler(Instance, 'T', 0, 0, false, MODETYPE_CHANNEL, false) { }
+
+       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, 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;
+       }
+};
+
+class ModuleNoNotice : public Module
+{
+       
+       NoNotice* nt;
+ public:
+       ModuleNoNotice(InspIRCd* Me)
+               : Module(Me)
+       {
+               
+               nt = new NoNotice(ServerInstance);
+               if (!ServerInstance->AddMode(nt, 'T'))
+                       throw ModuleException("Could not add new modes!");
+       }
+
+       void Implements(char* List)
+       {
+               List[I_OnUserPreNotice] = 1;
+       }
+       
+       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+       {
+               if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
+               {
+                       chanrec* c = (chanrec*)dest;
+                       if (c->IsModeSet('T'))
+                       {
+                               if ((ServerInstance->ULine(user->server)) || (c->GetStatus(user) == STATUS_OP) || (c->GetStatus(user) == STATUS_HOP))
+                               {
+                                       // ops and halfops can still /NOTICE the channel
+                                       return 0;
+                               }
+                               else
+                               {
+                                       user->WriteServ("404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
+                                       return 1;
+                               }
+                       }
+               }
+               return 0;
+       }
+
+       virtual ~ModuleNoNotice()
+       {
+               ServerInstance->Modes->DelMode(nt);
+               DELETE(nt);
+       }
+       
+       virtual Version GetVersion()
+       {
+               return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
+       }
+};
+
+MODULE_INIT(ModuleNoNotice)