diff options
author | Adam <Adam@anope.org> | 2011-03-07 19:54:51 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-03-07 19:54:51 -0500 |
commit | 8eb23e7d489239e8af79c2d6da587cd1c3a81b5d (patch) | |
tree | 04bf54ceb46a4b18345cf4e01d8aeb11ccd52c07 /modules/protocol/inspircd12.cpp | |
parent | 093b3d258e7b14d2aa057ca6113de034b5063efe (diff) |
Added support for extbans
Diffstat (limited to 'modules/protocol/inspircd12.cpp')
-rw-r--r-- | modules/protocol/inspircd12.cpp | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 5bdae4b7b..27f692956 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -311,6 +311,60 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string return true; } +template<typename T> class InspIRCdExtBan : public T +{ + public: + InspIRCdExtBan(ChannelModeName mName, char modeChar) : T(mName, modeChar) { } + + bool Matches(User *u, const Entry *e) + { + const Anope::string &mask = e->mask; + + if (mask.find("A:") == 0 || mask.find("B:") == 0 || mask.find("c:") == 0 || mask.find("C:") == 0 || + mask.find("m:") == 0 || mask.find("N:") == 0 || mask.find("p:") == 0 || mask.find("Q:") == 0 || + mask.find("N:") == 0 || mask.find("p:") == 0 || mask.find("Q:") == 0 || mask.find("S:") == 0 || + mask.find("T:") == 0) + { + Anope::string real_mask = mask.substr(2); + + Entry en(this->Name, real_mask); + if (en.Matches(u)) + return true; + } + else if (mask.find("j:") == 0) + { + Anope::string real_mask = mask.substr(2); + + Channel *c = findchan(real_mask); + if (c != NULL && c->FindUser(u) != NULL) + return true; + } + else if (mask.find("M:") == 0 || mask.find("R:") == 0) + { + Anope::string real_mask = mask.substr(2); + + if (u->IsIdentified() && real_mask.equals_ci(u->Account()->display)) + return true; + } + else if (mask.find("r:") == 0) + { + Anope::string real_mask = mask.substr(2); + + if (Anope::Match(u->realname, real_mask)) + return true; + } + else if (mask.find("s:") == 0) + { + Anope::string real_mask = mask.substr(2); + + if (Anope::Match(u->server->GetName(), real_mask)) + return true; + } + + return false; + } +}; + class Inspircd12IRCdMessage : public InspircdIRCdMessage { public: @@ -388,13 +442,13 @@ class Inspircd12IRCdMessage : public InspircdIRCdMessage switch (modebuf[t]) { case 'b': - ModeManager::AddChannelMode(new ChannelModeBan('b')); + ModeManager::AddChannelMode(new InspIRCdExtBan<ChannelModeBan>(CMODE_BAN, 'b')); continue; case 'e': - ModeManager::AddChannelMode(new ChannelModeExcept('e')); + ModeManager::AddChannelMode(new InspIRCdExtBan<ChannelModeList>(CMODE_EXCEPT, 'e')); continue; case 'I': - ModeManager::AddChannelMode(new ChannelModeInvex('I')); + ModeManager::AddChannelMode(new InspIRCdExtBan<ChannelModeList>(CMODE_INVITEOVERRIDE, 'I')); continue; /* InspIRCd sends q and a here if they have no prefixes */ case 'q': @@ -675,19 +729,6 @@ class Inspircd12IRCdMessage : public InspircdIRCdMessage } }; -bool ChannelModeFlood::IsValid(const Anope::string &value) const -{ - try - { - Anope::string rest; - if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) - return true; - } - catch (const CoreException &) { } - - return false; -} - class ProtoInspIRCd : public Module { Message message_endburst, message_time, |