]> jfr.im git - solanum.git/blobdiff - modules/m_knock.c
msg: remove last vestiges of the fakelag system. charybdis has never supported fakelag.
[solanum.git] / modules / m_knock.c
index 2c786e09e7ae83d497948de28f213c5142980d97..86d325158a86f415f4a09d9809612f922364024c 100644 (file)
@@ -27,7 +27,7 @@
 #include "channel.h"
 #include "client.h"
 #include "hash.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "send.h"
 #include "parse.h"
 #include "modules.h"
 #include "s_serv.h"
+#include "supported.h"
 
-static int m_knock(struct Client *, struct Client *, int, const char **);
+static int 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}}
 };
 
+static int
+_modinit(void)
+{
+       add_isupport("KNOCK", isupport_boolean, &ConfigChannel.use_knock);
+       return 0;
+}
+
+static void
+_moddeinit(void)
+{
+       delete_isupport("KNOCK");
+}
+
 mapi_clist_av1 knock_clist[] = { &knock_msgtab, NULL };
-DECLARE_MODULE_AV1(knock, NULL, NULL, knock_clist, NULL, NULL, "$Revision: 3570 $");
+DECLARE_MODULE_AV1(knock, _modinit, _moddeinit, knock_clist, NULL, NULL, "$Revision: 3570 $");
 
 /* m_knock
- *    parv[0] = sender prefix
  *    parv[1] = channel
  *
  *  The KNOCK command has the following syntax:
@@ -62,7 +75,7 @@ DECLARE_MODULE_AV1(knock, NULL, NULL, knock_clist, NULL, NULL, "$Revision: 3570
  *  <anonymous>
  */
 static int
-m_knock(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_knock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        struct Channel *chptr;
        char *p, *name;
@@ -80,13 +93,6 @@ m_knock(struct Client *client_p, struct Client *source_p, int parc, const char *
        if((p = strchr(name, ',')))
                *p = '\0';
 
-       if(!IsChannelName(name))
-       {
-               sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
-                                  form_str(ERR_NOSUCHCHANNEL), name);
-               return 0;
-       }
-
        if((chptr = find_channel(name)) == NULL)
        {
                sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
@@ -102,8 +108,8 @@ m_knock(struct Client *client_p, struct Client *source_p, int parc, const char *
                return 0;
        }
 
-       if(!((chptr->mode.mode & MODE_INVITEONLY) || (*chptr->mode.key) || 
-            (chptr->mode.limit && 
+       if(!((chptr->mode.mode & MODE_INVITEONLY) || (*chptr->mode.key) ||
+            (chptr->mode.limit &&
              rb_dlink_list_length(&chptr->members) >= (unsigned long)chptr->mode.limit)))
        {
                sendto_one_numeric(source_p, ERR_CHANOPEN,
@@ -119,12 +125,12 @@ m_knock(struct Client *client_p, struct Client *source_p, int parc, const char *
                return 0;
        }
 
-       
+
        if(MyClient(source_p))
        {
                /* don't allow a knock if the user is banned */
-               if(is_banned(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN ||
-                               is_quieted(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN)
+               if(is_banned(chptr, source_p, NULL, NULL, NULL, NULL) == CHFL_BAN ||
+                       is_quieted(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN)
                {
                        sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,
                                           form_str(ERR_CANNOTSENDTOCHAN), name);
@@ -135,7 +141,7 @@ m_knock(struct Client *client_p, struct Client *source_p, int parc, const char *
                 * allow one knock per user per knock_delay
                 * allow one knock per channel per knock_delay_channel
                 */
-               if(!IsOper(source_p) && 
+               if(!IsOper(source_p) &&
                   (source_p->localClient->last_knock + ConfigChannel.knock_delay) > rb_current_time())
                {
                        sendto_one(source_p, form_str(ERR_TOOMANYKNOCK),