3 #include "inspircd_config.h"
4 #include "configreader.h"
13 #include "inspstring.h"
15 #include "modes/cmode_v.h"
17 ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false)
21 ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
23 userrec* x = ServerInstance->FindNick(parameter);
26 if (channel->GetStatus(x) == STATUS_VOICE)
28 return std::make_pair(true, x->nick);
32 return std::make_pair(false, parameter);
35 return std::make_pair(false, parameter);
38 ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
40 int status = channel->GetStatus(source);
42 /* Call the correct method depending on wether we're adding or removing the mode */
45 parameter = this->AddVoice(source, parameter.c_str(), channel, status);
49 parameter = this->DelVoice(source, parameter.c_str(), channel, status);
51 /* If the method above 'ate' the parameter by reducing it to an empty string, then
52 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
53 * the return value and is always MODEACTION_DENY if the mode is supposed to have
56 return MODEACTION_ALLOW;
59 std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status)
61 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
68 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE));
70 if (MOD_RESULT == ACR_DENY)
72 if (MOD_RESULT == ACR_DEFAULT)
74 if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
76 user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name);
82 return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE);
87 std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status)
89 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
96 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE));
98 if (MOD_RESULT == ACR_DENY)
100 if (MOD_RESULT == ACR_DEFAULT)
102 if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
104 user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name);
110 return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE);