From 896195002cc903ec4b1ef7e1468f73c1dc08df9e Mon Sep 17 00:00:00 2001 From: Sven Moritz Hallberg Date: Sat, 16 Feb 2008 17:25:24 +0100 Subject: read root's welcome message from a file (like tho MOTD) --- Makefile | 2 ++ bitlbee.conf | 7 +++++++ conf.c | 6 ++++++ conf.h | 1 + irc.c | 28 ++++++++++++++++++++++++---- welcome.txt | 5 +++++ 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 welcome.txt diff --git a/Makefile b/Makefile index c0d7aad9..10c671d9 100644 --- a/Makefile +++ b/Makefile @@ -84,10 +84,12 @@ uninstall-dev: install-etc: mkdir -p $(DESTDIR)$(ETCDIR) install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt + install -m 0644 welcome.txt $(DESTDIR)$(ETCDIR)/welcome.txt install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf uninstall-etc: rm -f $(DESTDIR)$(ETCDIR)/motd.txt + rm -f $(DESTDIR)$(ETCDIR)/welcome.txt rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf -rmdir $(DESTDIR)$(ETCDIR) diff --git a/bitlbee.conf b/bitlbee.conf index d9f878c8..d2d8b559 100644 --- a/bitlbee.conf +++ b/bitlbee.conf @@ -72,6 +72,13 @@ ## # MotdFile = /etc/bitlbee/motd.txt +## WelcomeFile +## +## Specify an alternative file for the welcome message displayed when joining the +## control channel. Default value depends on the --etcdir argument to configure. +## +# WelcomeFile = /etc/bitlbee/welcome.txt + ## ConfigDir ## ## Specify an alternative directory to store all the per-user configuration diff --git a/conf.c b/conf.c index 94c673cc..f87eb983 100644 --- a/conf.c +++ b/conf.c @@ -60,6 +60,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->plugindir = g_strdup( PLUGINDIR ); conf->pidfile = g_strdup( PIDFILE ); conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); + conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" ); conf->ping_interval = 180; conf->ping_timeout = 300; conf->user = NULL; @@ -240,6 +241,11 @@ static int conf_loadini( conf_t *conf, char *file ) g_free( conf->motdfile ); conf->motdfile = g_strdup( ini->value ); } + else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 ) + { + g_free( conf->welcomefile ); + conf->welcomefile = g_strdup( ini->value ); + } else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) { g_free( conf->primary_storage ); diff --git a/conf.h b/conf.h index d21ec577..75c5ddb4 100644 --- a/conf.h +++ b/conf.h @@ -44,6 +44,7 @@ typedef struct conf char *plugindir; char *pidfile; char *motdfile; + char *welcomefile; char *primary_storage; char **migrate_storage; int ping_interval; diff --git a/irc.c b/irc.c index 7ef653a1..3ea0d755 100644 --- a/irc.c +++ b/irc.c @@ -31,6 +31,7 @@ #include static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); +static void irc_welcome( irc_t *irc ); GSList *irc_connection_list = NULL; @@ -786,10 +787,7 @@ void irc_login( irc_t *irc ) u->online = 1; irc_spawn( irc, u ); - irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there." ); - #ifdef WITH_OTR - irc_usermsg( irc, "\nOTR users please note: Private key files are owned by the user BitlBee is running as." ); - #endif + irc_welcome( irc ); if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname ); @@ -797,6 +795,28 @@ void irc_login( irc_t *irc ) irc->status |= USTATUS_LOGGED_IN; } +static void irc_welcome( irc_t *irc ) +{ + FILE *f; + + f = fopen( global.conf->welcomefile, "r" ); + if( !f ) + { + irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there.\n\nOTR users please note: Private key files are owned by the user BitlBee is running as." ); + } + else + { + char linebuf[380]; + + while( fgets( linebuf, 380, f ) ) + { + irc_usermsg( irc, linebuf ); + } + + fclose( f ); + } +} + void irc_motd( irc_t *irc ) { int fd; diff --git a/welcome.txt b/welcome.txt new file mode 100644 index 00000000..3216efc0 --- /dev/null +++ b/welcome.txt @@ -0,0 +1,5 @@ +Welcome to the BitlBee gateway! + +If you've never used BitlBee before, please do read the help information using the help command. Lots of FAQs are answered there. + +OTR users please note: Private key files are owned by the user BitlBee is running as. -- cgit v1.2.3