]> jfr.im git - solanum.git/blobdiff - modules/m_knock.c
Mint CLICAP_FLAGS_PRIORITY
[solanum.git] / modules / m_knock.c
index 7b124fb3d6390875a7b80ec0846a8cf5dd9abe9f..29cc3e5f578b34b427191ee16ebc1571b5b1e4d5 100644 (file)
@@ -19,8 +19,6 @@
  *  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_knock.c 3570 2007-09-09 19:19:23Z jilles $
  */
 
 #include "stdinc.h"
 #include "modules.h"
 #include "s_serv.h"
 #include "supported.h"
+#include "s_newconf.h"
+
+static const char knock_desc[] = "Provides the KNOCK command to ask for an invite to an invite-only channel";
 
-static int m_knock(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void m_knock(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message knock_msgtab = {
-       "KNOCK", 0, 0, 0, MFLG_SLOW,
+       "KNOCK", 0, 0, 0, 0,
        {mg_unreg, {m_knock, 2}, {m_knock, 2}, mg_ignore, mg_ignore, {m_knock, 2}}
 };
 
@@ -59,7 +60,8 @@ _moddeinit(void)
 }
 
 mapi_clist_av1 knock_clist[] = { &knock_msgtab, NULL };
-DECLARE_MODULE_AV1(knock, _modinit, _moddeinit, knock_clist, NULL, NULL, "$Revision: 3570 $");
+
+DECLARE_MODULE_AV2(knock, _modinit, _moddeinit, knock_clist, NULL, NULL, NULL, NULL, knock_desc);
 
 /* m_knock
  *    parv[1] = channel
@@ -74,7 +76,7 @@ DECLARE_MODULE_AV1(knock, _modinit, _moddeinit, knock_clist, NULL, NULL, "$Revis
  *  of these conditions.  Concept by Dianora <db@db.net> and written by
  *  <anonymous>
  */
-static int
+static void
 m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        struct Channel *chptr;
@@ -84,7 +86,7 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        {
                sendto_one(source_p, form_str(ERR_KNOCKDISABLED),
                           me.name, source_p->name);
-               return 0;
+               return;
        }
 
        name = LOCAL_COPY(parv[1]);
@@ -97,7 +99,7 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        {
                sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
                                   form_str(ERR_NOSUCHCHANNEL), name);
-               return 0;
+               return;
        }
 
        if(IsMember(source_p, chptr))
@@ -105,7 +107,7 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                if(MyClient(source_p))
                        sendto_one(source_p, form_str(ERR_KNOCKONCHAN),
                                   me.name, source_p->name, name);
-               return 0;
+               return;
        }
 
        if(!((chptr->mode.mode & MODE_INVITEONLY) || (*chptr->mode.key) ||
@@ -114,7 +116,7 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        {
                sendto_one_numeric(source_p, ERR_CHANOPEN,
                                   form_str(ERR_CHANOPEN), name);
-               return 0;
+               return;
        }
 
        /* cant knock to a +p channel */
@@ -122,37 +124,37 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        {
                sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,
                                   form_str(ERR_CANNOTSENDTOCHAN), name);
-               return 0;
+               return;
        }
 
 
        if(MyClient(source_p))
        {
                /* don't allow a knock if the user is banned */
-               if(is_banned(chptr, source_p, NULL, NULL, NULL, NULL) == CHFL_BAN ||
-                       is_quieted(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN)
+               if(is_banned(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN ||
+                       is_quieted(chptr, source_p, NULL, NULL) == CHFL_BAN)
                {
                        sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,
                                           form_str(ERR_CANNOTSENDTOCHAN), name);
-                       return 0;
+                       return;
                }
 
                /* local flood protection:
                 * allow one knock per user per knock_delay
                 * allow one knock per channel per knock_delay_channel
                 */
-               if(!IsOper(source_p) &&
+               if(!IsOperGeneral(source_p) &&
                   (source_p->localClient->last_knock + ConfigChannel.knock_delay) > rb_current_time())
                {
                        sendto_one(source_p, form_str(ERR_TOOMANYKNOCK),
                                        me.name, source_p->name, name, "user");
-                       return 0;
+                       return;
                }
                else if((chptr->last_knock + ConfigChannel.knock_delay_channel) > rb_current_time())
                {
                        sendto_one(source_p, form_str(ERR_TOOMANYKNOCK),
                                        me.name, source_p->name, name, "channel");
-                       return 0;
+                       return;
                }
 
                /* ok, we actually can send the knock, tell client */
@@ -165,7 +167,7 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        chptr->last_knock = rb_current_time();
 
        if(ConfigChannel.use_knock)
-               sendto_channel_local(chptr->mode.mode & MODE_FREEINVITE ? ALL_MEMBERS : ONLY_CHANOPS,
+               sendto_channel_local(source_p, (chptr->mode.mode & MODE_FREEINVITE) ? ALL_MEMBERS : ONLY_CHANOPS,
                                     chptr, form_str(RPL_KNOCK),
                                     me.name, name, name, source_p->name,
                                     source_p->username, source_p->host);
@@ -174,6 +176,5 @@ m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                      ":%s KNOCK %s", use_id(source_p), name);
        sendto_server(client_p, chptr, CAP_KNOCK, CAP_TS6,
                      ":%s KNOCK %s", source_p->name, name);
-       return 0;
 }