diff -uNrd -x CVS ircd-hybrid-6.dist/README.QOTD ircd-hybrid-6/README.QOTD --- ircd-hybrid-6.dist/README.QOTD Wed Dec 31 19:00:00 1969 +++ ircd-hybrid-6/README.QOTD Sun Feb 10 17:50:39 2002 @@ -0,0 +1,16 @@ +The QOTD patch provoides a "Quote of the Day" service in ircd. + +ircd.quote contains any number of one line quotes or messages. +ircd will choose a line from the file randomly on each client +connection and issue of the /qotd command. + +The default ircd.quote file contains a few brief hints for users, +and is installed into the ircd's running directory. The admin +should replace it with their own quote file, and issue +/rehash qotd to force a reread. If ircd.quote exists in the +DPATH directory, the default will not be installed. + ++qotd1 +Against: 6.3rc6 + +10 Feb 2002 diff -uNrd -x CVS ircd-hybrid-6.dist/include/config.h ircd-hybrid-6/include/config.h --- ircd-hybrid-6.dist/include/config.h Sun Feb 10 16:23:45 2002 +++ ircd-hybrid-6/include/config.h Sun Feb 10 17:07:59 2002 @@ -88,6 +88,7 @@ * DLPATH = dline conf file * * OMOTD = path to MOTD for opers + * QPATH = path to the quote of the day file * * For /restart to work, SPATH needs to be a full pathname * (unless "." is in your exec path). -Rodder @@ -110,6 +111,7 @@ #define PPATH "ircd.pid" #define HPATH "opers.txt" #define OPATH "opers.motd" +#define QPATH "ircd.quote" /* HIDE_OPS * Define this to prevent non chanops from seeing what ops a channel has diff -uNrd -x CVS ircd-hybrid-6.dist/include/config.h.dist ircd-hybrid-6/include/config.h.dist --- ircd-hybrid-6.dist/include/config.h.dist Sun Feb 10 16:23:45 2002 +++ ircd-hybrid-6/include/config.h.dist Sun Feb 10 17:13:09 2002 @@ -88,6 +88,7 @@ * DLPATH = dline conf file * * OMOTD = path to MOTD for opers + * QPATH = path to the quote of the day file * * For /restart to work, SPATH needs to be a full pathname * (unless "." is in your exec path). -Rodder @@ -110,6 +111,7 @@ #define PPATH "ircd.pid" #define HPATH "opers.txt" #define OPATH "opers.motd" +#define QPATH "ircd.quote" /* HIDE_OPS * Define this to prevent non chanops from seeing what ops a channel has diff -uNrd -x CVS ircd-hybrid-6.dist/include/m_commands.h ircd-hybrid-6/include/m_commands.h --- ircd-hybrid-6.dist/include/m_commands.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/m_commands.h Sun Feb 10 17:02:30 2002 @@ -99,4 +99,6 @@ extern int m_dns(struct Client *,struct Client *,int,char **); extern int m_htm(struct Client *,struct Client *,int,char **); extern int m_set(struct Client *,struct Client *,int,char **); + +extern int m_qotd(struct Client *,struct Client *,int,char **); #endif /* INCLUDED_m_commands_h */ diff -uNrd -x CVS ircd-hybrid-6.dist/include/motd.h ircd-hybrid-6/include/motd.h --- ircd-hybrid-6.dist/include/motd.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/motd.h Sun Feb 10 16:29:03 2002 @@ -18,7 +18,8 @@ typedef enum { USER_MOTD, OPER_MOTD, - HELP_MOTD + HELP_MOTD, + QUOTE_MOTD } MotdType; struct MessageFileLine @@ -33,6 +34,7 @@ { char fileName[PATH_MAX + 1]; MotdType motdType; + int linecount; MessageFileLine* contentsOfFile; char lastChangedDate[MAX_DATE_STRING + 1]; }; diff -uNrd -x CVS ircd-hybrid-6.dist/include/msg.h ircd-hybrid-6/include/msg.h --- ircd-hybrid-6.dist/include/msg.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/msg.h Sun Feb 10 17:03:52 2002 @@ -129,6 +129,8 @@ #define MSG_KNOCK "KNOCK" /* KNOCK */ +#define MSG_QOTD "QOTD" /* QOTD */ + #define MAXPARA 15 #define MSG_TESTLINE "TESTLINE" @@ -252,6 +254,7 @@ { MSG_DIE, m_die, 0, MAXPARA, 1, 0, 0, 0L }, { MSG_HTM, m_htm, 0, MAXPARA, 1, 0, 0, 0L }, { MSG_SET, m_set, 0, MAXPARA, 1, 0, 0, 0L }, + { MSG_QOTD, m_qotd, 0, MAXPARA, 1, 0, 0, 0L }, { MSG_TESTLINE, m_testline, 0, MAXPARA, 1, 0, 0, 0L }, { (char *) 0, (int (*)()) 0 , 0, 0, 0, 0, 0, 0L } }; diff -uNrd -x CVS ircd-hybrid-6.dist/include/patchlevel.h ircd-hybrid-6/include/patchlevel.h --- ircd-hybrid-6.dist/include/patchlevel.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/patchlevel.h Sun Feb 10 17:50:50 2002 @@ -19,5 +19,5 @@ */ #ifndef PATCHLEVEL -#define PATCHLEVEL "2.8/hybrid-6.3rc6" +#define PATCHLEVEL "2.8/hybrid-6.3rc6+qotd1" #endif diff -uNrd -x CVS ircd-hybrid-6.dist/include/s_conf.h ircd-hybrid-6/include/s_conf.h --- ircd-hybrid-6.dist/include/s_conf.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/s_conf.h Sun Feb 10 16:48:19 2002 @@ -175,6 +175,7 @@ MessageFile helpfile; MessageFile motd; MessageFile opermotd; + MessageFile qotdfile; } ConfigFileEntryType; /* aConfItems */ diff -uNrd -x CVS ircd-hybrid-6.dist/include/s_user.h ircd-hybrid-6/include/s_user.h --- ircd-hybrid-6.dist/include/s_user.h Sun Feb 10 16:23:46 2002 +++ ircd-hybrid-6/include/s_user.h Sun Feb 10 17:04:36 2002 @@ -41,5 +41,7 @@ extern int show_lusers(struct Client *, struct Client *, int, char **); extern void show_opers(struct Client* client); +extern void send_qotd(struct Client *); + #endif diff -uNrd -x CVS ircd-hybrid-6.dist/ircd.quote ircd-hybrid-6/ircd.quote --- ircd-hybrid-6.dist/ircd.quote Wed Dec 31 19:00:00 1969 +++ ircd-hybrid-6/ircd.quote Sun Feb 10 17:43:49 2002 @@ -0,0 +1,10 @@ +Try /stats m for a list of commands +O: lines are not given, they are taken +Use /stats p to find opers +The 004 numeric shows you the valid user and channel modes +If you get a "server is too busy" message, wait about 10 seconds and try again +The 005 numeric allows clients and scripts to customize themselves to the daemon +'/userhost yournick' will give you your current IP address +'/whois nick nick' will display the idle time for a user +'/time ' will display the server's time +Enjoy your stay! diff -uNrd -x CVS ircd-hybrid-6.dist/src/ircd.c ircd-hybrid-6/src/ircd.c --- ircd-hybrid-6.dist/src/ircd.c Sun Feb 10 16:23:48 2002 +++ ircd-hybrid-6/src/ircd.c Sun Feb 10 17:09:56 2002 @@ -611,10 +611,12 @@ InitMessageFile( HELP_MOTD, HPATH, &ConfigFileEntry.helpfile ); InitMessageFile( USER_MOTD, MPATH, &ConfigFileEntry.motd ); InitMessageFile( OPER_MOTD, OPATH, &ConfigFileEntry.opermotd ); + InitMessageFile( QUOTE_MOTD, QPATH, &ConfigFileEntry.qotdfile ); ReadMessageFile( &ConfigFileEntry.helpfile ); ReadMessageFile( &ConfigFileEntry.motd ); ReadMessageFile( &ConfigFileEntry.opermotd ); + ReadMessageFile( &ConfigFileEntry.qotdfile ); } /* diff -uNrd -x CVS ircd-hybrid-6.dist/src/m_rehash.c ircd-hybrid-6/src/m_rehash.c --- ircd-hybrid-6.dist/src/m_rehash.c Sun Feb 10 16:23:50 2002 +++ ircd-hybrid-6/src/m_rehash.c Sun Feb 10 16:35:17 2002 @@ -197,6 +197,13 @@ ReadMessageFile( &ConfigFileEntry.helpfile ); found = YES; } + else if(irccmp(parv[1],"QOTD") == 0) + { + sendto_ops("%s is forcing re-reading of quote of the day file", + parv[0]); + ReadMessageFile( &ConfigFileEntry.qotdfile ); + found = YES; + } else if(irccmp(parv[1],"DUMP") == 0) { sendto_ops("%s is dumping conf file",parv[0]); @@ -227,10 +234,10 @@ else { #ifdef GLINES - sendto_one(sptr, ":%s NOTICE %s :Rehash one of: DNS, TKLINES, GLINES, GC, HELP, MOTD, OMOTD, DUMP, DLINES", + sendto_one(sptr, ":%s NOTICE %s :Rehash one of: DNS, TKLINES, GLINES, GC, HELP, MOTD, OMOTD, QOTD, DUMP, DLINES", me.name, sptr->name); #else - sendto_one(sptr, ":%s NOTICE %s :Rehash one of: DNS, TKLINES, GC, HELP, MOTD, OMOTD, DUMP, DLINES", + sendto_one(sptr, ":%s NOTICE %s :Rehash one of: DNS, TKLINES, GC, HELP, MOTD, OMOTD, QOTD, DUMP, DLINES", me.name, sptr->name); #endif return(0); diff -uNrd -x CVS ircd-hybrid-6.dist/src/motd.c ircd-hybrid-6/src/motd.c --- ircd-hybrid-6.dist/src/motd.c Sun Feb 10 16:23:48 2002 +++ ircd-hybrid-6/src/motd.c Sun Feb 10 17:01:31 2002 @@ -79,6 +79,11 @@ return(SendMessageFile(sptr,&ConfigFileEntry.motd)); } +int m_qotd(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + return send_qotd(sptr); +} + /* ** InitMessageFile ** @@ -90,6 +95,7 @@ motd->motdType = motdType; motd->contentsOfFile = NULL; motd->lastChangedDate[0] = '\0'; + motd->linecount = 0; } /* @@ -146,6 +152,9 @@ case HELP_MOTD: break; + case QUOTE_MOTD: + break; + default: return 0; /* NOT REACHED */ @@ -215,6 +224,8 @@ MessageFileptr->contentsOfFile = NULL; + MessageFileptr->linecount = 0; + if ((file = fbopen(MessageFileptr->fileName, "r")) == 0) return(-1); @@ -227,6 +238,8 @@ strncpy_irc(newMessageLine->line, buffer, MESSAGELINELEN); newMessageLine->line[MESSAGELINELEN] = '\0'; newMessageLine->next = (MessageFileLine *)NULL; + + MessageFileptr->linecount++; if (MessageFileptr->contentsOfFile) { diff -uNrd -x CVS ircd-hybrid-6.dist/src/s_user.c ircd-hybrid-6/src/s_user.c --- ircd-hybrid-6.dist/src/s_user.c Sun Feb 10 16:23:51 2002 +++ ircd-hybrid-6/src/s_user.c Sun Feb 10 18:02:15 2002 @@ -823,6 +823,8 @@ #else SendMessageFile(sptr, &ConfigFileEntry.motd); #endif + + send_qotd(sptr); #ifdef LITTLE_I_LINES if(sptr->confs && sptr->confs->value.aconf && @@ -2205,4 +2207,40 @@ if (cptr && MyClient(cptr)) send_umode(cptr, sptr, old, ALL_UMODES, buf); +} + +/* send_qotd - Send the Quote of the Day out to the specified user. + * This function chooses a random item from the QOTD file and displays it + * to the user. - Hwy (proof of concept patch) + */ +void send_qotd(aClient *sptr) +{ + int i; + int desired; + MessageFileLine *linenode = ConfigFileEntry.qotdfile.contentsOfFile; + + if (linenode == NULL) + { + sendto_one(sptr, ":%s NOTICE %s :Notice - QOTD File Missing", me.name, + sptr->name); + return; + } + + desired = my_rand() % ConfigFileEntry.qotdfile.linecount; + + /* This for loop is a performance hit....for this reason, the QOTD patch + * CANNOT be run on a high load server. -Hwy + */ + + /* desired can be zero, the first line of the file */ + for (i = 0; i < desired; i++) + linenode = linenode->next; + + sendto_one(sptr, ":%s NOTICE %s :Notice - %s quote of the day", + me.name, sptr->name, me.name); + sendto_one(sptr, ":%s NOTICE %s :Notice - for %s", me.name, sptr->name, + myctime(CurrentTime)); + sendto_one(sptr, ":%s NOTICE %s :%s", me.name, sptr->name, + linenode->line); + /* I don't think an "end of qotd" notice is necessary here... */ } diff -uNrd -x CVS ircd-hybrid-6.dist/tools/install_ircd ircd-hybrid-6/tools/install_ircd --- ircd-hybrid-6.dist/tools/install_ircd Sun Feb 10 16:23:51 2002 +++ ircd-hybrid-6/tools/install_ircd Sun Feb 10 18:00:23 2002 @@ -47,6 +47,7 @@ LPATH=`grep '#define.LPATH' include/config.h|awk '{print $3}'|tr -d \"`; PPATH=`grep '#define.PPATH' include/config.h|awk '{print $3}'|tr -d \"`; HPATH=`grep '#define.HPATH' include/config.h|awk '{print $3}'|tr -d \"`; +QPATH=`grep '#define.QPATH' include/config.h|awk '{print $3}'|tr -d \"`; SPATH=`dir_concat ${SPATH}`; CPATH=`dir_concat ${CPATH}`; @@ -55,6 +56,7 @@ LPATH=`dir_concat ${LPATH}`; PPATH=`dir_concat ${PPATH}`; HPATH=`dir_concat ${HPATH}`; +QPATH=`dir_concat ${QPATH}`; # DPATH = directory, # SPATH = server executable, @@ -63,6 +65,7 @@ # KPATH = kline conf file # leave KPATH undefined if you want klines in main conf file # HPATH is the opers help file, seen by opers on /quote help +# QPATH = quote file # Let's make sure $DPATH exists dir_make ${DPATH} @@ -122,6 +125,15 @@ echo previous opers.txt saved as opers.txt.old mv ${HPATH} ${HPATH}.old $INSTALL_SH -c opers.txt ${HPATH}; +fi + +# try to install their quote file unless it already exists. +dir_make `dirname ${QPATH}` +if [ ! -f ${QPATH} ]; then + echo installing ircd.quote as ${QPATH} + $INSTALL_SH -c ircd.quote ${QPATH}; +else + echo You already have a quote file in ${QPATH}.; fi # install mkpasswd