]> jfr.im git - solanum.git/blobdiff - extensions/m_findforwards.c
Note that messages caught in +g/+G are discarded
[solanum.git] / extensions / m_findforwards.c
index ff8efff45b954266acee395ff09a615ac407a7a6..cc04843313a77beaeeded0cf4047eca81ba2b5cc 100644 (file)
@@ -34,7 +34,9 @@
 #include "packet.h"
 #include "messages.h"
 
-static int m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
+static const char findfowards_desc[] = "Allows operators to find forwards to a given channel";
+
+static void m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
                        int parc, const char *parv[]);
 
 struct Message findforwards_msgtab = {
@@ -44,73 +46,60 @@ struct Message findforwards_msgtab = {
 
 mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL };
 
-static const char findfowards_desc = "Allows operators to find forwards to a given channel";
-
 DECLARE_MODULE_AV2(findforwards, NULL, NULL, findforwards_clist, NULL, NULL, NULL, NULL, findfowards_desc);
 
 /*
 ** mo_findforwards
 **      parv[1] = channel
 */
-static int
+static void
 m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        static time_t last_used = 0;
        struct Channel *chptr;
        struct membership *msptr;
        rb_dlink_node *ptr;
-       char buf[414];
-       char *p = buf, *end = buf + sizeof buf - 1;
-       *p = '\0';
 
        /* Allow ircops to search for forwards to nonexistent channels */
-       if(!IsOper(source_p))
+       if(!IsOperGeneral(source_p))
        {
                if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL)
                {
                        sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
                                        form_str(ERR_NOTONCHANNEL), parv[1]);
-                       return 0;
+                       return;
                }
 
                if(!is_chanop(msptr))
                {
                        sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
                                        me.name, source_p->name, parv[1]);
-                       return 0;
+                       return;
                }
 
                if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
                {
                        sendto_one(source_p, form_str(RPL_LOAD2HI),
                                        me.name, source_p->name, "FINDFORWARDS");
-                       return 0;
+                       return;
                }
                else
                        last_used = rb_current_time();
        }
 
+       send_multiline_init(source_p, " ", ":%s NOTICE %s :Forwards for %s: ",
+                       me.name,
+                       source_p->name,
+                       parv[1]);
+
        RB_DLINK_FOREACH(ptr, global_channel_list.head)
        {
                chptr = ptr->data;
                if(!irccmp(chptr->mode.forward, parv[1]))
                {
-                       if(p + strlen(chptr->chname) >= end - 13)
-                       {
-                               strcpy(p, "<truncated> ");
-                               p += 12;
-                               break;
-                       }
-                       strcpy(p, chptr->chname);
-                       p += strlen(chptr->chname);
-                       *p++ = ' ';
+                       send_multiline_item(source_p, "%s", chptr->chname);
                }
        }
 
-       if(buf[0])
-               *(--p) = '\0';
-
-       sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf);
-
-       return 0;
+       send_multiline_fini(source_p, NULL);
 }