summaryrefslogtreecommitdiff
path: root/src/modes.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-03-15 12:27:08 -0500
committerAdam <Adam@anope.org>2013-03-15 12:27:08 -0500
commit1a0e6b0be3f901462d4376c882f1dc7304bedaf9 (patch)
treeff20ba105783b7c79a14a257f79cabb5f3d63d0d /src/modes.cpp
parent81c89bb7080f17a4bdfd8912863285713e0822df (diff)
Allow autokicking real names, extbans, and channels
Diffstat (limited to 'src/modes.cpp')
-rw-r--r--src/modes.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/modes.cpp b/src/modes.cpp
index b7c22dfc7..0eee41682 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -626,7 +626,19 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh
this->user = nu;
}
else
- this->host = fh;
+ {
+ if (fh.find('.') != Anope::string::npos || fh.find(':') != Anope::string::npos)
+ this->host = fh;
+ else
+ this->nick = fh;
+ }
+
+ at = this->host.find('#');
+ if (at != Anope::string::npos)
+ {
+ this->real = this->host.substr(at + 1);
+ this->host = this->host.substr(0, at);
+ }
/* If the mask is all *'s it will match anything, so just clear it */
if (this->nick.find_first_not_of("*") == Anope::string::npos)
@@ -667,6 +679,9 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh
catch (const ConvertException &) { }
}
}
+
+ if (this->real.find_first_not_of("*") == Anope::string::npos)
+ this->real.clear();
}
const Anope::string Entry::GetMask() const
@@ -677,12 +692,15 @@ const Anope::string Entry::GetMask() const
bool Entry::Matches(const User *u, bool full) const
{
/* First check if this mode has defined any matches (usually for extbans). */
- ChannelMode *cm = ModeManager::FindChannelModeByName(this->name);
- if (cm != NULL && cm->type == MODE_LIST)
+ if (IRCD->IsExtbanValid(this->mask))
{
- ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm);
- if (cml->Matches(u, this))
- return true;
+ ChannelMode *cm = ModeManager::FindChannelModeByName(this->name);
+ if (cm != NULL && cm->type == MODE_LIST)
+ {
+ ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm);
+ if (cml->Matches(u, this))
+ return true;
+ }
}
/* If the user's displayed host is their real host, then we can do a full match without
@@ -714,6 +732,9 @@ bool Entry::Matches(const User *u, bool full) const
(!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->ip, this->host))))
ret = false;
+ if (!this->real.empty() && !Anope::Match(u->realname, this->real))
+ ret = false;
+
return ret;
}