|
@@ -23,6 +23,9 @@ module {
|
|
|
// One include for all cross-platform compatibility thangs
|
|
|
#include "unrealircd.h"
|
|
|
|
|
|
+// Since v5.0.5 some hooks now include a SendType
|
|
|
+#define BACKPORT_HOOK_SENDTYPE (UNREAL_VERSION_GENERATION == 5 && UNREAL_VERSION_MAJOR == 0 && UNREAL_VERSION_MINOR < 5)
|
|
|
+
|
|
|
// Command strings
|
|
|
#define MSG_MSHUN "MSHUN"
|
|
|
#define MSG_MSHUN_ALT "MLINE"
|
|
@@ -62,11 +65,17 @@ MShun *find_mline(char *mask);
|
|
|
MShun *match_mline(Client *client);
|
|
|
int mshun_hook_serverconnect(Client *client);
|
|
|
int _check_premsg_isshunned(Client *client, int from_cansend, char **text, char **errmsg);
|
|
|
-int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, int notice);
|
|
|
-int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, int notice);
|
|
|
int mshun_hook_preknock(Client *client, Channel *channel);
|
|
|
int mshun_hook_preinvite(Client *client, Client *target, Channel *channel, int *override);
|
|
|
|
|
|
+#if BACKPORT_HOOK_SENDTYPE
|
|
|
+ int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, int notice);
|
|
|
+ int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, int notice);
|
|
|
+#else
|
|
|
+ int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, SendType sendtype);
|
|
|
+ int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, SendType sendtype);
|
|
|
+#endif
|
|
|
+
|
|
|
// Muh globals
|
|
|
ModDataInfo *mshunMDI; // To store the M-Lines with &me lol (hack so we don't have to use a .db file or some shit)
|
|
|
int mshunCount; // A counter for M-Lines so we can change the moddata back to NULL
|
|
@@ -104,7 +113,7 @@ static char *muhhalp[] = {
|
|
|
// Dat dere module header
|
|
|
ModuleHeader MOD_HEADER = {
|
|
|
"third/mshun", // Module name
|
|
|
- "2.0", // Version
|
|
|
+ "2.0.1", // Version
|
|
|
"Implements an M-Line for special shuns", // Description
|
|
|
"Gottem", // Author
|
|
|
"unrealircd-5", // Modversion
|
|
@@ -328,7 +337,7 @@ MShun *match_mline(Client *client) {
|
|
|
return find_mline(mask); // Returns NULL if n0, gg ez
|
|
|
}
|
|
|
|
|
|
-// Internal function called by the PRE_CHANMSG and CAN_SEND_TO_USER hooks ;];]
|
|
|
+// Internal function called by the CAN_SEND_TO_CHANNEL/USER hooks ;];]
|
|
|
int _check_premsg_isshunned(Client *client, int from_cansend, char **text, char **errmsg) {
|
|
|
if(MyUser(client) && !IsServer(client) && !IsMe(client) && !IsULine(client) && !IsOper(client) && match_mline(client)) { // Servers, U-Lines and opers are exempt for obv raisins
|
|
|
// This is a CAN_SEND type thing, so set text to NULL to drop em ;];];];]
|
|
@@ -357,15 +366,33 @@ int mshun_hook_serverconnect(Client *client) {
|
|
|
}
|
|
|
|
|
|
// Pre message hewks lol
|
|
|
-int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, int notice) {
|
|
|
- return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
-}
|
|
|
+#if BACKPORT_HOOK_SENDTYPE
|
|
|
+ int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, int notice) {
|
|
|
+ return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
+ }
|
|
|
|
|
|
-int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, int notice) {
|
|
|
- if(IsULine(to)) // Allow sending to U-Lines (NickServ etc famiglia) ;]
|
|
|
- return HOOK_CONTINUE;
|
|
|
- return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
-}
|
|
|
+ int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, int notice) {
|
|
|
+ if(IsULine(to)) // Allow sending to U-Lines (NickServ etc famiglia) ;]
|
|
|
+ return HOOK_CONTINUE;
|
|
|
+ return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
+ }
|
|
|
+
|
|
|
+#else
|
|
|
+ int mshun_hook_cansend_chan(Client *client, Channel *channel, Membership *lp, char **text, char **errmsg, SendType sendtype) {
|
|
|
+ if(sendtype != SEND_TYPE_PRIVMSG && sendtype != SEND_TYPE_NOTICE)
|
|
|
+ return HOOK_CONTINUE;
|
|
|
+ return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ int mshun_hook_cansend_user(Client *client, Client *to, char **text, char **errmsg, SendType sendtype) {
|
|
|
+ if(sendtype != SEND_TYPE_PRIVMSG && sendtype != SEND_TYPE_NOTICE)
|
|
|
+ return HOOK_CONTINUE;
|
|
|
+
|
|
|
+ if(IsULine(to)) // Allow sending to U-Lines (NickServ etc famiglia) ;]
|
|
|
+ return HOOK_CONTINUE;
|
|
|
+ return _check_premsg_isshunned(client, 1, text, errmsg);
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
// Also /knock
|
|
|
int mshun_hook_preknock(Client *client, Channel *channel) {
|