- ConfigTag* tag = tags.first->second;
- tags.first++;
- CustomPrefixMode* mh = new CustomPrefixMode(this, tag);
- modes.push_back(mh);
- if (mh->GetPrefixRank() == 0)
- throw ModuleException("Rank must be specified for prefix at " + tag->getTagLocation());
- if (!isalpha(mh->GetModeChar()))
- throw ModuleException("Mode must be a letter for prefix at " + tag->getTagLocation());
+ 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 nonexistent 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());
+