]> jfr.im git - solanum.git/blobdiff - modules/m_motd.c
make VERSION not include sid (#118)
[solanum.git] / modules / m_motd.c
index 802b4071e5bfb096a312c812cc383abbc543359b..f71ea801ce796a787154e1f890050760fd7ea67d 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: m_motd.c 254 2005-09-21 23:35:12Z nenolod $
  */
 
 #include "stdinc.h"
 #include "client.h"
-#include "tools.h"
 #include "ircd.h"
 #include "send.h"
 #include "numeric.h"
 #include "modules.h"
 #include "s_conf.h"
 #include "cache.h"
+#include "ratelimit.h"
+
+static const char motd_desc[] = "Provides the MOTD command to view the Message of the Day";
 
-static int m_motd(struct Client *, struct Client *, int, const char **);
-static int mo_motd(struct Client *, struct Client *, int, const char **);
+static void m_motd(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void mo_motd(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message motd_msgtab = {
-       "MOTD", 0, 0, 0, MFLG_SLOW,
+       "MOTD", 0, 0, 0, 0,
        {mg_unreg, {m_motd, 0}, {mo_motd, 0}, mg_ignore, mg_ignore, {mo_motd, 0}}
 };
 
@@ -54,56 +54,51 @@ mapi_hlist_av1 motd_hlist[] = {
        { NULL, NULL }
 };
 
-DECLARE_MODULE_AV1(motd, NULL, NULL, motd_clist, motd_hlist, NULL, "$Revision: 254 $");
+DECLARE_MODULE_AV2(motd, NULL, NULL, motd_clist, motd_hlist, NULL, NULL, NULL, motd_desc);
 
 static void motd_spy(struct Client *);
 
 /*
 ** m_motd
-**      parv[0] = sender prefix
 **      parv[1] = servername
 */
-static int
-m_motd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+m_motd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        static time_t last_used = 0;
 
-       if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
-       {
+       if (parc < 2) {
+               /* do nothing */
+       } else if ((last_used + ConfigFileEntry.pace_wait) > rb_current_time() || !ratelimit_client(source_p, 6)) {
                /* safe enough to give this on a local connect only */
                sendto_one(source_p, form_str(RPL_LOAD2HI),
                           me.name, source_p->name, "MOTD");
                sendto_one(source_p, form_str(RPL_ENDOFMOTD),
                           me.name, source_p->name);
-               return 0;
+               return;
+       } else {
+               last_used = rb_current_time();
        }
-       else
-               last_used = CurrentTime;
 
        if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
-               return 0;
+               return;
 
        motd_spy(source_p);
        send_user_motd(source_p);
-
-       return 0;
 }
 
 /*
 ** mo_motd
-**      parv[0] = sender prefix
 **      parv[1] = servername
 */
-static int
-mo_motd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+mo_motd(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME)
-               return 0;
+               return;
 
        motd_spy(source_p);
        send_user_motd(source_p);
-
-       return 0;
 }
 
 /* motd_spy()