X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_customprefix.cpp;h=befc9750d1c90e89957ee14e15ea9b07a635cca0;hb=d4a1ea70451abb333e71f9cff09b624db59531a0;hp=c8ebde5ccae9de2de5ed22836a6f0a43d88eeddc;hpb=76e3b7860411c79fb3c6b56c7d15bf7ba1fd569a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp index c8ebde5cc..befc9750d 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -28,10 +28,14 @@ class CustomPrefixMode : public PrefixMode : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { - prefixrank = tag->getInt("rank", 0, 0, UINT_MAX); - ranktoset = tag->getInt("ranktoset", prefixrank, prefixrank, UINT_MAX); - ranktounset = tag->getInt("ranktounset", ranktoset, ranktoset, UINT_MAX); - selfremove = tag->getBool("depriv", true); + unsigned long rank = tag->getUInt("rank", 0, 0, UINT_MAX); + unsigned long setrank = tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX); + unsigned long unsetrank = tag->getUInt("ranktounset", setrank, setrank, UINT_MAX); + bool depriv = tag->getBool("depriv", true); + this->Update(rank, setrank, unsetrank, depriv); + + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Created the %s prefix: letter=%c prefix=%c rank=%u ranktoset=%u ranktounset=%i depriv=%d", + name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), CanSelfRemove()); } }; @@ -50,6 +54,27 @@ class ModuleCustomPrefix : public Module if (name.empty()) throw ModuleException(" must be specified at " + tag->getTagLocation()); + if (tag->getBool("change")) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(name, MODETYPE_CHANNEL); + if (!mh) + throw ModuleException(" specified for a non-existent mode at " + tag->getTagLocation()); + + PrefixMode* pm = mh->IsPrefixMode(); + if (!pm) + throw ModuleException(" 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(" must be set to a mode character at " + tag->getTagLocation()); @@ -61,6 +86,7 @@ class ModuleCustomPrefix : public Module try { CustomPrefixMode* mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag); + modes.push_back(mh); ServerInstance->Modules->AddService(*mh); } catch (ModuleException& e)