diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_blockcaps.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_blockcolor.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_botmode.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_callerid.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_censor.cpp | 52 | ||||
-rw-r--r-- | src/modules/m_helpop.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_knock.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_noinvite.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_nokicks.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_nonotice.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_services.cpp | 78 | ||||
-rw-r--r-- | src/modules/m_services_account.cpp | 78 | ||||
-rw-r--r-- | src/modules/m_stripcolor.cpp | 56 |
13 files changed, 38 insertions, 448 deletions
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index c229ef752..3e8fdccc5 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -18,32 +18,10 @@ /** 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 ¶meter, 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 diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index a6a255e23..3e97f8287 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -17,32 +17,10 @@ /** 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 ¶meter, 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 diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 2bf683fa9..7cc050403 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -17,32 +17,10 @@ /** 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 ¶meter, 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 diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index e3dc6b353..a33b493b1 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -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 ¶meter, 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 diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index b4746d936..93fe3ae3b 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -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 ¶meter, 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 ¶meter, 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 diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index eb64d4f48..3ed172644 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -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 ¶meter, 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 diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 3d2f4b344..82b76c02b 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -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 ¶meter, 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 diff --git a/src/modules/m_noinvite.cpp b/src/modules/m_noinvite.cpp index efa0af0e1..e27ed6f04 100644 --- a/src/modules/m_noinvite.cpp +++ b/src/modules/m_noinvite.cpp @@ -15,32 +15,10 @@ /* $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 ¶meter, 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 diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index 0806b2d56..9daa4c66b 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -15,32 +15,10 @@ /* $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 ¶meter, 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 diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 52ddb537d..1e88a4cc0 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -15,32 +15,10 @@ /* $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 ¶meter, 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 diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index 5b39de931..669a87aeb 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -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 ¶meter, 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 ¶meter, 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 ¶meter, 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 diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 70539ddde..3ac333b37 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -18,92 +18,26 @@ /** 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 ¶meter, 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 ¶meter, 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 ¶meter, 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 diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index eb32c60b3..420e2e6e2 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -17,66 +17,18 @@ /** 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 ¶meter, 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 ¶meter, 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') { } }; |