From 2b3c7c29c334c3ebb6a2da2176d89a65f5ad9ffa Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Thu, 25 Feb 2010 01:51:28 -0500 Subject: [PATCH] Add chmode +G, which blocks messages in all caps. --- help/opers/cmode | 2 ++ include/channel.h | 1 + modules/core/m_message.c | 18 ++++++++++++++++++ src/chmode.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/help/opers/cmode b/help/opers/cmode index 0bef5f6..af50219 100644 --- a/help/opers/cmode +++ b/help/opers/cmode @@ -35,6 +35,8 @@ NO PARAMETERS: channel. +N - No nickchanges. People on the channel will not be able to change nick. + +N - Block messages in all caps. Messages that are more than + 50% capital letters will be blocked. WITH PARAMETERS: +f - Forward. Forwards users who cannot join because of +i, diff --git a/include/channel.h b/include/channel.h index 4064c3d..db18116 100644 --- a/include/channel.h +++ b/include/channel.h @@ -179,6 +179,7 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p, #define MODE_NOACTION 0x32000 /* Block CTCP ACTION directed to this channel */ #define MODE_NOKICK 0x64000 /* Disable /kick on this channel */ #define MODE_NONICK 0x128000 /* Disable /nick for anyone on this channel */ +#define MODE_NOCAPS 0x256000 /* Block messages in all capital letters */ #define CHFL_BAN 0x10000000 /* ban channel flag */ #define CHFL_EXCEPTION 0x20000000 /* exception to ban channel flag */ diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 8277301..a3378f1 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -484,6 +484,9 @@ msg_channel(int p_or_n, const char *command, { int result; char text2[BUFSIZE]; + int contor; + int caps = 0; + int len = 0; if(MyClient(source_p)) { @@ -513,6 +516,21 @@ msg_channel(int p_or_n, const char *command, if(result == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr, chptr->chname)) { + if (strlen(text) > 10 && chptr->mode.mode & MODE_NOCAPS) + { + for(contor=0; contor < strlen(text); contor++) + { + if(IsUpper(text[contor]) && !isdigit(text[contor])) + caps++; + len++; + } + if(((caps*100)/(len)) >= 50) + { + sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN, + form_str(ERR_CANNOTSENDTOCHAN), chptr->chname); + return; + } + } if (p_or_n != PRIVMSG && chptr->mode.mode & MODE_NONOTICE) { sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN, diff --git a/src/chmode.c b/src/chmode.c index 49c5704..2319c51 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -1403,7 +1403,7 @@ struct ChannelMode chmode_table[256] = {chm_simple, MODE_NOACTION }, /* D */ {chm_simple, MODE_NOKICK }, /* E */ {chm_simple, MODE_FREETARGET }, /* F */ - {chm_nosuch, 0 }, /* G */ + {chm_simple, MODE_NOCAPS }, /* G */ {chm_nosuch, 0 }, /* H */ {chm_ban, CHFL_INVEX }, /* I */ {chm_nosuch, 0 }, /* J */