diff --git a/include/h.h b/include/h.h index 6c9bef93d..cd07572c9 100644 --- a/include/h.h +++ b/include/h.h @@ -435,9 +435,6 @@ extern MODVAR long SNO_SNOTICE; extern MODVAR long SNO_SPAMF; extern MODVAR long SNO_OPER; -/* Extended chanmodes... */ -extern MODVAR Cmode_t EXTMODE_NONOTICE; - #ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t size); #endif diff --git a/modules.conf b/modules.conf index 54ab43ab6..b8028ec23 100644 --- a/modules.conf +++ b/modules.conf @@ -124,6 +124,8 @@ loadmodule "modules/chanmodes/noknock"; /* +K */ loadmodule "modules/chanmodes/noinvite"; /* +V */ loadmodule "modules/chanmodes/operonly"; /* +O */ loadmodule "modules/chanmodes/adminonly"; /* +A */ +loadmodule "modules/chanmodes/nonotice"; /* +T */ + /*** User modes ***/ loadmodule "modules/usermodes/noctcp"; /* +T */ diff --git a/src/channel.c b/src/channel.c index 61a6a683f..55c2a5104 100644 --- a/src/channel.c +++ b/src/channel.c @@ -742,12 +742,13 @@ int is_chanprot(aClient *cptr, aChannel *chptr) #define CANNOT_SEND_BAN 4 #define CANNOT_SEND_MODREG 6 #define CANNOT_SEND_SWEAR 7 /* This isn't actually used here */ -#define CANNOT_SEND_NOTICE 8 +#define CANNOT_SEND_OTHER 8 int can_send(aClient *cptr, aChannel *chptr, char *msgtext, int notice) { Membership *lp; - int member; + int member, i; + Hook *h; /* * #0000053 by |savage|, speedup */ @@ -758,6 +759,7 @@ int can_send(aClient *cptr, aChannel *chptr, char *msgtext, int notice) } member = IsMember(cptr, chptr); + if (chptr->mode.mode & MODE_NOPRIVMSGS && !member) return (CANNOT_SEND_NOPRIVMSGS); @@ -775,9 +777,16 @@ int can_send(aClient *cptr, aChannel *chptr, char *msgtext, int notice) return (CANNOT_SEND_MODERATED); } - if (notice && (chptr->mode.extmode & EXTMODE_NONOTICE) && - (!lp || !(lp->flags & (CHFL_CHANOP | CHFL_CHANOWNER | CHFL_CHANPROT)))) - return (CANNOT_SEND_NOTICE); + + for (h = Hooks[HOOKTYPE_CAN_SEND]; h; h = h->next) + { + i = (*(h->func.intfunc))(cptr,chptr,msgtext,lp,notice); + if (i != HOOK_CONTINUE) + break; + } + + if (i == HOOK_DENY) + return (CANNOT_SEND_OTHER); /* Makes opers able to talk thru bans -Stskeeps suggested by The_Cat */ if (IsOper(cptr) && OPCanOverride(cptr)) diff --git a/src/extcmodes.c b/src/extcmodes.c index e9bca2a88..97c541074 100644 --- a/src/extcmodes.c +++ b/src/extcmodes.c @@ -56,8 +56,6 @@ unsigned short Channelmode_highest = 0; Cmode *ParamTable[MAXPARAMMODES+1]; -Cmode_t EXTMODE_NONOTICE = 0L; - void make_extcmodestr() { char *p; @@ -92,17 +90,6 @@ int i; *p = '\0'; } -static void load_extendedchanmodes(void) -{ - CmodeInfo req; - memset(&req, 0, sizeof(req)); - - req.paracount = 0; - req.is_ok = extcmode_default_requirechop; - req.flag = 'T'; - CmodeAdd(NULL, req, &EXTMODE_NONOTICE); -} - void extcmode_init(void) { Cmode_t val = 1; @@ -117,9 +104,6 @@ void extcmode_init(void) Channelmode_highest = 0; memset(&extchmstr, 0, sizeof(extchmstr)); memset(¶m_to_slot_mapping, 0, sizeof(param_to_slot_mapping)); - - /* And load the build-in extended chanmodes... */ - load_extendedchanmodes(); } /* Update letter->slot mapping and slot->handler mapping */ diff --git a/src/modules/chanmodes/Makefile.in b/src/modules/chanmodes/Makefile.in index 649ed7593..f183cffc2 100644 --- a/src/modules/chanmodes/Makefile.in +++ b/src/modules/chanmodes/Makefile.in @@ -32,7 +32,7 @@ INCLUDES = ../../include/auth.h ../../include/channel.h \ R_MODULES= \ nocolor.so stripcolor.so issecure.so permanent.so jointhrottle.so floodprot.so \ noctcp.so link.so censor.so delayjoin.so noknock.so noinvite.so operonly.so \ - adminonly.so + adminonly.so nonotice.so MODULES=$(R_MODULES) MODULEFLAGS=@MODULEFLAGS@ @@ -108,4 +108,8 @@ operonly.so: operonly.c $(INCLUDES) adminonly.so: adminonly.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ - -o adminonly.so adminonly.c \ No newline at end of file + -o adminonly.so adminonly.c + +nonotice.so: nonotice.c $(INCLUDES) + $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ + -o nonotice.so nonotice.c \ No newline at end of file diff --git a/src/modules/chanmodes/nonotice.c b/src/modules/chanmodes/nonotice.c new file mode 100644 index 000000000..db4131d95 --- /dev/null +++ b/src/modules/chanmodes/nonotice.c @@ -0,0 +1,97 @@ +/* + * Disallow notices in channel UnrealIRCd Module (Channel Mode +T) + * (C) Copyright 2014 Travis McArthur (Heero) and the UnrealIRCd team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "config.h" +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "proto.h" +#include "channel.h" +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#include +#include "h.h" +#ifdef _WIN32 +#include "version.h" +#endif + +DLLFUNC CMD_FUNC(nonotice); + +ModuleHeader MOD_HEADER(nonotice) + = { + "chanmodes/nonotice", + "$Id$", + "Channel Mode +T", + "3.2-b8-1", + NULL + }; + +Cmode_t EXTCMODE_NONOTICE; + +#define IsNoNotice(chptr) (chptr->mode.extmode & EXTCMODE_NONOTICE) + +int nonotice_check_can_send(aClient *cptr, aChannel *chptr, char *msgtext, Membership *lp, int notice); + +DLLFUNC int MOD_TEST(nonotice)(ModuleInfo *modinfo) +{ + return MOD_SUCCESS; +} + +DLLFUNC int MOD_INIT(nonotice)(ModuleInfo *modinfo) +{ + CmodeInfo req; + + memset(&req, 0, sizeof(req)); + req.paracount = 0; + req.flag = 'T'; + req.is_ok = extcmode_default_requirechop; + CmodeAdd(modinfo->handle, req, &EXTCMODE_NONOTICE); + + HookAddEx(modinfo->handle, HOOKTYPE_CAN_SEND, nonotice_check_can_send); + + MARK_AS_OFFICIAL_MODULE(modinfo); + return MOD_SUCCESS; +} + +DLLFUNC int MOD_LOAD(nonotice)(int module_load) +{ + return MOD_SUCCESS; +} + +DLLFUNC int MOD_UNLOAD(nonotice)(int module_unload) +{ + return MOD_SUCCESS; +} + +int nonotice_check_can_send(aClient *cptr, aChannel *chptr, char *msgtext, Membership *lp, int notice) +{ + if (notice && IsNoNotice(chptr) && + (!lp || !(lp->flags & (CHFL_CHANOP | CHFL_CHANOWNER | CHFL_CHANPROT)))) + return HOOK_DENY; + + return HOOK_CONTINUE; +}