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)
|
Base(Module* mod, const std::string& xbname, ExtBan::Letter xbletter)
|
||||||
: ServiceProvider(mod, xbname, SERVICE_CUSTOM)
|
: 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")
|
, manager(mod, "extbanmanager")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,20 @@
|
|||||||
|
|
||||||
void ExtBanManager::AddExtBan(ExtBan::Base* extban)
|
void ExtBanManager::AddExtBan(ExtBan::Base* extban)
|
||||||
{
|
{
|
||||||
auto lit = byletter.emplace(extban->GetLetter(), extban);
|
if (extban->GetLetter())
|
||||||
if (!lit.second)
|
{
|
||||||
throw ModuleException(creator, INSP_FORMAT("ExtBan letter \"{}\" is already in use by the {} extban from {}",
|
auto lit = byletter.emplace(extban->GetLetter(), extban);
|
||||||
extban->GetLetter(), lit.first->second->GetName(), lit.first->second->creator->ModuleFile));
|
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);
|
auto nit = byname.emplace(extban->GetName(), extban);
|
||||||
if (!nit.second)
|
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 {}",
|
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));
|
extban->GetName(), nit.first->second->GetLetter(), nit.first->second->creator->ModuleFile));
|
||||||
}
|
}
|
||||||
@ -63,7 +68,10 @@ bool ExtBanManager::Canonicalize(std::string& text) const
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ExtBan::Format::LETTER:
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -153,9 +161,12 @@ ModResult ExtBanManager::GetStatus(ExtBan::ActingBase* extban, User* user, Chann
|
|||||||
|
|
||||||
void ExtBanManager::DelExtBan(ExtBan::Base* extban)
|
void ExtBanManager::DelExtBan(ExtBan::Base* extban)
|
||||||
{
|
{
|
||||||
auto lit = byletter.find(extban->GetLetter());
|
if (extban->GetLetter())
|
||||||
if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr())
|
{
|
||||||
byletter.erase(lit);
|
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());
|
auto nit = byname.find(extban->GetName());
|
||||||
if (nit != byname.end() && nit->second->creator.ptr() == extban->creator.ptr())
|
if (nit != byname.end() && nit->second->creator.ptr() == extban->creator.ptr())
|
||||||
|
@ -300,8 +300,8 @@ bool TreeSocket::BuildExtBanList(std::string& out)
|
|||||||
if (!extbanmgr)
|
if (!extbanmgr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ExtBan::Manager::LetterMap& extbans = extbanmgr->GetLetterMap();
|
const auto& extbans = extbanmgr->GetNameMap();
|
||||||
for (ExtBan::Manager::LetterMap::const_iterator iter = extbans.begin(); iter != extbans.end(); ++iter)
|
for (auto iter = extbans.begin(); iter != extbans.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (iter != extbans.begin())
|
if (iter != extbans.begin())
|
||||||
out.push_back(' ');
|
out.push_back(' ');
|
||||||
@ -317,9 +317,9 @@ bool TreeSocket::BuildExtBanList(std::string& out)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.append(extban->GetName())
|
out.append(extban->GetName());
|
||||||
.append("=")
|
if (extban->GetLetter())
|
||||||
.push_back(extban->GetLetter());
|
out.append("=").push_back(extban->GetLetter());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user