summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp38
-rw-r--r--src/messages.cpp3
-rw-r--r--src/regchannel.cpp40
3 files changed, 39 insertions, 42 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 0a2f73ce1..ff060dce9 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -23,6 +23,7 @@
#include "config.h"
#include "access.h"
#include "sockets.h"
+#include "language.h"
channel_map ChannelList;
@@ -174,12 +175,12 @@ ChanUserContainer* Channel::JoinUser(User *user)
if (user->server && user->server->IsSynced())
Log(user, this, "join");
- FOREACH_MOD(OnJoinChannel, (user, this));
-
ChanUserContainer *cuc = new ChanUserContainer(user, this);
user->chans[this] = cuc;
this->users[user] = cuc;
+ FOREACH_MOD(OnJoinChannel, (user, this));
+
return cuc;
}
@@ -908,6 +909,39 @@ bool Channel::Unban(User *u, bool full)
return ret;
}
+bool Channel::CheckKick(User *user)
+{
+ if (user->super_admin)
+ return false;
+
+ /* We don't enforce services restrictions on clients on ulined services
+ * as this will likely lead to kick/rejoin floods. ~ Viper */
+ if (user->server->IsULined())
+ return false;
+
+ if (user->IsProtected())
+ return false;
+
+ Anope::string mask, reason;
+
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(OnCheckKick, MOD_RESULT, (user, this, mask, reason));
+ if (MOD_RESULT != EVENT_STOP)
+ return false;
+
+ if (mask.empty())
+ mask = this->ci->GetIdealBan(user);
+ if (reason.empty())
+ reason = Language::Translate(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN);
+
+ Log(LOG_DEBUG) << "Autokicking " << user->nick << " (" << mask << ") from " << this->name;
+
+ this->SetMode(NULL, "BAN", mask);
+ this->Kick(NULL, user, "%s", reason.c_str());
+
+ return true;
+}
+
Channel* Channel::Find(const Anope::string &name)
{
channel_map::const_iterator it = ChannelList.find(name);
diff --git a/src/messages.cpp b/src/messages.cpp
index f651b7352..ce92841e6 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -139,8 +139,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
*/
c->SetCorrectModes(u, true);
- if (c->ci)
- c->ci->CheckKick(u);
+ c->CheckKick(u);
}
/* Channel is done syncing */
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index bd8c3dca0..b1f056b27 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -18,7 +18,6 @@
#include "channels.h"
#include "config.h"
#include "bots.h"
-#include "language.h"
#include "servers.h"
Serialize::Checker<registered_channel_map> RegisteredChannelList("ChannelInfo");
@@ -1007,42 +1006,6 @@ Anope::string ChannelInfo::GetMLockAsString(bool complete) const
return pos + neg + params;
}
-bool ChannelInfo::CheckKick(User *user)
-{
- if (!user || !this->c)
- return false;
-
- if (user->super_admin)
- return false;
-
- /* We don't enforce services restrictions on clients on ulined services
- * as this will likely lead to kick/rejoin floods. ~ Viper */
- if (user->server->IsULined())
- return false;
-
- if (user->IsProtected())
- return false;
-
- Anope::string mask, reason;
-
- EventReturn MOD_RESULT;
- FOREACH_RESULT(OnCheckKick, MOD_RESULT, (user, this, mask, reason));
- if (MOD_RESULT != EVENT_STOP)
- return false;
-
- if (mask.empty())
- mask = this->GetIdealBan(user);
- if (reason.empty())
- reason = Language::Translate(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN);
-
- Log(LOG_DEBUG) << "Autokicking " << user->nick << " (" << mask << ") from " << this->name;
-
- this->c->SetMode(NULL, "BAN", mask);
- this->c->Kick(NULL, user, "%s", reason.c_str());
-
- return true;
-}
-
int16_t ChannelInfo::GetLevel(const Anope::string &priv) const
{
if (PrivilegeManager::FindPrivilege(priv) == NULL)
@@ -1074,7 +1037,8 @@ void ChannelInfo::ClearLevels()
Anope::string ChannelInfo::GetIdealBan(User *u) const
{
- switch (this->bantype)
+ int bt = this ? this->bantype : -1;
+ switch (bt)
{
case 0:
return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost();