1 #include "configreader.h"
7 #include "modes/cmode_o.h"
9 ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, 'o', 1, 1, true, MODETYPE_CHANNEL, false, '@')
13 unsigned int ModeChannelOp::GetPrefixRank()
18 ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
20 userrec* x = ServerInstance->FindNick(parameter);
23 if (channel->GetStatusFlags(x) & UCMODE_OP)
25 return std::make_pair(true, x->nick);
29 return std::make_pair(false, parameter);
32 return std::make_pair(false, parameter);
35 ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 int status = channel->GetStatus(source);
39 /* Call the correct method depending on wether we're adding or removing the mode */
42 parameter = this->AddOp(source, parameter.c_str(), channel, status);
46 parameter = this->DelOp(source, parameter.c_str(), channel, status);
48 /* If the method above 'ate' the parameter by reducing it to an empty string, then
49 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
50 * the return value and is always MODEACTION_DENY if the mode is supposed to have
53 return MODEACTION_ALLOW;
56 std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status)
58 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
65 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP));
67 if (MOD_RESULT == ACR_DENY)
69 if (MOD_RESULT == ACR_DEFAULT)
71 if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))
73 user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
79 return ServerInstance->Modes->Grant(d,chan,UCMODE_OP);
84 std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status)
86 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
93 ServerInstance->Log(DEBUG,"Call OnAccessCheck for AC_DEOP");
94 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP));
96 ServerInstance->Log(DEBUG,"Returns %d",MOD_RESULT);
98 if (MOD_RESULT == ACR_DENY)
100 if (MOD_RESULT == ACR_DEFAULT)
102 if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user)))
104 user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
110 return ServerInstance->Modes->Revoke(d,chan,UCMODE_OP);