Пример #1
0
void send_remote_simul(int idx, char *bot, char *cmd, char *par)
{
  char msg[SGRAB - 110] = "";

  simple_snprintf(msg, sizeof msg, "r-s %d %s %d %s %lu %s %s", idx, dcc[idx].nick, dcc[idx].u.chat->con_flags, 
               dcc[idx].u.chat->con_chan, dcc[idx].status, cmd, par);
  putbot(bot, msg);
}
Пример #2
0
static void rebalance_roles()
{
  struct bot_addr *ba = NULL;
  int r[5] = { 0, 0, 0, 0, 0 };
  unsigned int hNdx, lNdx, i;
  char tmp[10] = "";

  for (i = 0; i < (unsigned) dcc_total; i++) {
    if (dcc[i].type && dcc[i].user && dcc[i].user->bot && bot_hublevel(dcc[i].user) == 999) {
      ba = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, dcc[i].user);
      if (ba && (ba->roleid > 0) && (ba->roleid < 5))
        r[(ba->roleid - 1)]++;
    }
  }
  /*
     Find high & low
     while (high-low) > 2
     move from highNdx to lowNdx
   */

  hNdx = 0;
  lNdx = 0;
  for (i = 1; i <= 4; i++) {
    if (r[i] < r[lNdx])
      lNdx = i;
    if (r[i] > r[hNdx])
      hNdx = i;
  }
  while (r[hNdx] - r[lNdx] >= 2) {
    for (i = 0; i < (unsigned) dcc_total; i++) {
      if (dcc[i].type && dcc[i].user && dcc[i].user->bot && bot_hublevel(dcc[i].user) == 999) {
        ba = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, dcc[i].user);
        if (ba && (ba->roleid == (hNdx + 1))) {
          ba->roleid = lNdx + 1;
          simple_snprintf(tmp, sizeof(tmp), "rl %d", lNdx + 1);
          putbot(dcc[i].nick, tmp);
        }
      }
    }
    r[hNdx]--;
    r[lNdx]++;
    hNdx = 0;
    lNdx = 0;
    for (i = 1; i <= 4; i++) {
      if (r[i] < r[lNdx])
        lNdx = i;
      if (r[i] > r[hNdx])
        hNdx = i;
    }
  }
}
Пример #3
0
void bounce_simul(int idx, char *buf)
{
  char rmsg[SGRAB - 110] = "";

  if (!buf || !buf[0] || !dcc[idx].simulbot || !dcc[idx].simulbot[0] || idx < 0)
    return;

  /* Truncate out the newline that was put in from the dprintf() */
  char *p = strchr(buf, '\n');
  if (p)
    *p = 0;

  simple_snprintf(rmsg, sizeof rmsg, "r-sr %d %s %s", dcc[idx].simul, dcc[idx].user->handle, buf);          /* remote-simul[r]eturn idx buf */
  putbot(dcc[idx].simulbot, rmsg);
}
Пример #4
0
static void mns_chan(int idx, char *par, char *bot)
{
  char *chname = NULL, buf2[1024] = "";
  struct chanset_t *chan = NULL;
  int i;

  if (!bot)
    putlog(LOG_CMDS, "*", "#%s# -chan %s", dcc[idx].nick, par);

  if (!par[0]) {
    dprintf(idx, "Usage: -chan [%s]<channel>\n", CHANMETA);
    return;
  }
  chname = newsplit(&par);

  simple_snprintf(buf2, sizeof(buf2), "cpart %s %s", chname, bot ? bot : "*");
  if (bot)		/* bot will just set it +inactive */
    putbot(bot, buf2);
  else
    putallbots(buf2);

  chan = findchan_by_dname(chname);
  if (!chan) {
    if ((chan = findchan(chname)))
      dprintf(idx, "That channel exists with a short name of %s, use that.\n", chan->dname);
    else
      dprintf(idx, "That channel doesn't exist!\n");
    return;
  }

  if (!bot) {
    for (i = 0; i < dcc_total; i++) {
      if (dcc[i].type && (dcc[i].type->flags & DCT_CHAT) && 
          !rfc_casecmp(dcc[i].u.chat->con_chan, chan->dname)) {
        dprintf(i, "%s is no longer a valid channel, changing your console to '*'\n", chname);
        strlcpy(dcc[i].u.chat->con_chan, "*", 2);
        console_dostore(i, 0);
      }
    }
    remove_channel(chan);
    if (conf.bot->hub)
      write_userfile(idx);
    dprintf(idx, "Channel %s removed from the botnet.\n", chname);
    dprintf(idx, "This includes any channel specific bans, invites, exemptions and user records that you set.\n");
  } else
    dprintf(idx, "Channel %s removed from the bot: %s\n", chname, bot);
}
Пример #5
0
static void cmd_slowpart(int idx, char *par)
{
  int intvl = 0, delay = 0, count = 1;
  char *chname = NULL, *p = NULL;
  struct chanset_t *chan = NULL;
  tand_t *bot = NULL;

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

  if (conf.bot->hub)
    count = 0;

  for (bot = tandbot; bot; bot = bot->next) {
    char tmp[100] = "";

    tmp[0] = 0;
    if (bot->u) {
      if (bot_hublevel(bot->u) < 999) {		/* HUB */
        simple_snprintf(tmp, sizeof(tmp), "sp %s 0", chname);
      } else {					/* LEAF */
        struct flag_record fr = { FR_CHAN|FR_GLOBAL|FR_BOT, 0, 0, 0 };
        get_user_flagrec(bot->u, &fr, chname);
	/* Only send the 'sp' command if the bot is supposed to be in the channel (backups and such) */
        if (bot_shouldjoin(bot->u, &fr, chan)) {
          /* Variation: 60 secs intvl should be 60 +/- 15 */
          int v = (random() % (intvl / 2)) - (intvl / 4);
          delay += intvl;
          simple_snprintf(tmp, sizeof(tmp), "sp %s %i", chname, delay + v);
          count++;
        }
      }
      if (tmp[0])
        putbot(bot->bot, tmp);
    }  
  }

  remove_channel(chan);
  if (conf.bot->hub)
    write_userfile(-1);
  dprintf(idx, "Channel %s removed from the bot.\n", chname);
  dprintf(idx, "This includes any channel specific bans, invites, exemptions and user records that you set.\n");

  if (findchan_by_dname(chname)) {
    dprintf(idx, "Failed to remove channel.\n");
    return;
  }

  dprintf(idx, "%i bots parting %s during the next %i seconds\n", count, chname, delay);
  if (!conf.bot->hub)
    dprintf(DP_MODE, "PART %s\n", chname);
}
Пример #6
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);
}