本文整理汇总了C++中PrefixMode::GetLevelRequired方法的典型用法代码示例。如果您正苦于以下问题:C++ PrefixMode::GetLevelRequired方法的具体用法?C++ PrefixMode::GetLevelRequired怎么用?C++ PrefixMode::GetLevelRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrefixMode
的用法示例。
在下文中一共展示了PrefixMode::GetLevelRequired方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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() + ")");
}
}
}