3 #include "inspircd_config.h"
4 #include "configreader.h"
10 #include "helperfuncs.h"
14 #include "inspstring.h"
16 #include "modes/cmode_v.h"
18 extern InspIRCd* ServerInstance;
19 extern InspIRCd* ServerInstance;
20 extern std::vector<Module*> modules;
21 extern std::vector<ircd_module*> factory;
25 ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHANNEL, false)
29 ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
31 userrec* x = Find(parameter);
34 if (cstatus(x, channel) == STATUS_VOICE)
36 return std::make_pair(true, x->nick);
40 return std::make_pair(false, parameter);
43 return std::make_pair(false, parameter);
46 ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
48 int status = cstatus(source, channel);
50 /* Call the correct method depending on wether we're adding or removing the mode */
53 parameter = this->AddVoice(source, parameter.c_str(), channel, status);
57 parameter = this->DelVoice(source, parameter.c_str(), channel, status);
59 /* If the method above 'ate' the parameter by reducing it to an empty string, then
60 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
61 * the return value and is always MODEACTION_DENY if the mode is supposed to have
64 return MODEACTION_ALLOW;
67 std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status)
69 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
76 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE));
78 if (MOD_RESULT == ACR_DENY)
80 if (MOD_RESULT == ACR_DEFAULT)
82 if ((status < STATUS_HOP) && (!is_uline(user->server)))
84 user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name);
90 return ModeParser::Grant(d,chan,UCMODE_VOICE);
95 std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status)
97 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
104 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE));
106 if (MOD_RESULT == ACR_DENY)
108 if (MOD_RESULT == ACR_DEFAULT)
110 if ((status < STATUS_HOP) && (!is_uline(user->server)))
112 user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name);
118 return ModeParser::Revoke(d,chan,UCMODE_VOICE);