From 7673eb2e6fcdd8685d2c29760f1215d8ecbb86a9 Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 8 Jul 2011 17:26:36 +0200 Subject: [PATCH] channel created messages added --- src/chanserv.c | 23 +++++++++++++++++++++++ src/chanserv.h | 1 + src/proto-common.c | 1 + src/proto-p10.c | 2 ++ srvx.conf.example | 5 +++++ 5 files changed, 32 insertions(+) diff --git a/src/chanserv.c b/src/chanserv.c index b6da814..a76992e 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -58,6 +58,9 @@ #define KEY_MAX_USERINFO_LENGTH "max_userinfo_length" #define KEY_GIVEOWNERSHIP_PERIOD "giveownership_timeout" #define KEY_INVITED_INTERVAL "invite_timeout" +#define KEY_NEW_CHANNEL_AUTHED "new_channel_authed_join" +#define KEY_NEW_CHANNEL_UNAUTHED "new_channel_unauthed_join" +#define KEY_NEW_CHANNEL_MSG "new_channel_message" /* ChanServ database */ #define KEY_CHANNELS "channels" @@ -574,6 +577,10 @@ static struct const char *irc_operator_epithet; const char *network_helper_epithet; const char *support_helper_epithet; + + const char *new_channel_authed; + const char *new_channel_unauthed; + const char *new_channel_msg; } chanserv_conf; struct listData @@ -7048,6 +7055,16 @@ handle_new_channel(struct chanNode *channel) SetChannelTopic(channel, chanserv, channel->channel_info->topic, 1); } +void handle_new_channel_created(char *chan, struct userNode *user) { + if(user->handle_info && chanserv_conf.new_channel_authed) { + send_target_message(5, chan, chanserv, "%s", chanserv_conf.new_channel_authed); + } else if(!user->handle_info && chanserv_conf.new_channel_unauthed) { + send_target_message(5, chan, chanserv, "%s", chanserv_conf.new_channel_unauthed); + } + if(chanserv_conf.new_channel_msg) + send_target_message(5, chan, chanserv, "%s", chanserv_conf.new_channel_msg); +} + /* Welcome to my worst nightmare. Warning: Read (or modify) the code below at your own risk. */ static int @@ -7673,6 +7690,12 @@ chanserv_conf_read(void) chanserv_conf.network_helper_epithet = str ? str : "a wannabe tyrant"; str = database_get_data(conf_node, KEY_SUPPORT_HELPER_EPITHET, RECDB_QSTRING); chanserv_conf.support_helper_epithet = str ? str : "a wannabe tyrant"; + str = database_get_data(conf_node, KEY_NEW_CHANNEL_AUTHED, RECDB_QSTRING); + chanserv_conf.new_channel_authed = str ? str : NULL; + str = database_get_data(conf_node, KEY_NEW_CHANNEL_UNAUTHED, RECDB_QSTRING); + chanserv_conf.new_channel_unauthed = str ? str : NULL; + str = database_get_data(conf_node, KEY_NEW_CHANNEL_MSG, RECDB_QSTRING); + chanserv_conf.new_channel_msg = str ? str : NULL; str = database_get_data(conf_node, "default_modes", RECDB_QSTRING); if(!str) str = "+nt"; diff --git a/src/chanserv.h b/src/chanserv.h index 8faad9c..22fb717 100644 --- a/src/chanserv.h +++ b/src/chanserv.h @@ -199,5 +199,6 @@ unsigned short user_level_from_name(const char *name, unsigned short clamp_level struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle); int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner); struct mod_chanmode *find_matching_bans(struct banList *bans, struct userNode *actee, const char *mask); +void handle_new_channel_created(char *chan, struct userNode *user); #endif diff --git a/src/proto-common.c b/src/proto-common.c index fbd22e3..ee7a8b7 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -24,6 +24,7 @@ #include "log.h" #include "nickserv.h" #include "opserv.h" +#include "chanserv.h" #include "spamserv.h" #include "timeq.h" #ifdef HAVE_SYS_SOCKET_H diff --git a/src/proto-p10.c b/src/proto-p10.c index 0e4645a..f8817be 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -1197,6 +1197,8 @@ create_helper(char *name, void *data) return; } + handle_new_channel_created(name, cd->user); + AddChannelUser(cd->user, AddChannel(name, cd->when, NULL, NULL)); } diff --git a/srvx.conf.example b/srvx.conf.example index 2501d93..e9dcfc3 100644 --- a/srvx.conf.example +++ b/srvx.conf.example @@ -260,6 +260,11 @@ "nodelete_level" "1"; // how long before a new channel owner can give ownership away? "giveownership_timeout" "1w"; + // message sent to new channels + "new_channel_unauthed_join" ""; //only sent if the user is unauthed + "new_channel_authed_join" ""; //only sent if the user is authed + "new_channel_message" ""; //always after the message above + }; "global" { -- 2.20.1