]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/channel.c
Start moving parts of join to channels.c so they can be used in more places.
[irc/rqf/shadowircd.git] / src / channel.c
index e3e2c060b4f3f827ad0732c784453cf48bb3591a..61332aa21430b91cda8504066e1706695c2abe68 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "stdinc.h"
 #include "channel.h"
+#include "chmode.h"
 #include "client.h"
 #include "common.h"
 #include "hash.h"
@@ -917,19 +918,14 @@ check_spambot_warning(struct Client *source_p, const char *name)
                        source_p->localClient->oper_warn_count_down--;
                else
                        source_p->localClient->oper_warn_count_down = 0;
-               if(source_p->localClient->oper_warn_count_down == 0)
+               if(source_p->localClient->oper_warn_count_down == 0 &&
+                               name != NULL)
                {
                        /* Its already known as a possible spambot */
-                       if(name != NULL)
-                               sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
-                                                    "User %s (%s@%s) trying to join %s is a possible spambot",
-                                                    source_p->name,
-                                                    source_p->username, source_p->orighost, name);
-                       else
-                               sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
-                                                    "User %s (%s@%s) is a possible spambot",
-                                                    source_p->name,
-                                                    source_p->username, source_p->orighost);
+                       sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
+                                            "User %s (%s@%s) trying to join %s is a possible spambot",
+                                            source_p->name,
+                                            source_p->username, source_p->orighost, name);
                        source_p->localClient->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
                }
        }
@@ -940,7 +936,9 @@ check_spambot_warning(struct Client *source_p, const char *name)
                   JOIN_LEAVE_COUNT_EXPIRE_TIME)
                {
                        decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
-                       if(decrement_count > source_p->localClient->join_leave_count)
+                       if(name != NULL)
+                               ;
+                       else if(decrement_count > source_p->localClient->join_leave_count)
                                source_p->localClient->join_leave_count = 0;
                        else
                                source_p->localClient->join_leave_count -= decrement_count;
@@ -1359,3 +1357,42 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                        sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
        }
 }
+
+/* Check what we will forward to, without sending any notices to the user
+ * -- jilles
+ */
+struct Channel *
+check_forward(struct Client *source_p, struct Channel *chptr,
+               char *key)
+{
+       int depth = 0, i;
+
+       /* User is +Q */
+       if (IsNoForward(source_p))
+               return NULL;
+
+       while (depth < 16)
+       {
+               chptr = find_channel(chptr->mode.forward);
+               /* Can only forward to existing channels */
+               if (chptr == NULL)
+                       return NULL;
+               /* Already on there, show original error message */
+               if (IsMember(source_p, chptr))
+                       return NULL;
+               /* Juped. Sending a warning notice would be unfair */
+               if (hash_find_resv(chptr->chname))
+                       return NULL;
+               /* Don't forward to +Q channel */
+               if (chptr->mode.mode & MODE_DISFORWARD)
+                       return NULL;
+               i = can_join(source_p, chptr, key);
+               if (i == 0)
+                       return chptr;
+               if (i != ERR_INVITEONLYCHAN && i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_CHANNELISFULL)
+                       return NULL;
+               depth++;
+       }
+
+       return NULL;
+}