Use SimpleUserModeHandler/SimpleChannelModeHandler where possible

This commit is contained in:
attilamolnar 2012-07-04 17:13:41 +02:00
parent 2a5cab9b44
commit 0fa8cdd7b8
6 changed files with 13 additions and 142 deletions

View File

@ -23,32 +23,10 @@
/** Handles user mode +c /** Handles user mode +c
*/ */
class PrivacyMode : public ModeHandler class PrivacyMode : public SimpleUserModeHandler
{ {
public: public:
PrivacyMode(Module* Creator) : ModeHandler(Creator, "deaf_commonchan", 'c', PARAM_NONE, MODETYPE_USER) { } PrivacyMode(Module* Creator) : SimpleUserModeHandler(Creator, "deaf_commonchan", 'c') { }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
if (adding)
{
if (!dest->IsModeSet('c'))
{
dest->SetMode('c',true);
return MODEACTION_ALLOW;
}
}
else
{
if (dest->IsModeSet('c'))
{
dest->SetMode('c',false);
return MODEACTION_ALLOW;
}
}
return MODEACTION_DENY;
}
}; };
class ModulePrivacyMode : public Module class ModulePrivacyMode : public Module

View File

@ -29,35 +29,13 @@ static std::map<irc::string, std::string> helpop_map;
/** Handles user mode +h /** Handles user mode +h
*/ */
class Helpop : public ModeHandler class Helpop : public SimpleUserModeHandler
{ {
public: public:
Helpop(Module* Creator) : ModeHandler(Creator, "helpop", 'h', PARAM_NONE, MODETYPE_USER) Helpop(Module* Creator) : SimpleUserModeHandler(Creator, "helpop", 'h')
{ {
oper = true; oper = true;
} }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
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;
}
}; };
/** Handles /HELPOP /** Handles /HELPOP

View File

@ -24,32 +24,10 @@
/** Handles user mode +I /** Handles user mode +I
*/ */
class HideChans : public ModeHandler class HideChans : public SimpleUserModeHandler
{ {
public: public:
HideChans(Module* Creator) : ModeHandler(Creator, "hidechans", 'I', PARAM_NONE, MODETYPE_USER) { } HideChans(Module* Creator) : SimpleUserModeHandler(Creator, "hidechans", 'I') { }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
if (adding)
{
if (!dest->IsModeSet('I'))
{
dest->SetMode('I',true);
return MODEACTION_ALLOW;
}
}
else
{
if (dest->IsModeSet('I'))
{
dest->SetMode('I',false);
return MODEACTION_ALLOW;
}
}
return MODEACTION_DENY;
}
}; };
class ModuleHideChans : public Module class ModuleHideChans : public Module

View File

@ -25,35 +25,13 @@
/** Handles user mode +H /** Handles user mode +H
*/ */
class HideOper : public ModeHandler class HideOper : public SimpleUserModeHandler
{ {
public: public:
HideOper(Module* Creator) : ModeHandler(Creator, "hideoper", 'H', PARAM_NONE, MODETYPE_USER) HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H')
{ {
oper = true; oper = true;
} }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
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;
}
}; };
class ModuleHideOper : public Module class ModuleHideOper : public Module

View File

@ -24,32 +24,13 @@
/* $ModDesc: Provides support for oper-only chans via the +O channel mode */ /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
class OperChans : public ModeHandler class OperChans : public SimpleChannelModeHandler
{ {
public: public:
/* This is an oper-only mode */ /* This is an oper-only mode */
OperChans(Module* Creator) : ModeHandler(Creator, "operonly", 'O', PARAM_NONE, MODETYPE_CHANNEL) { oper = true; } OperChans(Module* Creator) : SimpleChannelModeHandler(Creator, "operonly", 'O')
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{ {
if (adding) oper = true;
{
if (!channel->IsModeSet('O'))
{
channel->SetMode('O',true);
return MODEACTION_ALLOW;
}
}
else
{
if (channel->IsModeSet('O'))
{
channel->SetMode('O',false);
return MODEACTION_ALLOW;
}
}
return MODEACTION_DENY;
} }
}; };

View File

@ -27,35 +27,13 @@
/** Handle user mode +W /** Handle user mode +W
*/ */
class SeeWhois : public ModeHandler class SeeWhois : public SimpleUserModeHandler
{ {
public: public:
SeeWhois(Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, "showwhois", 'W', PARAM_NONE, MODETYPE_USER) SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
{ {
oper = IsOpersOnly; oper = IsOpersOnly;
} }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
if (adding)
{
if (!dest->IsModeSet('W'))
{
dest->SetMode('W',true);
return MODEACTION_ALLOW;
}
}
else
{
if (dest->IsModeSet('W'))
{
dest->SetMode('W',false);
return MODEACTION_ALLOW;
}
}
return MODEACTION_DENY;
}
}; };
class WhoisNoticeCmd : public Command class WhoisNoticeCmd : public Command