public:
ChanFounder(Server* s) : ModeHandler('q', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { }
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
{
userrec* x = Find(parameter);
if (x)
{
userrec* theuser = Srv->FindNick(parameter);
+ log(DEBUG,"ChanFounder::OnModeChange");
+
// cant find the user given as the parameter, eat the mode change.
if (!theuser)
{
+ log(DEBUG,"No such user in ChanFounder");
parameter = "";
return MODEACTION_DENY;
}
// given user isnt even on the channel, eat the mode change
if (!channel->HasUser(theuser))
{
+ log(DEBUG,"Channel doesn't have user in ChanFounder");
parameter = "";
return MODEACTION_DENY;
}
std::string founder = "cm_founder_"+std::string(channel->name);
// source is a server, or ulined, we'll let them +-q the user.
- if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!*source->server))
+ if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!*source->server) || (!IS_LOCAL(source)))
{
+ log(DEBUG,"Allowing remote mode change in ChanFounder");
if (adding)
{
if (!theuser->GetExt(founder,dummyptr))
{
- theuser->Extend(founder,fakevalue);
+ log(DEBUG,"Does not have the ext item in ChanFounder");
+ if (!theuser->Extend(founder,fakevalue))
+ log(DEBUG,"COULD NOT EXTEND!!!");
// Tidy the nickname (make case match etc)
parameter = theuser->nick;
+ if (theuser->GetExt(founder, dummyptr))
+ log(DEBUG,"Extended!");
+ else
+ log(DEBUG,"Not extended :(");
return MODEACTION_ALLOW;
}
}
else
{
// whoops, someones being naughty!
- WriteServ(source->fd,"468 %s %s :Only servers may set channel mode +q",source->nick, channel->name);
+ source->WriteServ("468 %s %s :Only servers may set channel mode +q",source->nick, channel->name);
parameter = "";
return MODEACTION_DENY;
}
{
if (cl[i]->GetExt(founder, dummyptr))
{
- WriteServ(user->fd,"386 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ user->WriteServ("386 %s %s %s",user->nick, channel->name,cl[i]->nick);
}
}
- WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name);
+ user->WriteServ("387 %s %s :End of channel founder list",user->nick, channel->name);
}
};
public:
ChanProtect(Server* s) : ModeHandler('a', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { }
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
{
userrec* x = Find(parameter);
if (x)
std::string founder = "cm_founder_"+std::string(channel->name);
// source has +q, is a server, or ulined, we'll let them +-a the user.
- if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!*source->server) || (source->GetExt(founder,dummyptr)))
+ if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!*source->server) || (source->GetExt(founder,dummyptr)) || (!IS_LOCAL(source)))
{
if (adding)
{
else
{
// bzzzt, wrong answer!
- WriteServ(source->fd,"482 %s %s :You are not a channel founder",source->nick, channel->name);
+ source->WriteServ("482 %s %s :You are not a channel founder",source->nick, channel->name);
return MODEACTION_DENY;
}
}
{
if (cl[i]->GetExt(protect,dummyptr))
{
- WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ user->WriteServ("388 %s %s %s",user->nick, channel->name,cl[i]->nick);
}
}
- WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name);
+ user->WriteServ("389 %s %s :End of channel protected user list",user->nick, channel->name);
}
};
// Change requested by katsklaw... when the first in is set to get founder,
// to make it clearer that +q has been given, send that one user the +q notice
// so that their client's syncronization and their sanity are left intact.
- WriteServ(user->fd,"MODE %s +q %s",channel->name,user->nick);
+ user->WriteServ("MODE %s +q %s",channel->name,user->nick);
if (user->Extend("cm_founder_"+std::string(channel->name),fakevalue))
{
Srv->Log(DEBUG,"Marked user "+std::string(user->nick)+" as founder for "+std::string(channel->name));
// etc of protected users. There are many types of access check, we're going to handle
// a relatively small number of them relevent to our module using a switch statement.
+ log(DEBUG,"chanprotect OnAccessCheck %d",access_type);
// don't allow action if:
// (A) Theyre founder (no matter what)
// (B) Theyre protected, and you're not
{
// a user has been deopped. Do we let them? hmmm...
case AC_DEOP:
+ log(DEBUG,"OnAccessCheck AC_DEOP");
if (dest->GetExt(founder,dummyptr))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as they're a channel founder");
+ log(DEBUG,"Has %s",founder.c_str());
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as they're a channel founder");
return ACR_DENY;
}
+ else
+ {
+ log(DEBUG,"Doesnt have %s",founder.c_str());
+ }
if ((dest->GetExt(protect,dummyptr)) && (!source->GetExt(protect,dummyptr)))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as they're protected (+a)");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as they're protected (+a)");
return ACR_DENY;
}
break;
// a user is being kicked. do we chop off the end of the army boot?
case AC_KICK:
+ log(DEBUG,"OnAccessCheck AC_KICK");
if (dest->GetExt(founder,dummyptr))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as they're a channel founder");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as they're a channel founder");
return ACR_DENY;
}
if ((dest->GetExt(protect,dummyptr)) && (!source->GetExt(protect,dummyptr)))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as they're protected (+a)");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as they're protected (+a)");
return ACR_DENY;
}
break;
case AC_DEHALFOP:
if (dest->GetExt(founder,dummyptr))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as they're a channel founder");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as they're a channel founder");
return ACR_DENY;
}
if ((dest->GetExt(protect,dummyptr)) && (!source->GetExt(protect,dummyptr)))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as they're protected (+a)");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as they're protected (+a)");
return ACR_DENY;
}
break;
case AC_DEVOICE:
if (dest->GetExt(founder,dummyptr))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as they're a channel founder");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as they're a channel founder");
return ACR_DENY;
}
if ((dest->GetExt(protect,dummyptr)) && (!source->GetExt(protect,dummyptr)))
{
- Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as they're protected (+a)");
+ source->WriteServ("484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as they're protected (+a)");
return ACR_DENY;
}
break;