mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Add support for extbans without letters.
This commit is contained in:
parent
a9a6411051
commit
fc9d49641f
@ -204,7 +204,7 @@ protected:
|
||||
*/
|
||||
Base(Module* mod, const std::string& xbname, ExtBan::Letter xbletter)
|
||||
: ServiceProvider(mod, xbname, SERVICE_CUSTOM)
|
||||
, letter(ServerInstance->Config->ConfValue("extbans")->getCharacter(xbname, xbletter))
|
||||
, letter(ServerInstance->Config->ConfValue("extbans")->getCharacter(xbname, xbletter, true))
|
||||
, manager(mod, "extbanmanager")
|
||||
{
|
||||
}
|
||||
|
@ -22,15 +22,20 @@
|
||||
|
||||
void ExtBanManager::AddExtBan(ExtBan::Base* extban)
|
||||
{
|
||||
auto lit = byletter.emplace(extban->GetLetter(), extban);
|
||||
if (!lit.second)
|
||||
throw ModuleException(creator, INSP_FORMAT("ExtBan letter \"{}\" is already in use by the {} extban from {}",
|
||||
extban->GetLetter(), lit.first->second->GetName(), lit.first->second->creator->ModuleFile));
|
||||
if (extban->GetLetter())
|
||||
{
|
||||
auto lit = byletter.emplace(extban->GetLetter(), extban);
|
||||
if (!lit.second)
|
||||
throw ModuleException(creator, INSP_FORMAT("ExtBan letter \"{}\" is already in use by the {} extban from {}",
|
||||
extban->GetLetter(), lit.first->second->GetName(), lit.first->second->creator->ModuleFile));
|
||||
}
|
||||
|
||||
auto nit = byname.emplace(extban->GetName(), extban);
|
||||
if (!nit.second)
|
||||
{
|
||||
byletter.erase(extban->GetLetter());
|
||||
if (extban->GetLetter())
|
||||
byletter.erase(extban->GetLetter());
|
||||
|
||||
throw ModuleException(creator, INSP_FORMAT("ExtBan name \"{}\" is already in use by the {} extban from {}",
|
||||
extban->GetName(), nit.first->second->GetLetter(), nit.first->second->creator->ModuleFile));
|
||||
}
|
||||
@ -63,7 +68,10 @@ bool ExtBanManager::Canonicalize(std::string& text) const
|
||||
break;
|
||||
|
||||
case ExtBan::Format::LETTER:
|
||||
text.append(1, extban->GetLetter());
|
||||
if (extban->GetLetter())
|
||||
text.push_back(extban->GetLetter());
|
||||
else
|
||||
text.append(extban->GetName()); // ExtBan has no letter.
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -153,9 +161,12 @@ ModResult ExtBanManager::GetStatus(ExtBan::ActingBase* extban, User* user, Chann
|
||||
|
||||
void ExtBanManager::DelExtBan(ExtBan::Base* extban)
|
||||
{
|
||||
auto lit = byletter.find(extban->GetLetter());
|
||||
if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr())
|
||||
byletter.erase(lit);
|
||||
if (extban->GetLetter())
|
||||
{
|
||||
auto lit = byletter.find(extban->GetLetter());
|
||||
if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr())
|
||||
byletter.erase(lit);
|
||||
}
|
||||
|
||||
auto nit = byname.find(extban->GetName());
|
||||
if (nit != byname.end() && nit->second->creator.ptr() == extban->creator.ptr())
|
||||
|
@ -300,8 +300,8 @@ bool TreeSocket::BuildExtBanList(std::string& out)
|
||||
if (!extbanmgr)
|
||||
return false;
|
||||
|
||||
const ExtBan::Manager::LetterMap& extbans = extbanmgr->GetLetterMap();
|
||||
for (ExtBan::Manager::LetterMap::const_iterator iter = extbans.begin(); iter != extbans.end(); ++iter)
|
||||
const auto& extbans = extbanmgr->GetNameMap();
|
||||
for (auto iter = extbans.begin(); iter != extbans.end(); ++iter)
|
||||
{
|
||||
if (iter != extbans.begin())
|
||||
out.push_back(' ');
|
||||
@ -317,9 +317,9 @@ bool TreeSocket::BuildExtBanList(std::string& out)
|
||||
break;
|
||||
}
|
||||
|
||||
out.append(extban->GetName())
|
||||
.append("=")
|
||||
.push_back(extban->GetLetter());
|
||||
out.append(extban->GetName());
|
||||
if (extban->GetLetter())
|
||||
out.append("=").push_back(extban->GetLetter());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user