Ejemplo n.º 1
0
int
chk_voice(struct flag_record fr, struct chanset_t *chan)
{
  if (!chan || (!privchan(fr, chan, PRIV_VOICE) && !chk_devoice(fr))) {
    if (chan_voice(fr) || (glob_voice(fr) && !chan_quiet(fr)))
      return 1;
  }
  return 0;
}
Ejemplo n.º 2
0
int
chk_autoop(struct flag_record fr, struct chanset_t *chan)
{
  if (glob_bot(fr))
    return 0;
  if (!chan || (!channel_take(chan) && !privchan(fr, chan, PRIV_OP) && chk_op(fr, chan) && !chk_deop(fr, chan))) {
    if (channel_autoop(chan) || chan_autoop(fr) || glob_autoop(fr))
      return 1;
  }
  return 0;
}
Ejemplo n.º 3
0
static void cmd_mns_chrec(int idx, char *par)
{
  char *nick = NULL, *chn = NULL;
  struct userrec *u1 = NULL;
  struct chanuserrec *chanrec = NULL;

  if (!par[0]) {
    dprintf(idx, "Usage: -chrec <user> [channel]\n");
    return;
  }
  nick = newsplit(&par);
  u1 = get_user_by_handle(userlist, nick);
  if (!u1) {
    dprintf(idx, "No such user.\n");
    return;
  }
  if (!par[0]) {
    struct chanset_t *chan;

    chan = findchan_by_dname(dcc[idx].u.chat->con_chan);
    if (chan)
      chn = chan->dname;
    else {
      dprintf(idx, "Invalid console channel.\n");
      return;
    }
  } else
    chn = newsplit(&par);
  get_user_flagrec(dcc[idx].user, &user, chn);
  get_user_flagrec(u1, &victim, chn);
  if (privchan(user, findchan_by_dname(chn), PRIV_OP)) {
    dprintf(idx, "No such channel.\n");
    return;
  }
  if ((!glob_master(user) && !chan_master(user)) ||  /* drummer */
      (chan_owner(victim) && !chan_owner(user) && !glob_owner(user)) ||
      (glob_owner(victim) && !glob_owner(user))) {
    dprintf(idx, "You have no permission to do that.\n");
    return;
  }
  chanrec = get_chanrec(u1, chn);
  if (!chanrec) {
    dprintf(idx, "User %s doesn't have a channel record for %s.\n", nick, chn);
    return;
  }
  putlog(LOG_CMDS, "*", "#%s# -chrec %s %s", dcc[idx].nick, nick, chn);
  del_chanrec(u1, chn);
  dprintf(idx, "Removed %s channel record from %s.\n", chn, nick);
  if (conf.bot->hub)
    write_userfile(idx);
}
Ejemplo n.º 4
0
int
real_chk_op(struct flag_record fr, struct chanset_t *chan, bool botbitch)
{
  if (!chan && glob_op(fr))
    return 1;
  else if (!chan)
    return 0;

  if (!privchan(fr, chan, PRIV_OP) && !real_chk_deop(fr, chan, botbitch)) {
    if (chan_op(fr) || (glob_op(fr) && !chan_deop(fr)))
      return 1;
  }
  return 0;
}
Ejemplo n.º 5
0
void channels_report(int idx, int details)
{
  int i;
  char s[1024] = "", s2[100] = "";
  struct flag_record fr = {FR_CHAN | FR_GLOBAL, 0, 0, 0 };

  for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
    if (idx != DP_STDOUT)
      get_user_flagrec(dcc[idx].user, &fr, chan->dname, chan);
    if (!privchan(fr, chan, PRIV_OP) && ((idx == DP_STDOUT) || glob_master(fr) || chan_master(fr))) {

      s[0] = 0;

      if (chan_bitch(chan))
	strlcat(s, "bitch, ", sizeof(s));
      if (s[0])
	s[strlen(s) - 2] = 0;
      if (!s[0])
	strlcpy(s, "lurking", sizeof(s));
      get_mode_protect(chan, s2, sizeof(s2));
      if (channel_closed(chan)) {
        if (chan->closed_invite)
          strlcat(s2, "i", sizeof(s2));
        if (chan->closed_private)
          strlcat(s2, "p", sizeof(s2));
      }

      if (shouldjoin(chan)) {
	if (channel_active(chan)) {
	  /* If it's a !chan, we want to display it's unique name too <cybah> */
	  if (chan->dname[0]=='!') {
	    dprintf(idx, "    %-20s: %2d member%s enforcing \"%s\" (%s), "
	            "unique name %s\n", chan->dname, chan->channel.members,
	            (chan->channel.members==1) ? "," : "s,", s2, s, chan->name);
	  } else {
	    dprintf(idx, "    %-20s: %2d member%s enforcing \"%s\" (%s)\n",
	            chan->dname, chan->channel.members,
	            chan->channel.members == 1 ? "," : "s,", s2, s);
	  }
	} else {
          if (!conf.bot->hub)
            dprintf(idx, "    %-20s: (%s), enforcing \"%s\"  (%s)\n", chan->dname,
		  channel_pending(chan) ? "pending" : "not on channel", s2, s);
          else
            dprintf(idx, "    %-20s: (%s), enforcing \"%s\"  (%s)\n", chan->dname,
		  "limbo", s2, s);
	}
      } else {
	dprintf(idx, "    %-20s: channel is set +inactive\n",
		chan->dname);
      }
      if (details) {
	s[0] = 0;
	i = 0;
	i += my_strcpy(s + i, "dynamic ");
	if (channel_enforcebans(chan))
	  i += my_strcpy(s + i, "enforcebans ");
	if (channel_dynamicbans(chan))
	  i += my_strcpy(s + i, "dynamicbans ");
	if (!channel_nouserbans(chan))
	  i += my_strcpy(s + i, "userbans ");
	if (channel_bitch(chan))
	  i += my_strcpy(s + i, "bitch ");
/*
	if (channel_revenge(chan))
	  i += my_strcpy(s + i, "revenge ");
	if (channel_revenge(chan))
	  i += my_strcpy(s + i, "revengebot ");
*/
	if (channel_secret(chan))
	  i += my_strcpy(s + i, "secret ");
	if (channel_cycle(chan))
	  i += my_strcpy(s + i, "cycle ");
	if (channel_dynamicexempts(chan))
	  i += my_strcpy(s + i, "dynamicexempts ");
	if (!channel_nouserexempts(chan))
	  i += my_strcpy(s + i, "userexempts ");
	if (channel_dynamicinvites(chan))
	  i += my_strcpy(s + i, "dynamicinvites ");
	if (!channel_nouserinvites(chan))
	  i += my_strcpy(s + i, "userinvites ");
	if (!shouldjoin(chan))
	  i += my_strcpy(s + i, "inactive ");
	if (channel_nodesynch(chan))
	  i += my_strcpy(s + i, "nodesynch ");
        if (channel_closed(chan))
          i += my_strcpy(s + i, "closed ");
        if (HAVE_TAKE && channel_take(chan))
          i += my_strcpy(s + i, "take ");
        if (channel_voice(chan))
          i += my_strcpy(s + i, "voice ");
        if (channel_autoop(chan))
          i += my_strcpy(s + i, "autoop ");
        if (channel_meankicks(chan))
          i += my_strcpy(s + i, "meankicks ");
        if (channel_rbl(chan))
          i += my_strcpy(s + i, "rbl ");
        if (channel_voicebitch(chan))
          i += my_strcpy(s + i, "voicebitch ");
        if (channel_protect(chan))
          i += my_strcpy(s + i, "protect ");
/* Chanflag template
 *	if (channel_temp(chan))
 *	  i += my_strcpy(s + i, "temp ");
*/
        if (channel_nomassjoin(chan))
          i += my_strcpy(s + i, "nomassjoin ");
        if (channel_botbitch(chan))
          i += my_strcpy(s + i, "botbitch ");
        if (channel_backup(chan))
          i += my_strcpy(s + i, "backup ");
        if (channel_fastop(chan))
          i += my_strcpy(s + i, "fastop ");
        if (channel_privchan(chan))
          i += my_strcpy(s + i, "private ");

	dprintf(idx, "      Options: %s\n", s);
        if (chan->limitraise)
          dprintf(idx, "      Raising limit +%d every 2 minutes\n", chan->limitraise);
/*
        if (chan->revenge_mode)
          dprintf(idx, "      revenge-mode %d\n",
                  chan->revenge_mode);
*/
       dprintf(idx, "    Bans last %d mins.\n", chan->ban_time);
       dprintf(idx, "    Exemptions last %d mins.\n", chan->exempt_time);
       dprintf(idx, "    Invitations last %d mins.\n", chan->invite_time);
      }
    }
  }
}
Ejemplo n.º 6
0
static void cmd_stick_yn(int idx, char *par, int yn)
{
  int i = 0, j;
  struct chanset_t *chan = NULL;
  char *stick_type = NULL, s[UHOSTLEN] = "", chname[81] = "", type = 0, *str_type = NULL;
  maskrec *channel_list = NULL;

  stick_type = newsplit(&par);
  strlcpy(s, newsplit(&par), sizeof s);
  strlcpy(chname, newsplit(&par), sizeof chname);
  if (strcasecmp(stick_type, "exempt") &&
      strcasecmp(stick_type, "invite") &&
      strcasecmp(stick_type, "ban")) {
    strlcpy(chname, s, sizeof chname);
    strlcpy(s, stick_type, sizeof s);
    stick_type = "ban";
  }
  if (!s[0]) {
    dprintf(idx, "Usage: %sstick [ban/exempt/invite] <hostmask or number> [channel]\n", yn ? "" : "un");
    return;
  }
  /* Now deal with exemptions */
  if (!strcasecmp(stick_type, "exempt")) {
    type = 'e';
    str_type = "exempt";
  } else if (!strcasecmp(stick_type, "invite")) {
    type = 'I';
    str_type = "invite";
  } else if (!strcasecmp(stick_type, "ban")) {
    type = 'b';
    str_type = "ban";
  } else
    return;

  if (!chname[0]) {
    channel_list = (type == 'b' ? global_bans : type == 'e' ? global_exempts : global_invites);

    i = u_setsticky_mask(NULL, channel_list, s, (dcc[idx].user->flags & USER_MASTER) ? yn : -1, type);
    if (i > 0) {
      putlog(LOG_CMDS, "*", "#%s# %sstick %s %s", dcc[idx].nick, yn ? "" : "un", str_type, s);
      dprintf(idx, "%stuck %s: %s\n", yn ? "S" : "Uns", str_type, s);

      if (!conf.bot->hub) {
        struct chanset_t *achan = NULL;

        for (achan = chanset; achan != NULL; achan = achan->next)
          check_this_mask(type, achan, s, yn);
      } else
        write_userfile(idx);

      return;
    }
    strlcpy(chname, dcc[idx].u.chat->con_chan, sizeof chname);
  }
  /* Channel-specific mask? */
  if (!(chan = findchan_by_dname(chname))) {
    dprintf(idx, "No such channel.\n");
    return;
  }
  get_user_flagrec(dcc[idx].user, &user, chan->dname);
  if (privchan(user, chan, PRIV_OP)) {
    dprintf(idx, "No such channel.\n");
    return;
  }

  channel_list = (type == 'b' ? chan->bans : type == 'e' ? chan->exempts : chan->invites);

  if (str_isdigit(s)) {
    /* substract the numer of global masks to get the number of the channel masks */
    j = atoi(s);
    j -= count_mask(type == 'b' ? global_bans : type == 'e' ? global_exempts : global_invites);
    simple_snprintf(s, sizeof s, "%d", j);
  }

  j = u_setsticky_mask(chan, channel_list, s, yn, type);
  if (j > 0) {
    putlog(LOG_CMDS, "*", "#%s# %sstick %s %s %s", dcc[idx].nick, yn ? "" : "un", str_type, s, chname);
    dprintf(idx, "%stuck %s %s: %s\n", yn ? "S" : "Uns", chname, str_type, s);
    if (!conf.bot->hub)
      check_this_mask(type, chan, s, yn);
    else
      write_userfile(idx);

    return;
  }
  dprintf(idx, "No such %s.\n", str_type);
}
Ejemplo n.º 7
0
static void cmd_pls_mask(const char type, int idx, char *par)
{
  const char *cmd = (type == 'b' ? "ban" : type == 'e' ? "exempt" : "invite");

  if (!par[0]) {
usage:
    dprintf(idx, "Usage: +%s <hostmask> [channel] [%%<XdXhXm>] [reason]\n", cmd);
    return;
  }

  char *chname = NULL, *who = NULL, s[UHOSTLEN] = "", s1[UHOSTLEN] = "", *p = NULL, *p_expire = NULL;
  unsigned long int expire_time = 0, expire_foo;
  int sticky = 0;
  struct chanset_t *chan = NULL;

  who = newsplit(&par);
  if (par[0] && strchr(CHANMETA, par[0]))
    chname = newsplit(&par);

  /* Did they mix up the two params? */
  if (!chname && strchr(CHANMETA, who[0])) {
    if (par[0]) {
      chname = who;
      who = newsplit(&par);
    } else {
      goto usage;
    }
  }

  if (chname || !(dcc[idx].user->flags & USER_MASTER)) {
    if (!chname)
      chname = dcc[idx].u.chat->con_chan;
    get_user_flagrec(dcc[idx].user, &user, chname);
    chan = findchan_by_dname(chname);
    /* *shrug* ??? (guppy:10Feb1999) */
    if (!chan || (chan && privchan(user, chan, PRIV_OP))) {
      dprintf(idx, "No such channel.\n");
      return;
    } else if (!chk_op(user, chan)) {
      dprintf(idx, "You don't have access to set %ss on %s.\n", cmd, chname);
      return;
    }
  } else
    chan = 0;
  /* Added by Q and Solal -- Requested by Arty2, special thanx :) */
  if (par[0] == '%') {
    p = newsplit(&par);
    p_expire = p + 1;
    while (*(++p) != 0) {
      switch (tolower(*p)) {
	case 'd':
	  *p = 0;
	  expire_foo = strtol(p_expire, NULL, 10);
	  if (expire_foo > 365)
	    expire_foo = 365;
	  expire_time += 86400 * expire_foo;
	  p_expire = p + 1;
	  break;
	case 'h':
	  *p = 0;
	  expire_foo = strtol(p_expire, NULL, 10);
	  if (expire_foo > 8760)
	    expire_foo = 8760;
	  expire_time += 3600 * expire_foo;
	  p_expire = p + 1;
	  break;
	case 'm':
	  *p = 0;
	  expire_foo = strtol(p_expire, NULL, 10);
	  if (expire_foo > 525600)
	    expire_foo = 525600;
	  expire_time += 60 * expire_foo;
	  p_expire = p + 1;
	}
    }
  }
  if (!par[0])
    par = "requested";
  else if (strlen(par) > MASKREASON_MAX)
    par[MASKREASON_MAX] = 0;
  if (strlen(who) > UHOSTMAX - 4)
    who[UHOSTMAX - 4] = 0;
  /* Fix missing ! or @ BEFORE checking against myself */
  if (!strchr(who, '!')) {
    if (!strchr(who, '@'))
      simple_snprintf(s, sizeof s, "%s!*@*", who);	/* Lame nick ban */
    else
      simple_snprintf(s, sizeof s, "*!%s", who);
  } else if (!strchr(who, '@'))
    simple_snprintf(s, sizeof s, "%s@*", who);	/* brain-dead? */
  else
    strlcpy(s, who, sizeof s);
    if (conf.bot->hub)
      simple_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, conf.bot->net.host);
    else
      simple_snprintf(s1, sizeof s1, "%s!%s", botname, botuserhost);
  if (type == 'b' && s1[0] && wild_match(s, s1)) {
    dprintf(idx, "I'm not going to ban myself.\n");
    putlog(LOG_CMDS, "*", "#%s# attempted +ban %s", dcc[idx].nick, s);
    return;
  }
  /* IRC can't understand bans longer than 70 characters */
  if (strlen(s) > 70) {
    s[69] = '*';
    s[70] = 0;
  }
  if (chan) {
    u_addmask(type, chan, s, dcc[idx].nick, par, expire_time ? now + expire_time : 0, 0);
    if (par[0] == '*') {
      sticky = 1;
      par++;
      putlog(LOG_CMDS, "*", "#%s# (%s) +%s %s %s (%s) (sticky)", dcc[idx].nick, dcc[idx].u.chat->con_chan, cmd, s, chan->dname, par);
      dprintf(idx, "New %s sticky %s: %s (%s)\n", chan->dname, cmd, s, par);
    } else {
      putlog(LOG_CMDS, "*", "#%s# (%s) +%s %s %s (%s)", dcc[idx].nick, dcc[idx].u.chat->con_chan, cmd, s, chan->dname, par);
      dprintf(idx, "New %s %s: %s (%s)\n", chan->dname, cmd, s, par);
    }
    if (!conf.bot->hub) {
      if (type == 'e' || type == 'I')
        add_mode(chan, '+', type, s);
      /* Avoid unnesessary modes if you got +dynamicbans
       */
      else
        check_this_ban(chan, s, sticky);
    } else
      write_userfile(idx);
  } else {
    u_addmask(type, NULL, s, dcc[idx].nick, par, expire_time ? now + expire_time : 0, 0);
    if (par[0] == '*') {
      sticky = 1;
      par++;
      putlog(LOG_CMDS, "*", "#%s# (GLOBAL) +%s %s (%s) (sticky)", dcc[idx].nick, cmd, s, par);
      dprintf(idx, "New sticky %s: %s (%s)\n", cmd, s, par);
    } else {
      putlog(LOG_CMDS, "*", "#%s# (GLOBAL) +%s %s (%s)", dcc[idx].nick, cmd, s, par);
      dprintf(idx, "New %s: %s (%s)\n", cmd, s, par);
    }
    if (!conf.bot->hub) {
      for (chan = chanset; chan != NULL; chan = chan->next) {
        if (type == 'b')
          check_this_ban(chan, s, sticky);
        else
          add_mode(chan, '+', type, s);
      }
    } else
      write_userfile(idx);
  }
}
Ejemplo n.º 8
0
static void cmd_mns_mask(const char type, int idx, char *par)
{
  const char *cmd = (type == 'b' ? "ban" : type == 'e' ? "exempt" : "invite");

  if (!par[0]) {
usage:
    dprintf(idx, "Usage: -%s <hostmask> [channel]\n", cmd);
    return;
  }

  int i = 0, j;
  struct chanset_t *chan = NULL;
  char s[UHOSTLEN] = "", *who = NULL, *chname = NULL, *mask = NULL;
  masklist *m = NULL;

  who = newsplit(&par);
  if (par[0] && strchr(CHANMETA, par[0]))
    chname = newsplit(&par);

  /* Did they mix up the two params? */
  if (!chname && strchr(CHANMETA, who[0])) {
    if (par[0]) {
      chname = who;
      who = newsplit(&par);
    } else {
      goto usage;
    }
  }

  if (!chname)
    chname = dcc[idx].u.chat->con_chan;

  if (chname || !(dcc[idx].user->flags & USER_MASTER)) {
    if (!chname)
      chname = dcc[idx].u.chat->con_chan;
    get_user_flagrec(dcc[idx].user, &user, chname);

    if (strchr(CHANMETA, chname[0]) && privchan(user, findchan_by_dname(chname), PRIV_OP)) {
      dprintf(idx, "No such channel.\n");
      return;
    }
    if (!chk_op(user, findchan_by_dname(chname)))
      return;
  }
  strlcpy(s, who, sizeof s);
  i = u_delmask(type, NULL, s, (dcc[idx].user->flags & USER_MASTER));
  if (i > 0) {
    if (lastdeletedmask)
      mask = lastdeletedmask;
    else
      mask = s;
    putlog(LOG_CMDS, "*", "#%s# -%s %s", dcc[idx].nick, cmd, mask);
    dprintf(idx, "%s %s: %s\n", "Removed", cmd, s);
    if (!conf.bot->hub) {
      for (chan = chanset; chan != NULL; chan = chan->next)
        add_mode(chan, '-', type, mask);
    } else
      write_userfile(idx);
    return;
  }
  /* Channel-specific ban? */
  if (chname)
    chan = findchan_by_dname(chname);
  if (chan) {
    m = type == 'b' ? chan->channel.ban : type == 'e' ? chan->channel.exempt : chan->channel.invite;
    if (str_isdigit(who) && (i = atoi(who)) > 0) {
      simple_snprintf(s, sizeof s, "%d", i);
      j = u_delmask(type, chan, s, 1);
      if (j > 0) {
        if (lastdeletedmask)
          mask = lastdeletedmask;
        else
          mask = s;
	putlog(LOG_CMDS, "*", "#%s# (%s) -%s %s", dcc[idx].nick, chan->dname, cmd, mask);
	dprintf(idx, "Removed %s channel %s: %s\n", chan->dname, cmd, mask);
        if (!conf.bot->hub)
          add_mode(chan, '-', type, mask);
        else
          write_userfile(idx);
	return;
      }
      i = 0;
      for (; m && m->mask && m->mask[0]; m = m->next) {
	if ((!u_equals_mask(type == 'b' ? global_bans : type == 'e' ? global_exempts :
	      global_invites, m->mask)) &&
	    (!u_equals_mask(type == 'b' ? chan->bans : type == 'e' ? chan->exempts :
	      chan->invites, m->mask))) {
	  i++;
	  if (i == -j) {
	    dprintf(idx, "%s %s '%s' on %s.\n", "Removed", cmd, m->mask, chan->dname);
	    putlog(LOG_CMDS, "*", "#%s# (%s) -%s %s [on channel]", dcc[idx].nick, chan->dname, cmd, who);

            if (!conf.bot->hub)
              add_mode(chan, '-', type, m->mask);
            else
              write_userfile(idx);
	    return;
	  }
	}
      }
    } else {
      j = u_delmask(type, chan, who, 1);
      if (j > 0) {
	putlog(LOG_CMDS, "*", "#%s# (%s) -%s %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, cmd, who);
	dprintf(idx, "Removed %s channel %s: %s\n", chname, cmd, who);
        if (!conf.bot->hub)
          add_mode(chan, '-', type, who);
        else
          write_userfile(idx);
	return;
      }
      for (; m && m->mask && m->mask[0]; m = m->next) {
	if (!rfc_casecmp(m->mask, who)) {
	  dprintf(idx, "%s %s '%s' on %s.\n", "Removed", cmd, m->mask, chan->dname);
	  putlog(LOG_CMDS, "*", "#%s# (%s) -%s %s [on channel]", dcc[idx].nick, chan->dname, cmd, who);
          if (!conf.bot->hub)
            add_mode(chan, '-', type, m->mask);
          else
            write_userfile(idx);
	  return;
	}
      }
    }
  }
  dprintf(idx, "No such %s.\n", cmd);
}
Ejemplo n.º 9
0
static void cmd_chanset(int idx, char *par)
{
  char *chname = NULL, result[RESULT_LEN] = "";
  struct chanset_t *chan = NULL;
  int all = 0;

  if (!par[0]) {
    putlog(LOG_CMDS, "*", "#%s# chanset %s", dcc[idx].nick, par);
    dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA);
    return;
  }

  // Determine channel name
  if (strchr(CHANMETA, par[0]) || !strncasecmp(par, "default", 7) || !strncmp(par, "*", 1))
    chname = newsplit(&par);
  else {
    if (strncmp(dcc[idx].u.chat->con_chan, "*", 1) && !(chan = findchan_by_dname(chname = dcc[idx].u.chat->con_chan))) {
      dprintf(idx, "Invalid console channel.\n");
      return;
    }
    chname = dcc[idx].u.chat->con_chan;
  }

  if (chname && chname[0]) {
    if (!strncmp(chname, "*", 1)) {
      all = 1;
      get_user_flagrec(dcc[idx].user, &user, chanset ? chanset->dname : "");
      if (!glob_owner(user)) {
        dprintf(idx, "You need to be a global owner to use '%schanset *'.\n", (dcc[idx].u.chat->channel >= 0) ? settings.dcc_prefix : "");
        return;
      }
    } else if (!strcasecmp(chname, "default")) {
      chan = chanset_default;
    } else
      chan = findchan_by_dname(chname);
  }

  if (!all && !chan && chname && chname[0]) {
    dprintf(idx, "No such channel.\n");
    return;
  }

  if (!par[0]) {
    dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA);
    return;
  }

  if (!all) {
    get_user_flagrec(dcc[idx].user, &user, chan->dname);

    if (privchan(user, chan, PRIV_OP)) {
      dprintf(idx, "No such channel.\n");
      return;
    }

    if (!glob_master(user) && !chan_master(user)) {
      dprintf(idx, "You don't have access to %s. \n", chan->dname);
      return;
    } else if ((strstr(par, "+private") || strstr(par, "-private")) && (!glob_owner(user))) {
      dprintf(idx, "You don't have access to set +/-private on %s (halting command).\n", chan->dname);
      return;
    } else if ((strstr(par, "+backup") || strstr(par, "-backup")) && (!glob_owner(user))) {
      dprintf(idx, "You don't have access to set +/-backup on %s (halting command).\n", chan->dname);
      return;
    } else if ((strstr(par, "+inactive") || strstr(par, "-inactive")) && (!glob_owner(user))) {
      dprintf(idx, "You don't have access to set +/-inactive on %s (halting command).\n", chan->dname);
      return;
    }
  }

  putlog(LOG_CMDS, "*", "#%s# chanset (%s) %s", dcc[idx].nick, all ? "*" : chan->dname, par);
  
  if (do_chanset(result, all ? NULL : chan, par, DO_LOCAL | DO_NET | CMD) == ERROR) {
    dprintf(idx, "Error trying to set { %s } on %s: %s\n", par, all ? "all channels" : chan->dname, result);
    return;
  }

  if (all)
    dprintf(idx, "Successfully set modes { %s } on all channels (Including the default).\n", par);
  else
    dprintf(idx, "Successfully set modes { %s } on %s\n", par, chan->dname);

  if (conf.bot->hub)
    write_userfile(idx);
}
Ejemplo n.º 10
0
static void cmd_chaninfo(int idx, char *par)
{
  char *chname = NULL, work[512] = "";
  struct chanset_t *chan = NULL;
  int cnt = 0;

  if (!par[0]) {
    chname = dcc[idx].u.chat->con_chan;
    if (chname[0] == '*') {
      dprintf(idx, "Your console channel is invalid.\n");
      return;
    }
  } else {
    chname = newsplit(&par);
    get_user_flagrec(dcc[idx].user, &user, chname);
    if (!glob_master(user) && !chan_master(user)) {
      dprintf(idx, "You don't have access to %s.\n", chname);
      return;
    }
  }
  if (!strcasecmp(chname, "default"))
    chan = chanset_default;
  else
    chan = findchan_by_dname(chname);
  if (!chan || (chan && privchan(user, chan, PRIV_OP))) {
    dprintf(idx, "No such channel.\n");
    return;
  } else {
    char nick[HANDLEN + 1] = "", date[81] = "";
    int deflag = 0;

    if (chan->added_ts) {
      strftime(date, sizeof date, "%c %Z", gmtime(&(chan->added_ts)));
    } else
      date[0] = 0;
    if (chan->added_by && chan->added_by[0])
      strlcpy(nick, chan->added_by, sizeof(nick));
    else
      nick[0] = 0;
    putlog(LOG_CMDS, "*", "#%s# chaninfo %s", dcc[idx].nick, chname);
    if (nick[0] && date[0])
      dprintf(idx, "Settings for channel %s (Added %s by %s%s%s):\n", chan->dname, date, BOLD(idx), nick, BOLD_END(idx));
    else
      dprintf(idx, "Settings for channel %s:\n", chan->dname);
/* FIXME: SHOW_CHAR() here */
    get_mode_protect(chan, work, sizeof(work));
    dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None");
    dprintf(idx, "Groups: %s\n", chan->groups && chan->groups->length() ? static_cast<bd::String>(chan->groups->join(" ")).c_str() : "None");
    dprintf(idx, "FiSH Key: %s\n", chan->fish_key[0] ? chan->fish_key : "not set");
//    dprintf(idx, "Protect topic (topic)   : %s\n", chan->topic[0] ? chan->topic : "");
/* Chanchar template
 *  dprintf(idx, "String temp: %s\n", chan->temp[0] ? chan->temp : "NULL");
 */
    dprintf(idx, "Channel flags:\n");
    work[0] = 0;
    SHOW_FLAG("autoop",		channel_autoop(chan));
    SHOW_FLAG("backup",		channel_backup(chan));
    SHOW_FLAG("bitch",		channel_bitch(chan));
    SHOW_FLAG("botbitch",       channel_botbitch(chan));
    SHOW_FLAG("closed",		channel_closed(chan));
    SHOW_FLAG("cycle",		channel_cycle(chan));
    SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));
    SHOW_FLAG("fastop",		channel_fastop(chan));
    SHOW_FLAG("floodban", channel_floodban(chan));
    SHOW_FLAG("inactive",	channel_inactive(chan));
    SHOW_FLAG("nodesynch",	channel_nodesynch(chan));
    SHOW_FLAG("private",	channel_privchan(chan));
    SHOW_FLAG("protect",	channel_protect(chan));
    SHOW_FLAG("rbl",		channel_rbl(chan));
    if (HAVE_TAKE)
      SHOW_FLAG("take",		channel_take(chan));
    SHOW_FLAG("voice",		channel_voice(chan));
    SHOW_FLAG("voicebitch",		channel_voicebitch(chan));
    SHOW_FLAG("", 0);
    SHOW_FLAG("dynamicbans",	channel_dynamicbans(chan));
    SHOW_FLAG("userbans",	!channel_nouserbans(chan));
    SHOW_FLAG("dynamicexempts",	channel_dynamicexempts(chan));
    SHOW_FLAG("userexempts",	!channel_nouserexempts(chan));
    SHOW_FLAG("dynamicinvites",	channel_dynamicinvites(chan));
    SHOW_FLAG("userinvites",	!channel_nouserinvites(chan));
    SHOW_FLAG("", 0);
    work[0] = 0;

/* Chanflag template
 *  SHOW_FLAG("template", channel_template(chan));
 * also include %ctemp in dprintf.
 */

    work[0] = cnt = 0;
/* Chanint template
 * SHOW_INT("Desc: ", integer, "YES", "NO");
 */
    dprintf(idx, "Channel settings:\n");
    deflag = chan->bad_cookie;
    SHOW_INT("Auto-delay: ", chan->auto_delay, NULL, "None");
    SHOW_INT("Bad-cookie:" , chan->bad_cookie, DEFLAG_STR, "Ignore");
    SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever");
    SHOW_INT("Ban-type: ", chan->ban_type, NULL, "3");
    SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!");
    SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
    SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
    SHOW_INT("Closed-Exempt:", chan->closed_exempt_mode, F_STR(chan->closed_exempt_mode), "None");
    SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
    SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None");
    SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't");
    SHOW_INT("Caps-Limit(%): ", chan->capslimit, NULL, "None");
    SHOW_INT("Color-Limit: ", chan->colorlimit, NULL, "None");
    SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever");
    SHOW_INT("Knock: ", chan->knock_flags, F_STR(chan->knock_flags), "None");
    SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled");
    deflag = chan->manop;
    SHOW_INT("Manop: ", chan->manop, DEFLAG_STR, "Ignore");
    deflag = chan->mdop;
    SHOW_INT("Mdop: ", chan->mdop, DEFLAG_STR, "Ignore");
    deflag = chan->mop;
    SHOW_INT("Mop: ", chan->mop, DEFLAG_STR, "Ignore");
    deflag = chan->revenge;
    SHOW_INT("Revenge: ", chan->revenge, DEFLAG_STR, "Ignore");
    SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!");
    SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!");
    SHOW_INT("Voice-moderate:", chan->voice_moderate, "Do!", "Don't!");

    dprintf(idx, "Flood settings:   chan bytes ctcp join kick deop nick mjoin mpub mbytes mctcp\n");
    dprintf(idx, "  number:          %3d  %4d  %3d  %3d  %3d  %3d  %3d   %3d  %3d   %4d   %3d\n",
	    chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr,
	    chan->flood_join_thr, chan->flood_kick_thr,
	    chan->flood_deop_thr, chan->flood_nick_thr,
            chan->flood_mjoin_thr, chan->flood_mpub_thr,
            chan->flood_mbytes_thr, chan->flood_mctcp_thr);
    dprintf(idx, "  time  :          %3u  %4u  %3u  %3u  %3u  %3u  %3u   %3u  %3u   %4u  %4u\n",
	    chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time,
	    chan->flood_join_time, chan->flood_kick_time,
	    chan->flood_deop_time, chan->flood_nick_time,
            chan->flood_mjoin_time, chan->flood_mpub_time,
            chan->flood_mbytes_time, chan->flood_mctcp_time);
  }
}