本文整理汇总了C++中ModeHandler::IsPrefixMode方法的典型用法代码示例。如果您正苦于以下问题:C++ ModeHandler::IsPrefixMode方法的具体用法?C++ ModeHandler::IsPrefixMode怎么用?C++ ModeHandler::IsPrefixMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModeHandler
的用法示例。
在下文中一共展示了ModeHandler::IsPrefixMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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->IsPrefixMode())
continue;
if (mode->NeedsParam(true))
{
list.GetToken(parameter);
// If the parameter begins with a ':' then it's invalid
if (parameter.c_str()[0] == ':')
continue;
}
else
parameter.clear();
if ((mode->NeedsParam(true)) && (parameter.empty()))
continue;
mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
}
}
}
示例2: 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->IsPrefixMode())
continue;
if (mode->GetNumParams(true))
list.GetToken(parameter);
else
parameter.clear();
mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
}
}
}
示例3: FindPrefixMode
PrefixMode* ModeParser::FindPrefixMode(unsigned char modeletter)
{
ModeHandler* mh = FindMode(modeletter, MODETYPE_CHANNEL);
if (!mh)
return NULL;
return mh->IsPrefixMode();
}
示例4: SaveMemberData
void DataKeeper::SaveMemberData(Channel* chan, std::vector<OwnedModesExts>& memberdatalist)
{
ModesExts currdata;
const Channel::MemberMap& users = chan->GetUsers();
for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i)
{
Membership* const memb = i->second;
for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++)
{
ModeHandler* mh = handledmodes[MODETYPE_CHANNEL][j].mh;
if ((mh->IsPrefixMode()) && (memb->hasMode(mh->GetModeChar())))
currdata.modelist.push_back(InstanceData(j, memb->user->uuid)); // Need to pass the user's uuid to the mode parser to set the mode later
}
SaveExtensions(memb, currdata.extlist);
// Same logic as in DoSaveUsers()
if (!currdata.empty())
{
memberdatalist.push_back(OwnedModesExts(memb->user->uuid));
memberdatalist.back().swap(currdata);
}
}
}
示例5: FindMode
PrefixMode* FindMode(const std::string& mid)
{
if (mid.length() == 1)
return ServerInstance->Modes->FindPrefixMode(mid[0]);
ModeHandler* mh = ServerInstance->Modes->FindMode(mid, MODETYPE_CHANNEL);
return mh ? mh->IsPrefixMode() : NULL;
}
示例6: init
void init() override
{
ConfigTagList tags = ServerInstance->Config->ConfTags("customprefix");
for (ConfigIter iter = tags.first; iter != tags.second; ++iter)
{
ConfigTag* tag = iter->second;
const std::string name = tag->getString("name");
if (name.empty())
throw ModuleException("<customprefix:name> must be specified at " + tag->getTagLocation());
if (tag->getBool("change"))
{
ModeHandler* mh = ServerInstance->Modes.FindMode(name, MODETYPE_CHANNEL);
if (!mh)
throw ModuleException("<customprefix:change> specified for a non-existent mode at " + tag->getTagLocation());
PrefixMode* pm = mh->IsPrefixMode();
if (!pm)
throw ModuleException("<customprefix:change> specified for a non-prefix mode at " + tag->getTagLocation());
unsigned long rank = tag->getUInt("rank", pm->GetPrefixRank(), 0, UINT_MAX);
unsigned long setrank = tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, UINT_MAX);
unsigned long unsetrank = tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, UINT_MAX);
bool depriv = tag->getBool("depriv", pm->CanSelfRemove());
pm->Update(rank, setrank, unsetrank, depriv);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Changed the %s prefix: depriv=%u rank=%u ranktoset=%u ranktounset=%u",
pm->name.c_str(), pm->CanSelfRemove(), pm->GetPrefixRank(), pm->GetLevelRequired(true), pm->GetLevelRequired(false));
continue;
}
const std::string letter = tag->getString("letter");
if (letter.length() != 1)
throw ModuleException("<customprefix:letter> must be set to a mode character at " + tag->getTagLocation());
const std::string prefix = tag->getString("prefix");
if (prefix.length() != 1)
throw ModuleException("<customprefix:prefix> must be set to a mode prefix at " + tag->getTagLocation());
try
{
CustomPrefixMode* mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag);
modes.push_back(mh);
ServerInstance->Modules.AddService(*mh);
}
catch (ModuleException& e)
{
throw ModuleException(e.GetReason() + " (while creating mode from " + tag->getTagLocation() + ")");
}
}
}
示例7: GiveModeList
std::string ModeParser::GiveModeList(ModeType mt)
{
std::string type1; /* Listmodes EXCEPT those with a prefix */
std::string type2; /* Modes that take a param when adding or removing */
std::string type3; /* Modes that only take a param when adding */
std::string type4; /* Modes that dont take a param */
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
ModeHandler* mh = modehandlers[mt][mode-65];
/* One parameter when adding */
if (mh)
{
if (mh->GetNumParams(true))
{
PrefixMode* pm = mh->IsPrefixMode();
if ((mh->IsListMode()) && ((!pm) || (pm->GetPrefix() == 0)))
{
type1 += mh->GetModeChar();
}
else
{
/* ... and one parameter when removing */
if (mh->GetNumParams(false))
{
/* But not a list mode */
if (!pm)
{
type2 += mh->GetModeChar();
}
}
else
{
/* No parameters when removing */
type3 += mh->GetModeChar();
}
}
}
else
{
type4 += mh->GetModeChar();
}
}
}
return type1 + "," + type2 + "," + type3 + "," + type4;
}
示例8: Handle
CmdResult Handle(User* user, const Params& parameters) override
{
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(false))
{
user->WriteNotice("You do not have access to unset " + ConvToStr(modeletter) + " on " + chan->name + ".");
return CMD_FAILURE;
}
std::string pattern = parameters.size() > 2 ? parameters[2] : "*";
PrefixMode* pm;
ListModeBase* lm;
ListModeBase::ModeList* ml;
Modes::ChangeList changelist;
if ((pm = mh->IsPrefixMode()))
{
// As user prefix modes don't have a GetList() method, let's iterate through the channel's users.
const Channel::MemberMap& users = chan->GetUsers();
for (Channel::MemberMap::const_iterator it = users.begin(); it != users.end(); ++it)
{
if (!InspIRCd::Match(it->first->nick, pattern))
continue;
if (it->second->HasMode(pm) && !((it->first == user) && (pm->GetPrefixRank() > VOICE_VALUE)))
changelist.push_remove(mh, it->first->nick);
}
}
else if ((lm = mh->IsListModeBase()) && ((ml = lm->GetList(chan)) != NULL))
{
for (ListModeBase::ModeList::iterator it = ml->begin(); it != ml->end(); ++it)
{
if (!InspIRCd::Match(it->mask, pattern))
continue;
changelist.push_remove(mh, it->mask);
}
}
else
{
if (chan->IsModeSet(mh))
changelist.push_remove(mh);
}
ServerInstance->Modes.Process(user, chan, NULL, changelist);
return CMD_SUCCESS;
}
示例9: 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;
}
std::string pattern = parameters.size() > 2 ? parameters[2] : "*";
PrefixMode* pm;
ListModeBase* lm;
ListModeBase::ModeList* ml;
irc::modestacker modestack(false);
if ((pm = mh->IsPrefixMode()))
{
// As user prefix modes don't have a GetList() method, let's iterate through the channel's users.
const Channel::MemberMap& users = chan->GetUsers();
for (Channel::MemberMap::const_iterator it = users.begin(); it != users.end(); ++it)
{
if (!InspIRCd::Match(it->first->nick, pattern))
continue;
if (it->second->hasMode(modeletter) && !((it->first == user) && (pm->GetPrefixRank() > VOICE_VALUE)))
modestack.Push(modeletter, it->first->nick);
}
}
else if ((lm = mh->IsListModeBase()) && ((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
{
if (chan->IsModeSet(mh))
modestack.Push(modeletter);
}
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;
}