Author: Isomer <perry@coders.net>
[ircu2.10.12-pk.git] / ircd / m_motd.c
index 4a8354082f6fe55169dcf3d22a3c85d5b53ac094..966a8b6556680a3c626c7fca119c8bfae6358702 100644 (file)
 #include "numeric.h"
 #include "numnicks.h"
 #include "s_conf.h"
+#include "class.h"
 #include "s_user.h"
 #include "send.h"
 
+#include <stdlib.h>
 #include <assert.h>
 
 /*
@@ -123,6 +125,7 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct TRecord *ptr;
   int count;
   struct MotdItem *temp;
+  int class = get_client_class(sptr);
 
 #ifdef NODEFAULTMOTD
   int no_motd;
@@ -131,7 +134,7 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   {
     no_motd = 0;
 #endif
-    if (hunt_server_cmd(sptr, CMD_MODE, cptr, 0, "%C", 1, parc, parv) !=
+    if (hunt_server_cmd(sptr, CMD_MOTD, cptr, 0, "%C", 1, parc, parv) !=
        HUNTED_ISME)
       return 0;
 #ifdef NODEFAULTMOTD
@@ -142,30 +145,25 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     no_motd = 1;
   }
 #endif
-
-  /*
-   * Find out if this is a remote query or if we have a T line for our hostname
+  /* 2.10.11: Allow per Class T:'s
+   *    -- Isomer 2000-11-19
    */
-  if (IsServer(cptr))
-  {
-    tm = 0;                  /* Remote MOTD */
-    temp = rmotd;
-  }
-  else
+  for (ptr = tdata; ptr; ptr = ptr->next)
   {
-    for (ptr = tdata; ptr; ptr = ptr->next)
-    {
-      if (!match(ptr->hostmask, cptr->sockhost))
+    if (IsDigit(*ptr->hostmask)) {
+      if (atoi(ptr->hostmask)==class)
         break;
     }
-    if (ptr)
-    {
-      temp = ptr->tmotd;
-      tm = &ptr->tmotd_tm;
-    }
-    else
-      temp = motd;
+    else if (!match(ptr->hostmask, cptr->sockhost))
+      break;
+  }
+  if (ptr)
+  {
+    temp = ptr->tmotd;
+    tm = &ptr->tmotd_tm;
   }
+  else
+    temp = motd;
   if (temp == 0)
   {
     send_reply(sptr, ERR_NOMOTD);
@@ -178,7 +176,7 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     if (tm)                     /* Not remote? */
     {
       send_reply(sptr, RPL_MOTDSTART, me.name);
-      send_reply(sptr, SND_EXPLICIT | RPL_MOTD, "- %d/%d/%d %d:%02d",
+      send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":- %d/%d/%d %d:%02d",
                 tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, tm->tm_hour,
                 tm->tm_min);
       count = 100;