]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Simple user/channel mode patch
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 1 May 2008 16:12:45 +0000 (16:12 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 1 May 2008 16:12:45 +0000 (16:12 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9596 e03df62e-2008-0410-955e-edbf42e46eb7

15 files changed:
include/mode.h
src/mode.cpp
src/modules/m_blockcaps.cpp
src/modules/m_blockcolor.cpp
src/modules/m_botmode.cpp
src/modules/m_callerid.cpp
src/modules/m_censor.cpp
src/modules/m_helpop.cpp
src/modules/m_knock.cpp
src/modules/m_noinvite.cpp
src/modules/m_nokicks.cpp
src/modules/m_nonotice.cpp
src/modules/m_services.cpp
src/modules/m_services_account.cpp
src/modules/m_stripcolor.cpp

index e15ddeeb0bd416d5022b1d28252ea3d16a2c5ad6..dcd8cc0040d3cd051d39a92683ac90c328aeb6b9 100644 (file)
@@ -293,6 +293,32 @@ class CoreExport ModeHandler : public Extensible
        void SetNeededPrefix(char needsprefix);
 };
 
+/** A prebuilt mode handler which handles a simple user mode, e.g. no parameters, usable by any user, with no extra
+ * behaviour to the mode beyond the basic setting and unsetting of the mode, not allowing the mode to be set if it
+ * is already set and not allowing it to be unset if it is already unset.
+ * An example of a simple user mode is user mode +w.
+ */
+class CoreExport SimpleUserModeHandler : public ModeHandler
+{
+ public:
+       SimpleUserModeHandler(InspIRCd* Instance, char modeletter);
+       virtual ~SimpleUserModeHandler();
+       virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode = false);
+};
+
+/** A prebuilt mode handler which handles a simple channel mode, e.g. no parameters, usable by any user, with no extra
+ * behaviour to the mode beyond the basic setting and unsetting of the mode, not allowing the mode to be set if it
+ * is already set and not allowing it to be unset if it is already unset.
+ * An example of a simple channel mode is channel mode +s.
+ */
+class CoreExport SimpleChannelModeHandler : public ModeHandler
+{
+ public:
+       SimpleChannelModeHandler(InspIRCd* Instance, char modeletter);
+       virtual ~SimpleChannelModeHandler();
+       virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode = false);
+};
+
 /**
  * The ModeWatcher class can be used to alter the behaviour of a mode implemented
  * by the core or by another module. To use ModeWatcher, derive a class from it,
index e5efaffdf0251e5eea61bb78a0d02690cdd883aa..91a64f89b0102cb60e7ec6ab3b20d6b22b1f7db1 100644 (file)
@@ -149,6 +149,71 @@ bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&,
        return (ours < theirs);
 }
 
+SimpleUserModeHandler::SimpleUserModeHandler(InspIRCd* Instance, char modeletter) : ModeHandler(Instance, modeletter, 0, 0, false, MODETYPE_USER, false)
+{
+}
+
+SimpleUserModeHandler::~SimpleUserModeHandler()
+{
+}
+
+SimpleChannelModeHandler::~SimpleChannelModeHandler()
+{
+}
+
+SimpleChannelModeHandler::SimpleChannelModeHandler(InspIRCd* Instance, char modeletter) : ModeHandler(Instance, modeletter, 0, 0, false, MODETYPE_CHANNEL, false)
+{
+}
+
+ModeAction SimpleUserModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
+{
+       /* Only opers can change other users modes */
+       if (source != dest)
+               return MODEACTION_DENY;
+
+       if (adding)
+       {
+               if (!dest->IsModeSet(this->GetModeChar()))
+               {
+                       dest->SetMode(this->GetModeChar(),true);
+                       return MODEACTION_ALLOW;
+               }
+       }
+       else
+       {
+               if (dest->IsModeSet(this->GetModeChar()))
+               {
+                       dest->SetMode(this->GetModeChar(),false);
+                       return MODEACTION_ALLOW;
+               }
+       }
+
+       return MODEACTION_DENY;
+}
+
+
+ModeAction SimpleChannelModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
+{
+       if (adding)
+       {
+               if (!channel->IsModeSet(this->GetModeChar()))
+               {
+                       channel->SetMode(this->GetModeChar(),true);
+                       return MODEACTION_ALLOW;
+               }
+       }
+       else
+       {
+               if (channel->IsModeSet(this->GetModeChar()))
+               {
+                       channel->SetMode(this->GetModeChar(),false);
+                       return MODEACTION_ALLOW;
+               }
+       }
+
+       return MODEACTION_DENY;
+}
+
 ModeWatcher::ModeWatcher(InspIRCd* Instance, char modeletter, ModeType type) : ServerInstance(Instance), mode(modeletter), m_type(type)
 {
 }
index c229ef7529350a2000e79b06352489469e047f02..3e8fdccc5e6726996d86b2ba50ef752366706ed7 100644 (file)
 
 /** Handles the +P channel mode
  */
-class BlockCaps : public ModeHandler
+class BlockCaps : public SimpleChannelModeHandler
 {
  public:
-       BlockCaps(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('B'))
-                       {
-                               channel->SetMode('B',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('B'))
-                       {
-                               channel->SetMode('B',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       BlockCaps(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'B') { }
 };
 
 class ModuleBlockCAPS : public Module
index a6a255e23f093ff7e0046dda74ad0e9ce2285dfa..3e97f82877b6c7b85d4e65f69ef18a37a3c96acb 100644 (file)
 
 /** Handles the +c channel mode
  */
-class BlockColor : public ModeHandler
+class BlockColor : public SimpleChannelModeHandler
 {
  public:
-       BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('c'))
-                       {
-                               channel->SetMode('c',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('c'))
-                       {
-                               channel->SetMode('c',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       BlockColor(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'c') { }
 };
 
 class ModuleBlockColour : public Module
index 2bf683fa999b8c5449f3515c9c1accbf3f1c9b70..7cc0504038630ad9d22d94e1ae6e9932ecad152a 100644 (file)
 
 /** Handles user mode +B
  */
-class BotMode : public ModeHandler
+class BotMode : public SimpleUserModeHandler
 {
  public:
-       BotMode(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('B'))
-                       {
-                               dest->SetMode('B',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('B'))
-                       {
-                               dest->SetMode('B',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               
-               return MODEACTION_DENY;
-       }
+       BotMode(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'B') { }
 };
 
 class ModuleBotMode : public Module
index e3dc6b353c989d791c1ed8c9ab55537a278c9767..a33b493b16c3d98758f469d47d413f6cacd2a7c9 100644 (file)
@@ -59,22 +59,12 @@ void RemoveFromAllAccepts(InspIRCd* ServerInstance, User* who)
        }
 }
 
-class User_g : public ModeHandler
+class User_g : public SimpleUserModeHandler
 {
 private:
 
 public:
-       User_g(InspIRCd* Instance) : ModeHandler(Instance, 'g', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding != dest->IsModeSet('g'))
-               {
-                       dest->SetMode('g', adding);
-                       return MODEACTION_ALLOW;
-               }
-               return MODEACTION_DENY;
-       }
+       User_g(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'g') { }
 };
 
 class CommandAccept : public Command
index b4746d93660beeb2e6583c38b9f4a406cdaa82a8..93fe3ae3bb7eb73764bc37bc9f919a1b81ba0b05 100644 (file)
@@ -22,62 +22,18 @@ typedef std::map<irc::string,irc::string> censor_t;
 
 /** Handles usermode +G
  */
-class CensorUser : public ModeHandler
+class CensorUser : public SimpleUserModeHandler
 {
  public:
-       CensorUser(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('G'))
-                       {
-                               dest->SetMode('G',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('G'))
-                       {
-                               dest->SetMode('G',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       CensorUser(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'G') { }
 };
 
 /** Handles channel mode +G
  */
-class CensorChannel : public ModeHandler
+class CensorChannel : public SimpleChannelModeHandler
 {
  public:
-       CensorChannel(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('G'))
-                       {
-                               channel->SetMode('G',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('G'))
-                       {
-                               channel->SetMode('G',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       CensorChannel(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'G') { }
 };
 
 class ModuleCensor : public Module
index eb64d4f481609201e025f1b4c58224ea47870831..3ed172644ec2f10dc3ee1b9891582655f1929b33 100644 (file)
@@ -19,32 +19,10 @@ static std::map<irc::string, std::string> helpop_map;
 
 /** Handles user mode +h
  */
-class Helpop : public ModeHandler
+class Helpop : public SimpleUserModeHandler
 {
  public:
-       Helpop(InspIRCd* Instance) : ModeHandler(Instance, 'h', 0, 0, false, MODETYPE_USER, true) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       Helpop(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'h') { }
 };
 
 /** Handles /HELPOP
index 3d2f4b3444435c5152c7f98e7b222fc811a1e792..82b76c02b9d92b45e7f7916f26ac9ff79b1e579d 100644 (file)
@@ -70,32 +70,10 @@ class CommandKnock : public Command
 
 /** Handles channel mode +K
  */
-class Knock : public ModeHandler
+class Knock : public SimpleChannelModeHandler
 {
  public:
-       Knock(InspIRCd* Instance) : ModeHandler(Instance, 'K', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('K'))
-                       {
-                               channel->SetMode('K',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('K'))
-                       {
-                               channel->SetMode('K',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       Knock(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'K') { }
 };
 
 class ModuleKnock : public Module
index efa0af0e10957763c236d0b21b79a8597f568935..e27ed6f04f2f57b58d9b7747e5032ca5a7550ded 100644 (file)
 
 /* $ModDesc: Provides support for unreal-style channel mode +V */
 
-class NoInvite : public ModeHandler
+class NoInvite : public SimpleChannelModeHandler
 {
  public:
-       NoInvite(InspIRCd* Instance) : ModeHandler(Instance, 'V', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('V'))
-                       {
-                               channel->SetMode('V',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('V'))
-                       {
-                               channel->SetMode('V',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       NoInvite(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'V') { }
 };
 
 class ModuleNoInvite : public Module
index 0806b2d56b1094fad9f327879a405be5e117368f..9daa4c66bfffbaeebcf65e3c1942375002caf189 100644 (file)
 
 /* $ModDesc: Provides support for unreal-style channel mode +Q */
 
-class NoKicks : public ModeHandler
+class NoKicks : public SimpleChannelModeHandler
 {
  public:
-       NoKicks(InspIRCd* Instance) : ModeHandler(Instance, 'Q', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('Q'))
-                       {
-                               channel->SetMode('Q',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('Q'))
-                       {
-                               channel->SetMode('Q',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       NoKicks(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'Q') { }
 };
 
 class ModuleNoKicks : public Module
index 52ddb537dbe60958ea861514407bb143787a1fd7..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, bool)
-       {
-               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
index 5b39de93147c8efcdd41a9d032a225f7ba314462..669a87aeb3c71a2476387b5ba664e61884f90c69 100644 (file)
@@ -70,92 +70,26 @@ class User_r : public ModeHandler
 
 /** Channel mode +R - registered users only
  */
-class Channel_R : public ModeHandler
+class Channel_R : public SimpleChannelModeHandler
 {
  public:
-       Channel_R(InspIRCd* Instance) : ModeHandler(Instance, 'R', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('R'))
-                       {
-                               channel->SetMode('R',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('R'))
-                       {
-                               channel->SetMode('R',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       Channel_R(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'R') { }
 };
 
 /** User mode +R - only allow PRIVMSG and NOTICE from registered users
  */
-class User_R : public ModeHandler
+class User_R : public SimpleUserModeHandler
 {
  public:
-       User_R(InspIRCd* Instance) : ModeHandler(Instance, 'R', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('R'))
-                       {
-                               dest->SetMode('R',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('R'))
-                       {
-                               dest->SetMode('R',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       User_R(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'R') { }
 };
 
 /** Channel mode +M - only allow privmsg and notice to channel from registered users
  */
-class Channel_M : public ModeHandler
+class Channel_M : public SimpleChannelModeHandler
 {
  public:
-       Channel_M(InspIRCd* Instance) : ModeHandler(Instance, 'M', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('M'))
-                       {
-                               channel->SetMode('M',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('M'))
-                       {
-                               channel->SetMode('M',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       Channel_M(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'M') { }
 };
 
 /** Dreamnforge-like services support
index 70539ddde5fad0efa1c3aa7c0d72715f8ff335d7..3ac333b37caebe99680e8dc2bbd37293c3a5407f 100644 (file)
 
 /** Channel mode +R - unidentified users cannot join
  */
-class AChannel_R : public ModeHandler
+class AChannel_R : public SimpleChannelModeHandler
 {
  public:
-       AChannel_R(InspIRCd* Instance) : ModeHandler(Instance, 'R', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('R'))
-                       {
-                               channel->SetMode('R',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('R'))
-                       {
-                               channel->SetMode('R',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       AChannel_R(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'R') { }
 };
 
 /** User mode +R - unidentified users cannot message
  */
-class AUser_R : public ModeHandler
+class AUser_R : public SimpleUserModeHandler
 {
  public:
-       AUser_R(InspIRCd* Instance) : ModeHandler(Instance, 'R', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('R'))
-                       {
-                               dest->SetMode('R',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('R'))
-                       {
-                               dest->SetMode('R',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       AUser_R(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'R') { }
 };
 
 /** Channel mode +M - unidentified users cannot message channel
  */
-class AChannel_M : public ModeHandler
+class AChannel_M : public SimpleChannelModeHandler
 {
  public:
-       AChannel_M(InspIRCd* Instance) : ModeHandler(Instance, 'M', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('M'))
-                       {
-                               channel->SetMode('M',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('M'))
-                       {
-                               channel->SetMode('M',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       AChannel_M(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'M') { }
 };
 
 class ModuleServicesAccount : public Module
index eb32c60b3b0c2378d0c5d096c2b7948888334f93..420e2e6e293c1ad0413b86142b6dd2c7f1f82425 100644 (file)
 
 /** Handles channel mode +S
  */
-class ChannelStripColor : public ModeHandler
+class ChannelStripColor : public SimpleChannelModeHandler
 {
  public:
-       ChannelStripColor(InspIRCd* Instance) : ModeHandler(Instance, 'S', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('S'))
-                       {
-                               channel->SetMode('S',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('S'))
-                       {
-                               channel->SetMode('S',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       ChannelStripColor(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'S') { }
 };
 
 /** Handles user mode +S
  */
-class UserStripColor : public ModeHandler
+class UserStripColor : public SimpleUserModeHandler
 {
  public:
-       UserStripColor(InspIRCd* Instance) : ModeHandler(Instance, 'S', 0, 0, false, MODETYPE_USER, false) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
-       {
-               /* Only opers can change other users modes */
-               if (source != dest)
-                       return MODEACTION_DENY;
-
-               if (adding)
-               {
-                       if (!dest->IsModeSet('S'))
-                       {
-                               dest->SetMode('S',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('S'))
-                       {
-                               dest->SetMode('S',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       UserStripColor(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'S') { }
 };