]> jfr.im git - solanum.git/blobdiff - modules/m_whowas.c
Merge branch 'isupport-charset' of github.com:grawity/charybdis
[solanum.git] / modules / m_whowas.c
index 5ad67dfd3132642b29fd1c09aaa9b10c4fbf05fc..c0f10b66a708801a099fe49322868bc2013fb33c 100644 (file)
@@ -45,7 +45,7 @@ static int m_whowas(struct Client *, struct Client *, int, const char **);
 
 struct Message whowas_msgtab = {
        "WHOWAS", 0, 0, 0, MFLG_SLOW,
-       {mg_unreg, {m_whowas, 2}, mg_ignore, mg_ignore, mg_ignore, {m_whowas, 2}}
+       {mg_unreg, {m_whowas, 2}, {m_whowas, 4}, mg_ignore, mg_ignore, {m_whowas, 2}}
 };
 
 mapi_clist_av1 whowas_clist[] = { &whowas_msgtab, NULL };
@@ -53,7 +53,6 @@ DECLARE_MODULE_AV1(whowas, NULL, NULL, whowas_clist, NULL, NULL, "$Revision: 171
 
 /*
 ** m_whowas
-**      parv[0] = sender prefix
 **      parv[1] = nickname queried
 */
 static int
@@ -65,12 +64,15 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char
        char *p;
        const char *nick;
        char tbuf[26];
+       long sendq_limit;
 
        static time_t last_used = 0L;
 
-       if(!IsOper(source_p))
+       if(MyClient(source_p) && !IsOper(source_p))
        {
-               if((last_used + ConfigFileEntry.pace_wait_simple) > rb_current_time())
+               if(last_used + (parc > 3 ? ConfigFileEntry.pace_wait :
+                                               ConfigFileEntry.pace_wait_simple
+                               ) > rb_current_time())
                {
                        sendto_one(source_p, form_str(RPL_LOAD2HI),
                                   me.name, source_p->name, "WHOWAS");
@@ -86,23 +88,32 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char
        if(parc > 2)
                max = atoi(parv[2]);
 
-#if 0
        if(parc > 3)
                if(hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
                        return 0;
-#endif
+
+       if(!MyClient(source_p) && (max <= 0 || max > 20))
+               max = 20;
 
        if((p = strchr(parv[1], ',')))
                *p = '\0';
 
        nick = parv[1];
 
+       sendq_limit = get_sendq(client_p) * 9 / 10;
+
        temp = WHOWASHASH[hash_whowas_name(nick)];
        found = 0;
        for (; temp; temp = temp->next)
        {
                if(!irccmp(nick, temp->name))
                {
+                       if(cur > 0 && rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit)
+                       {
+                               sendto_one(source_p, form_str(ERR_TOOMANYMATCHES),
+                                          me.name, source_p->name, "WHOWAS");
+                               break;
+                       }
                        sendto_one(source_p, form_str(RPL_WHOWASUSER),
                                   me.name, source_p->name, temp->name,
                                   temp->username, temp->hostname, temp->realname);
@@ -116,6 +127,10 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char
                                                   form_str(RPL_WHOISACTUALLY),
                                                   temp->name, temp->sockhost);
 #endif
+                       if (!EmptyString(temp->suser))
+                               sendto_one_numeric(source_p, RPL_WHOISLOGGEDIN,
+                                                  "%s %s :was logged in as",
+                                                  temp->name, temp->suser);
                        sendto_one_numeric(source_p, RPL_WHOISSERVER,
                                           form_str(RPL_WHOISSERVER),
                                           temp->name, temp->servername,