Beispiel #1
0
/* reject <from> <bot>
 */
static void bot_reject(int idx, char *par)
{
  char *from = NULL, *who = NULL, *destbot = NULL, *frombot = NULL;
  struct userrec *u = NULL;
  int i;

  from = newsplit(&par);
  frombot = strchr(from, '@');
  if (frombot)
    frombot++;
  else
    frombot = from;
  i = nextbot(frombot);
  if (i != idx) {
    fake_alert(idx, "direction", frombot, "reject");
    return;
  }
  who = newsplit(&par);
  if (!(destbot = strchr(who, '@'))) {
    /* Rejecting a bot */
    i = nextbot(who);
    if (i < 0) {
      botnet_send_priv(idx, conf.bot->nick, from, NULL, "Can't unlink %s (doesn't exist)", who);
    } else if (!strcasecmp(dcc[i].nick, who)) {
      char s[1024];

      /* I'm the connection to the rejected bot */
      putlog(LOG_BOTS, "*", "%s rejected %s", from, dcc[i].nick);
      dprintf(i, "bye %s\n", par[0] ? par : "rejected");
      simple_sprintf(s, "Disconnected %s (%s: %s)", dcc[i].nick, from, par[0] ? par : "rejected");
      chatout("*** %s\n", s);
      botnet_send_unlinked(i, dcc[i].nick, s);
      killsock(dcc[i].sock);
      lostdcc(i);
    } else {
      if (i >= 0)
        botnet_send_reject(i, from, NULL, who, NULL, par);
    }
  } else {                      /* Rejecting user */
    *destbot++ = 0;
    if (!strcasecmp(destbot, conf.bot->nick)) {
      /* Kick someone here! */
      int ok = 0;

      for (i = 0; i < dcc_total; i++) {
        if (dcc[i].type && dcc[i].simul == -1 && !strcasecmp(who, dcc[i].nick) && (dcc[i].type->flags & DCT_CHAT)) {
          u = get_user_by_handle(userlist, from);
          if (u) {
            if (!whois_access(u, dcc[idx].user)) {
              add_note(from, conf.bot->nick, "Sorry, you cannot boot them.", -1, 0);
              return;
            }
            do_boot(i, from, par);
            putlog(LOG_CMDS, "*", "#%s# boot %s (%s)", from, who, par[0] ? par : "No reason");
            ok = 1;
          }
        }
      }
    } else {
      i = nextbot(destbot);
      *--destbot = '@';
      if (i >= 0)
        botnet_send_reject(i, from, NULL, who, NULL, par);
    }
  }
}
Beispiel #2
0
static void cmd_chinfo(int idx, char *par)
{

  if (!use_info) {
    dprintf(idx, "Info storage is turned off.\n");
    return;
  }

  char *handle = newsplit(&par);

  if (!handle[0]) {
    dprintf(idx, "Usage: chinfo <handle> [channel] <new-info>\n");
    return;
  }

  struct userrec *u1 = get_user_by_handle(userlist, handle);

  if (!u1 || (u1 && !whois_access(dcc[idx].user, u1))) {
    dprintf(idx, "No such user.\n");
    return;
  }

  char *chname = NULL;

  if (par[0] && strchr(CHANMETA, par[0])) {
    chname = newsplit(&par);
    if (!findchan_by_dname(chname)) {
      dprintf(idx, "No such channel.\n");
      return;
    }
  } else
    chname = 0;
  if (u1->bot && !(dcc[idx].user->flags & USER_MASTER)) {
    dprintf(idx, "You have to be master to change bots info.\n");
    return;
  }
  if ((u1->flags & USER_OWNER) && !(dcc[idx].user->flags & USER_OWNER)) {
    dprintf(idx, "You can't change info for the bot owner.\n");
    return;
  }
  if (chname) {
    get_user_flagrec(dcc[idx].user, &user, chname);
    get_user_flagrec(u1, &victim, chname);
    if ((chan_owner(victim) || glob_owner(victim)) &&
	!(glob_owner(user) || chan_owner(user))) {
      dprintf(idx, "You can't change info for the channel owner.\n");
      return;
    }
  }
  putlog(LOG_CMDS, "*", "#%s# chinfo %s %s %s", dcc[idx].nick, handle, chname ? chname : par, chname ? par : "");
  if (!strcasecmp(par, "none"))
    par[0] = 0;
  if (chname) {
    set_handle_chaninfo(userlist, handle, chname, par);
    if (par[0] == '@')
      dprintf(idx, "New info (LOCKED) for %s on %s: %s\n", handle, chname,
	      &par[1]);
    else if (par[0])
      dprintf(idx, "New info for %s on %s: %s\n", handle, chname, par);
    else
      dprintf(idx, "Wiped info for %s on %s\n", handle, chname);

    if (conf.bot->hub)
      write_userfile(idx);
  } else {
    set_user(&USERENTRY_INFO, u1, par[0] ? par : NULL);
    if (par[0] == '@')
      dprintf(idx, "New default info (LOCKED) for %s: %s\n", handle, &par[1]);
    else if (par[0])
      dprintf(idx, "New default info for %s: %s\n", handle, par);
    else
      dprintf(idx, "Wiped default info for %s\n", handle);

    if (conf.bot->hub)
      write_userfile(idx);
  }
}