#include "modules.h"
#include "packet.h"
#include "chmode.h"
+#include "ratelimit.h"
+#include "s_assert.h"
static int m_join(struct Client *, struct Client *, int, const char **);
static int ms_join(struct Client *, struct Client *, int, const char **);
static void do_join_0(struct Client *client_p, struct Client *source_p);
static int check_channel_name_loc(struct Client *source_p, const char *name);
+static void send_join_error(struct Client *source_p, int numeric, const char *name);
static void set_final_mode(struct Mode *mode, struct Mode *oldmode);
static void remove_our_modes(struct Channel *chptr, struct Client *source_p);
if(moduledata.approved != 0)
{
- sendto_one(source_p, form_str(moduledata.approved),
- me.name, source_p->name, name);
+ if(moduledata.approved != ERR_CUSTOM)
+ send_join_error(source_p,
+ moduledata.approved,
+ name);
continue;
}
* -- dwr
*/
if(i != ERR_CUSTOM)
- sendto_one(source_p, form_str(i), me.name, source_p->name, name);
-
+ send_join_error(source_p, i, name);
continue;
}
else if(chptr != chptr2)
}
chptr->join_count++;
+ /* credit user for join */
+ credit_client_join(source_p);
+
/* we send the user their join here, because we could have to
* send a mode out next.
*/
if(flags & CHFL_CHANOP)
{
chptr->channelts = rb_current_time();
- chptr->mode.mode |= MODE_TOPICLIMIT;
- chptr->mode.mode |= MODE_NOPRIVMSGS;
+ chptr->mode.mode |= ConfigChannel.autochanmodes;
modes = channel_modes(chptr, &me);
sendto_channel_local(ONLY_CHANOPS, chptr, ":%s MODE %s %s",
time_t newts;
int isnew;
int keep_our_modes = YES;
- int keep_new_modes = YES;
rb_dlink_node *ptr, *next_ptr;
/* special case for join 0 */
keep_our_modes = NO;
chptr->channelts = newts;
}
- else
- keep_new_modes = NO;
/* Lost the TS, other side wins, so remove modes on this side */
if(!keep_our_modes)
int fl;
int isnew;
int mlen_uid;
- int len_nick;
int len_uid;
int len;
int joins = 0;
static char empty[] = "";
rb_dlink_node *ptr, *next_ptr;
+ if(parc < 5)
+ return 0;
+
if(!IsChannelName(parv[2]) || !check_channel_name(parv[2]))
return 0;
if(isnew)
chptr->channelts = newts;
-
+
else if(newts == 0 || oldts == 0)
chptr->channelts = 0;
else if(newts == oldts)
mbuf = modebuf;
para[0] = para[1] = para[2] = para[3] = empty;
pargs = 0;
- len_nick = len_uid = 0;
+ len_uid = 0;
/* if theres a space, theres going to be more than one nick, change the
* first space to \0, so s is just the first nick, and point p to the
if(fl & CHFL_CHANOP)
{
*ptr_uid++ = '@';
- len_nick++;
len_uid++;
}
if(fl & CHFL_VOICE)
{
*ptr_uid++ = '+';
- len_nick++;
len_uid++;
}
}
return 1;
}
+/* send_join_error()
+ *
+ * input - client to send to, reason, channel name
+ * output - none
+ * side effects - error message sent to client
+ */
+static void
+send_join_error(struct Client *source_p, int numeric, const char *name)
+{
+ /* This stuff is necessary because the form_str macro only
+ * accepts constants.
+ */
+ switch (numeric)
+ {
+#define NORMAL_NUMERIC(i) \
+ case i: \
+ sendto_one(source_p, form_str(i), \
+ me.name, source_p->name, name); \
+ break
+
+ NORMAL_NUMERIC(ERR_BANNEDFROMCHAN);
+ NORMAL_NUMERIC(ERR_INVITEONLYCHAN);
+ NORMAL_NUMERIC(ERR_BADCHANNELKEY);
+ NORMAL_NUMERIC(ERR_CHANNELISFULL);
+ NORMAL_NUMERIC(ERR_NEEDREGGEDNICK);
+ NORMAL_NUMERIC(ERR_THROTTLE);
+
+ default:
+ sendto_one_numeric(source_p, numeric,
+ "%s :Cannot join channel", name);
+ break;
+ }
+}
+
static void
set_final_mode(struct Mode *mode, struct Mode *oldmode)
{
* remove_our_modes
*
* inputs -
- * output -
- * side effects -
+ * output -
+ * side effects -
*/
static void
remove_our_modes(struct Channel *chptr, struct Client *source_p)
banptr = ptr->data;
/* trailing space, and the mode letter itself */
- plen = strlen(banptr->banstr) + 2;
+ plen = strlen(banptr->banstr) +
+ (banptr->forward ? strlen(banptr->forward) + 1 : 0) + 2;
if(count >= MAXMODEPARAMS || (cur_len + plen) > BUFSIZE - 4)
{
*mbuf++ = c;
cur_len += plen;
- pbuf += rb_sprintf(pbuf, "%s ", banptr->banstr);
+ if (banptr->forward)
+ pbuf += rb_sprintf(pbuf, "%s$%s ", banptr->banstr, banptr->forward);
+ else
+ pbuf += rb_sprintf(pbuf, "%s ", banptr->banstr);
count++;
free_ban(banptr);