void	make_join(t_env *e, int cs, char *line)
{
	if (ft_strlen(line) < 26 && ft_strlen(line) > 2)
	{
		if (e->users[cs]->chan == NULL)
			join_chan(e, cs, line);
		else
			send(cs, "You can't join a chanel when you are already in one.\0", 53, 0);
	}
	else
		send(cs, "Wrong name : 3 characters min, 25 characters max.\0", 50, 0);
}
Exemple #2
0
static void got_jn(int idx, char *code, char *par)
{
  char *chname = newsplit(&par);

  if (!chname || !chname[0]) 
    return;

  struct chanset_t *chan = NULL;

  if (!(chan = findchan_by_dname(chname))) return;
  if (chan->channel.jointime && channel_inactive(chan)) {
    chan->status &= ~CHAN_INACTIVE;
    chan->channel.jointime = 0;
    if (!conf.bot->hub && shouldjoin(chan))
      join_chan(chan);
  }
}
Exemple #3
0
static int
check_slowjoinpart(struct chanset_t *chan)
{
  /* slowpart */
  if (chan->channel.parttime && (chan->channel.parttime < now)) {
    chan->channel.parttime = 0;
    dprintf(DP_MODE, "PART %s\n", chan->name);
    if (chan) /* this should NOT be necesary, but some unforseen bug requires it.. */
      remove_channel(chan);
    return 1;		/* if we keep looping, we'll segfault. */
  /* slowjoin */
  } else if ((chan->channel.jointime) && (chan->channel.jointime < now)) {
      chan->status &= ~CHAN_INACTIVE;
      chan->channel.jointime = 0;
    if (shouldjoin(chan))
      join_chan(chan);
  } else if (channel_closed(chan)) {
    enforce_closed(chan);
  }
  return 0;
}
Exemple #4
0
static void cmd_slowjoin(int idx, char *par)
{
  int intvl = 0, delay = 0, count = 0;
  char *chname = NULL, *p = NULL, buf[2048] = "", buf2[RESULT_LEN] = "";
  struct chanset_t *chan = NULL;
  tand_t *bot = NULL;

  /* slowjoin #chan 60 */
  putlog(LOG_CMDS, "*", "#%s# slowjoin %s", dcc[idx].nick, par);
  chname = newsplit(&par);
  p = newsplit(&par);
  intvl = atoi(p);
  if (!chname[0] || !p[0]) {
    dprintf(idx, "Usage: slowjoin <channel> <interval-seconds> [channel options]\n");
    return;
  }
  if (intvl < 10) {
    dprintf(idx, "Interval must be at least 10 seconds\n");
    return;
  }
  if ((chan = findchan_by_dname(chname))) {
    dprintf(idx, "Already on %s\n", chan->dname);
    return;
  }
  if (!strchr(CHANMETA, chname[0])) {
    dprintf(idx, "Invalid channel name\n");
    return;
  }

  simple_snprintf(buf, sizeof(buf), "+inactive addedby %s addedts %li ", dcc[idx].nick, (long)now);

  if (par[0])
    strlcat(buf, par, sizeof(buf));
  if (channel_add(buf2, chname, buf) == ERROR) {
    dprintf(idx, "Invalid channel or channel options.\n");
    if (buf2[0])
      dprintf(idx, " %s\n", buf2);
    return;
  }
  buf2[0] = 0;

  chan = findchan_by_dname(chname);
  if (!chan) {
    dprintf(idx, "Hmmm... Channel didn't get added. Weird *shrug*\n");
    return;
  }
  simple_snprintf(buf2, sizeof(buf2), "cjoin %s %s", chan->dname, buf);
  putallbots(buf2);
  if (conf.bot->hub)
    count = 0;

  chan->status &= ~CHAN_INACTIVE;

  for (bot = tandbot; bot; bot = bot->next) {
    char tmp[100] = "";
    tmp[0] = 0;    
    if (bot->u) {
      if (bot_hublevel(bot->u) < 999) {
	simple_snprintf(tmp, sizeof(tmp), "sj %s 0", chname);
      } else {
        struct flag_record fr = { FR_CHAN|FR_GLOBAL|FR_BOT, 0, 0, 0 };

        get_user_flagrec(bot->u, &fr, chname);
	/* Only send the 'sj' command if the bot is supposed to be in the channel (backups and such) */
        if (bot_shouldjoin(bot->u, &fr, chan, 1)) {
          /* Variation: 60 secs intvl should be 60 +/- 15 */
          int v = (random() % (intvl / 2)) - (intvl / 4);

          delay += intvl;
          simple_snprintf(tmp, sizeof(tmp), "sj %s %i", chname, delay + v);
          count++;
        }
      }
      if (tmp[0])
        putbot(bot->bot, tmp);
    }
  }

  if (!conf.bot->hub && shouldjoin(chan))
    count++;

  dprintf(idx, "%i bots joining %s during the next %i seconds\n", count, chan->dname, delay);

  if (!conf.bot->hub && shouldjoin(chan))
    join_chan(chan);
}