# Key file, syntax for each line: "<user>:<nick>:<key>".
# Default: none.
;KeyFile = :ETCDIR:/#chan.key
+
+ # Autojoin - set to yes to force all users to join this channel on connect
+ ;Autojoin = yes
[Channel]
# More [Channel] sections, if you like ...
This option can be specified multiple times, evaluated top to bottom.
.RE
.TP
+\fBAutojoin\fR (boolean)
+Forces users to join this channel on connect. Users must have access to the channel to make it work.
+.TP
\fBKeyFile\fR (string)
Path and file name of a "key file" containing individual channel keys for
different users. The file consists of plain text lines with the following
new_chan->name, new_chan->modes, new_chan->key,
new_chan->maxusers);
}
- if (channel_count)
- array_free(&Conf_Channels);
/* Make sure the local &SERVER channel exists */
if (!Channel_Search("&SERVER")) {
Config_Error_TooLong(File, Line, Var);
return;
}
+ if( strcasecmp( Var, "Autojoin" ) == 0 )
+ /* Check autojoin */
+ chan->autojoin = Check_ArgIsTrue(Arg);
if( strcasecmp( Var, "Key" ) == 0 ) {
/* Initial Channel Key (mode k) */
len = strlcpy(chan->key, Arg, sizeof(chan->key));
char key[CLIENT_PASS_LEN]; /**< Channel key ("password", mode "k" ) */
char topic[COMMAND_LEN]; /**< Initial topic */
char keyfile[512]; /**< Path and name of channel key file */
+ bool autojoin; /**< 1 to make all users autojoin this channel */
unsigned long maxusers; /**< User limit for this channel, mode "l" */
unsigned int modes_num; /**< Number of channel modes to evaluate */
};
} else
IRC_SetPenalty(Client, 1);
+ /* Autojoin clients to the channels */
+ Login_Autojoin(Client);
+
return CONNECTED;
}
+/**
+ * Autojoin clients to the channels set by administrator
+ * If autojoin is not set in Config or the channel is not available for search - do nothing
+ *
+ **/
+GLOBAL void
+Login_Autojoin(CLIENT *Client)
+{
+ /** make an autojoin to each channel that is good for it **/
+ REQUEST Req;
+ const struct Conf_Channel *conf_chan;
+ size_t i, n, channel_count = array_length(&Conf_Channels, sizeof(*conf_chan));
+ conf_chan = array_start(&Conf_Channels);
+ assert(channel_count == 0 || conf_chan != NULL);
+
+ for (i = 0; i < channel_count; i++, conf_chan++) {
+ if(!conf_chan->autojoin)
+ continue;
+ if (!Channel_Search(conf_chan->name))
+ continue;
+ Req.prefix = Client_ID(Client_ThisServer());
+ Req.command = "JOIN";
+ Req.argc = 1;
+ Req.argv[0] = conf_chan->name;
+ IRC_JOIN(Client, &Req);
+ }
+}
+
#ifdef PAM
/**
GLOBAL bool Login_User PARAMS((CLIENT * Client));
GLOBAL bool Login_User_PostAuth PARAMS((CLIENT *Client));
+GLOBAL void Login_Autojoin PARAMS((CLIENT *Client));
#endif