本文整理汇总了C++中ModeHandler::GetPrefixRank方法的典型用法代码示例。如果您正苦于以下问题:C++ ModeHandler::GetPrefixRank方法的具体用法?C++ ModeHandler::GetPrefixRank怎么用?C++ ModeHandler::GetPrefixRank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModeHandler
的用法示例。
在下文中一共展示了ModeHandler::GetPrefixRank方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Call
ModResult Call(User* user, Channel* chan, const std::string& restriction)
{
unsigned int mypfx = chan->GetPrefixValue(user);
std::string minmode;
modelist* list = ec.extItem.get(chan);
if (list)
{
for (modelist::iterator i = list->begin(); i != list->end(); ++i)
{
std::string::size_type pos = (*i).mask.find(':');
if (pos == std::string::npos)
continue;
if ((*i).mask.substr(0,pos) == restriction)
minmode = (*i).mask.substr(pos + 1);
}
}
ModeHandler* mh = FindMode(minmode);
if (mh && mypfx >= mh->GetPrefixRank())
return MOD_RES_ALLOW;
if (mh || minmode == "*")
return MOD_RES_DENY;
return ServerInstance->HandleOnCheckExemption.Call(user, chan, restriction);
}
示例2: AccessCheck
ModResult AccessCheck(User* source, Channel* channel, std::string ¶meter, bool adding)
{
std::string::size_type pos = parameter.find(':');
if (pos == 0 || pos == std::string::npos)
return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU;
unsigned int mylevel = channel->GetPrefixValue(source);
std::string mid = parameter.substr(0, pos);
ModeHandler* mh = FindMode(mid);
if (adding && (!mh || !mh->GetPrefixRank()))
{
source->WriteNumeric(415, "%s %s :Cannot find prefix mode '%s' for autoop",
source->nick.c_str(), mid.c_str(), mid.c_str());
return MOD_RES_DENY;
}
else if (!mh)
return MOD_RES_PASSTHRU;
std::string dummy;
if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
return MOD_RES_DENY;
if (mh->GetLevelRequired() > mylevel)
{
source->WriteNumeric(482, "%s %s :You must be able to set mode '%s' to include it in an autoop",
source->nick.c_str(), channel->name.c_str(), mid.c_str());
return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
}
示例3: GetListOfServersForChannel
/* returns a list of DIRECT servernames for a specific channel */
void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list)
{
unsigned int minrank = 0;
if (status)
{
ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
if (mh)
minrank = mh->GetPrefixRank();
}
const UserMembList *ulist = c->GetUsers();
for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
{
if (IS_LOCAL(i->first))
continue;
if (minrank && i->second->getRank() < minrank)
continue;
if (exempt_list.find(i->first) == exempt_list.end())
{
TreeServer* best = this->BestRouteTo(i->first->server);
if (best)
list.insert(best->GetSocket());
}
}
return;
}
示例4: OnPostJoin
void OnPostJoin(Membership *memb)
{
if (!IS_LOCAL(memb->user))
return;
modelist* list = mh.extItem.get(memb->chan);
if (list)
{
std::string modeline("+");
std::vector<std::string> modechange;
modechange.push_back(memb->chan->name);
for (modelist::iterator it = list->begin(); it != list->end(); it++)
{
std::string::size_type colon = it->mask.find(':');
if (colon == std::string::npos)
continue;
if (memb->chan->CheckBan(memb->user, it->mask.substr(colon+1)))
{
ModeHandler* given = mh.FindMode(it->mask.substr(0, colon));
if (given && given->GetPrefixRank())
modeline.push_back(given->GetModeChar());
}
}
modechange.push_back(modeline);
for(std::string::size_type i = modeline.length(); i > 1; --i) // we use "i > 1" instead of "i" so we skip the +
modechange.push_back(memb->user->nick);
if(modechange.size() >= 3)
ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient);
}
}
示例5: SetDefaultModes
void Channel::SetDefaultModes()
{
ServerInstance->Logs->Log("CHANNELS", LOG_DEBUG, "SetDefaultModes %s",
ServerInstance->Config->DefaultModes.c_str());
irc::spacesepstream list(ServerInstance->Config->DefaultModes);
std::string modeseq;
std::string parameter;
list.GetToken(modeseq);
for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
{
ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
if (mode)
{
if (mode->GetPrefixRank())
continue;
if (mode->GetNumParams(true))
list.GetToken(parameter);
else
parameter.clear();
mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
}
}
}
示例6: Call
ModResult OnCheckExemptionHandler::Call(User* user, Channel* chan, const std::string& restriction)
{
unsigned int mypfx = chan->GetPrefixValue(user);
char minmode = 0;
std::string current;
irc::spacesepstream defaultstream(ServerInstance->Config->ConfValue("options")->getString("exemptchanops"));
while (defaultstream.GetToken(current))
{
std::string::size_type pos = current.find(':');
if (pos == std::string::npos)
continue;
if (current.substr(0,pos) == restriction)
minmode = current[pos+1];
}
ModeHandler* mh = ServerInstance->Modes->FindMode(minmode, MODETYPE_CHANNEL);
if (mh && mypfx >= mh->GetPrefixRank())
return MOD_RES_ALLOW;
if (mh || minmode == '*')
return MOD_RES_DENY;
return MOD_RES_PASSTHRU;
}
示例7: Handle
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
{
ModeHandler* mh;
Channel* chan = ServerInstance->FindChan(parameters[0]);
char modeletter = parameters[1][0];
if (chan == NULL)
{
user->WriteNotice("The channel " + parameters[0] + " does not exist.");
return CMD_FAILURE;
}
mh = ServerInstance->Modes->FindMode(modeletter, MODETYPE_CHANNEL);
if (mh == NULL || parameters[1].size() > 1)
{
user->WriteNotice(parameters[1] + " is not a valid channel mode.");
return CMD_FAILURE;
}
if (chan->GetPrefixValue(user) < mh->GetLevelRequired())
{
user->WriteNotice("You do not have access to unset " + ConvToStr(modeletter) + " on " + chan->name + ".");
return CMD_FAILURE;
}
unsigned int prefixrank;
char prefixchar;
std::string pattern = parameters.size() > 2 ? parameters[2] : "*";
ListModeBase* lm;
ListModeBase::ModeList* ml;
irc::modestacker modestack(false);
if (!mh->IsListMode())
{
if (chan->IsModeSet(mh))
modestack.Push(modeletter);
}
else if (((prefixrank = mh->GetPrefixRank()) && (prefixchar = mh->GetPrefix())))
{
// As user prefix modes don't have a GetList() method, let's iterate through the channel's users.
for (UserMembIter it = chan->userlist.begin(); it != chan->userlist.end(); ++it)
{
if (!InspIRCd::Match(it->first->nick, pattern))
continue;
if (((strchr(chan->GetAllPrefixChars(user), prefixchar)) != NULL) && !(it->first == user && prefixrank > VOICE_VALUE))
modestack.Push(modeletter, it->first->nick);
}
}
else if (((lm = dynamic_cast<ListModeBase*>(mh)) != NULL) && ((ml = lm->GetList(chan)) != NULL))
{
for (ListModeBase::ModeList::iterator it = ml->begin(); it != ml->end(); ++it)
{
if (!InspIRCd::Match(it->mask, pattern))
continue;
modestack.Push(modeletter, it->mask);
}
}
else
{
user->WriteNotice("Could not remove channel mode " + ConvToStr(modeletter));
return CMD_FAILURE;
}
parameterlist stackresult;
stackresult.push_back(chan->name);
while (modestack.GetStackedLine(stackresult))
{
ServerInstance->Modes->Process(stackresult, user);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
return CMD_SUCCESS;
}