summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-06-01 14:55:45 -0400
committerAdam <Adam@anope.org>2013-06-01 14:55:45 -0400
commitb56e71ab14b020a3a01f1fbd183382083156aaf4 (patch)
tree0a08e0f848697c9c8c708e2e2156ce6256481fe2 /src/channels.cpp
parent6f45d7249785b056ed78916d33ec45045a43ed92 (diff)
Move CheckKick event to Channel and make os_forbid use it instead of kicking users in the join event, which does bad things
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp38
1 files changed, 36 insertions, 2 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);