]> jfr.im git - solanum.git/blobdiff - modules/m_names.c
m_message: global snote when massnotice is used
[solanum.git] / modules / m_names.c
index c18ecf8d7c03341a3d60cac1c0d6dbfe8013a92e..bbebb8a45178858e1deb9b8a1cf2b28288f58b8a 100644 (file)
@@ -25,7 +25,6 @@
 #include "stdinc.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
 #include "hash.h"
 #include "match.h"
 #include "ircd.h"
 #include "msg.h"
 #include "parse.h"
 #include "modules.h"
+#include "s_newconf.h"
 
 static const char names_desc[] = "Provides the NAMES command to view users on a channel";
 
-static int m_names(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void m_names(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message names_msgtab = {
        "NAMES", 0, 0, 0, 0,
@@ -60,7 +60,7 @@ static void names_global(struct Client *source_p);
  * m_names
  *      parv[1] = channel
  */
-static int
+static void
 m_names(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        static time_t last_used = 0;
@@ -78,7 +78,7 @@ m_names(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                        sendto_one_numeric(source_p, ERR_BADCHANNAME,
                                           form_str(ERR_BADCHANNAME),
                                           (unsigned char *) p);
-                       return 0;
+                       return;
                }
 
                if((chptr = find_channel(p)) != NULL)
@@ -89,7 +89,7 @@ m_names(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        }
        else
        {
-               if(!IsOper(source_p))
+               if(!IsOperGeneral(source_p))
                {
                        if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
                        {
@@ -97,7 +97,7 @@ m_names(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                                           me.name, source_p->name, "NAMES");
                                sendto_one(source_p, form_str(RPL_ENDOFNAMES),
                                           me.name, source_p->name, "*");
-                               return 0;
+                               return;
                        }
                        else
                                last_used = rb_current_time();
@@ -107,8 +107,6 @@ m_names(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                sendto_one(source_p, form_str(RPL_ENDOFNAMES),
                           me.name, source_p->name, "*");
        }
-
-       return 0;
 }
 
 /*
@@ -124,7 +122,7 @@ names_global(struct Client *source_p)
        int mlen;
        int tlen;
        int cur_len;
-       int dont_show = NO;
+       bool dont_show = false;
        rb_dlink_node *lp, *ptr;
        struct Client *target_p;
        struct Channel *chptr = NULL;
@@ -146,7 +144,7 @@ names_global(struct Client *source_p)
        RB_DLINK_FOREACH(ptr, global_client_list.head)
        {
                target_p = ptr->data;
-               dont_show = NO;
+               dont_show = false;
 
                if(!IsPerson(target_p) || IsInvisible(target_p))
                        continue;
@@ -166,7 +164,7 @@ names_global(struct Client *source_p)
                        if(PubChannel(chptr) || IsMember(source_p, chptr) ||
                           SecretChannel(chptr))
                        {
-                               dont_show = YES;
+                               dont_show = true;
                                break;
                        }
                }
@@ -174,14 +172,31 @@ names_global(struct Client *source_p)
                if(dont_show)
                        continue;
 
-               if((cur_len + NICKLEN + 2) > (BUFSIZE - 3))
+               if (IsCapable(source_p, CLICAP_USERHOST_IN_NAMES))
                {
-                       sendto_one(source_p, "%s", buf);
-                       cur_len = mlen;
-                       t = buf + mlen;
+                       if (cur_len + strlen(target_p->name) + strlen(target_p->username) + strlen(target_p->host) + strlen(" !@") >= BUFSIZE - strlen("\r\n"))
+                       {
+                               *(t - 1) = '\0';
+                               sendto_one(source_p, "%s", buf);
+                               cur_len = mlen;
+                               t = buf + mlen;
+                       }
+
+                       tlen = sprintf(t, "%s!%s@%s ", target_p->name, target_p->username, target_p->host);
+               }
+               else
+               {
+                       if(cur_len + strlen(target_p->name) + strlen(" ") >= BUFSIZE - strlen("\r\n"))
+                       {
+                               *(t - 1) = '\0';
+                               sendto_one(source_p, "%s", buf);
+                               cur_len = mlen;
+                               t = buf + mlen;
+                       }
+
+                       tlen = sprintf(t, "%s ", target_p->name);
                }
 
-               tlen = sprintf(t, "%s ", target_p->name);
                cur_len += tlen;
                t += tlen;
        }