3 #include "inspircd_config.h"
4 #include "configreader.h"
12 #include "inspstring.h"
14 #include "modes/cmode_v.h"
16 ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+')
20 unsigned int ModeChannelVoice::GetPrefixRank()
25 ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
27 userrec* x = ServerInstance->FindNick(parameter);
30 if (channel->GetStatusFlags(x) & UCMODE_VOICE)
32 return std::make_pair(true, x->nick);
36 return std::make_pair(false, parameter);
39 return std::make_pair(false, parameter);
42 ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
44 int status = channel->GetStatus(source);
46 /* Call the correct method depending on wether we're adding or removing the mode */
49 parameter = this->AddVoice(source, parameter.c_str(), channel, status);
53 parameter = this->DelVoice(source, parameter.c_str(), channel, status);
55 /* If the method above 'ate' the parameter by reducing it to an empty string, then
56 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
57 * the return value and is always MODEACTION_DENY if the mode is supposed to have
60 return MODEACTION_ALLOW;
63 std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status)
65 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
72 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE));
74 if (MOD_RESULT == ACR_DENY)
76 if (MOD_RESULT == ACR_DEFAULT)
78 if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
80 user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name);
86 return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE);
91 std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status)
93 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
100 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE));
102 if (MOD_RESULT == ACR_DENY)
104 if (MOD_RESULT == ACR_DEFAULT)
106 if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
108 user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name);
114 return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE);