From 13ec57db159bcfbf54e7e57b6e136ed5e9e97198 Mon Sep 17 00:00:00 2001 From: JD Horelick Date: Wed, 24 Feb 2010 22:18:13 -0500 Subject: [PATCH] autochanmodes support --- TODO-SHADOW | 1 - doc/example.conf | 1 + doc/reference.conf | 5 +++++ include/s_conf.h | 1 + modules/m_info.c | 6 ++++++ src/channel.c | 18 ++++++++++++++++-- src/newconf.c | 1 + src/s_conf.c | 1 + 8 files changed, 31 insertions(+), 3 deletions(-) diff --git a/TODO-SHADOW b/TODO-SHADOW index 01422cb..ecff06d 100644 --- a/TODO-SHADOW +++ b/TODO-SHADOW @@ -2,7 +2,6 @@ Todo list for Shadowircd 6.0 ----------------------------- * swhois support * custom operstrings (?) -* autochanmodes defined in the .conf (cmodes that are set on a channel on initial join.) * halfops - probably enabled/disabled via a configure switch on in the .conf * owner/+a prefix/cmode - see comment for halfops :D * "soft" callerid umode (+G, only allows PM's from users in the same channel as you) diff --git a/doc/example.conf b/doc/example.conf index 08ae57b..7636a38 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -326,6 +326,7 @@ exempt { }; channel { + autochanmodes = "nt"; use_invex = yes; use_except = yes; use_knock = yes; diff --git a/doc/reference.conf b/doc/reference.conf index 96057d7..4c4e608 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -673,6 +673,11 @@ exempt { /* The channel block contains options pertaining to channels */ channel { + /* autochanmodes: Modes that will be set on a unregistered channel + * when the first user joins it. + */ + autochanmodes = "nt"; + /* invex: Enable/disable channel mode +I, a n!u@h list of masks * that can join a +i channel without an invite. */ diff --git a/include/s_conf.h b/include/s_conf.h index 2a95669..636f5e7 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -222,6 +222,7 @@ struct config_file_entry struct config_channel_entry { + char * autochanmodes; int use_except; int use_invex; int use_knock; diff --git a/modules/m_info.c b/modules/m_info.c index 18f7b58..53b0026 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -332,6 +332,12 @@ static struct InfoStruct info_table[] = { &ServerInfo.network_desc, "Network description" }, + { + "autochanmodes", + OUTPUT_STRING, + &ConfigChannel.autochanmodes, + "Channelmodes set on channel creation" + }, { "nick_delay", OUTPUT_DECIMAL, diff --git a/src/channel.c b/src/channel.c index 9134b57..dd7c2c6 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1679,8 +1679,22 @@ void user_join(struct Client * client_p, struct Client * source_p, const char * if(flags & CHFL_CHANOP) { chptr->channelts = rb_current_time(); - chptr->mode.mode |= MODE_TOPICLIMIT; - chptr->mode.mode |= MODE_NOPRIVMSGS; + + /* autochanmodes stuff */ + if(ConfigChannel.autochanmodes) + { + char * ch; + for(ch = ConfigChannel.autochanmodes; *ch; *ch++) + { + chptr->mode.mode |= chmode_table[*ch].mode_type; + } + } + else + { + chptr->mode.mode |= MODE_TOPICLIMIT; + chptr->mode.mode |= MODE_NOPRIVMSGS; + } + modes = channel_modes(chptr, &me); sendto_channel_local(ONLY_CHANOPS, chptr, ":%s MODE %s %s", diff --git a/src/newconf.c b/src/newconf.c index 05f32fa..2f333fe 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -2200,6 +2200,7 @@ static struct ConfEntry conf_general_table[] = static struct ConfEntry conf_channel_table[] = { + { "autochanmodes", CF_QSTRING, NULL, 0, &ConfigChannel.autochanmodes }, { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, diff --git a/src/s_conf.c b/src/s_conf.c index 22ba9e7..40a18b0 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -746,6 +746,7 @@ set_default_conf(void) ConfigFileEntry.oper_only_umodes = UMODE_SERVNOTICE; ConfigFileEntry.oper_snomask = SNO_GENERAL; + ConfigChannel.autochanmodes = rb_strdup("nt"); ConfigChannel.use_except = YES; ConfigChannel.use_invex = YES; ConfigChannel.use_knock = YES;