summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h14
-rw-r--r--src/inspircd.cpp12
-rw-r--r--src/modules.cpp2
3 files changed, 24 insertions, 4 deletions
diff --git a/include/modules.h b/include/modules.h
index 451c939ef..b380b6e2f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -232,7 +232,19 @@ class Module : public classbase
*/
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname);
-
+ /** Called whenever a user is about to be kicked.
+ * Returning a value of 1 from this function stops the process immediately, causing no
+ * output to be sent to the user by the core. If you do this you must produce your own numerics,
+ * notices etc.
+ */
+ virtual int OnUserPreKick(userrec* source, userrec* user, chanrec* chan, std::string reason);
+
+ /** Called whenever a user is kicked.
+ * If this method is called, the kick is already underway and cannot be prevented, so
+ * to prevent a kick, please use Module::OnUserPreKick instead of this method.
+ */
+ virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason);
+
/** Called whenever a user opers locally.
* The userrec will contain the oper mode 'o' as this function is called after any modifications
* are made to the user's structure by the core.
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 38c58179f..cc4ccd35c 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -1780,7 +1780,6 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
int MOD_RESULT = 0;
FOREACH_RESULT(OnAccessCheck(src,user,Ptr,AC_KICK));
-
if (MOD_RESULT == ACR_DENY)
return;
@@ -1800,7 +1799,14 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
return;
}
}
-
+
+ MOD_RESULT = 0;
+ FOREACH_RESULT(OnUserPreKick(src,user,Ptr,reason));
+ if (MOD_RESULT)
+ return;
+
+ FOREACH_MOD OnUserKick(src,user,Ptr,reason);
+
for (int i =0; i != MAXCHANS; i++)
{
/* zap it from the channel list of the user */
@@ -1814,7 +1820,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
break;
}
}
-
+
/* if there are no users left on the channel */
if (!usercount(Ptr))
{
diff --git a/src/modules.cpp b/src/modules.cpp
index 12dccdade..02221f1a6 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -335,6 +335,8 @@ void Module::OnSendList(userrec* user, chanrec* channel, char mode) { };
int Module::OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user) { return 0; };
bool Module::OnCheckReady(userrec* user) { return true; };
void Module::OnUserRegister(userrec* user) { };
+int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, std::string reason) { return 0; };
+void Module::OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason) { };
// server is a wrapper class that provides methods to all of the C-style
// exports in the core