]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonotice.cpp
Fix some indenting.
[user/henk/code/inspircd.git] / src / modules / m_nonotice.cpp
index 11b57e09be9d2530f320750f0231dfb3c4b89b61..1e88a4cc0ec98b6ad320a1c09bb7f620a3bca763 100644 (file)
 
 /* $ModDesc: Provides support for unreal-style channel mode +T */
 
-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 &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;
-       }
+       NoNotice(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'T') { }
 };
 
 class ModuleNoNotice : public Module
@@ -68,14 +46,19 @@ class ModuleNoNotice : public Module
                        Channel* c = (Channel*)dest;
                        if (c->IsModeSet('T'))
                        {
-                               if ((ServerInstance->ULine(user->server)) || (c->GetStatus(user) == STATUS_OP) || (c->GetStatus(user) == STATUS_HOP))
+                               if (ServerInstance->ULine(user->server))
+                               {
+                                       // ulines are exempt.
+                                       return 0;
+                               }
+                               else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP)
                                {
-                                       // ops and halfops can still /NOTICE the channel
+                                       // channel ops are exempt if set in conf.
                                        return 0;
                                }
                                else
                                {
-                                       user->WriteServ("404 %s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
+                                       user->WriteNumeric(404, "%s %s :Can't send NOTICE to channel (+T set)",user->nick, c->name);
                                        return 1;
                                }
                        }
@@ -91,7 +74,7 @@ class ModuleNoNotice : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
        }
 };