Пример #1
0
static void cmd_down(int idx, char *par)
{
  char *chname = NULL, buf2[201] = "";
  struct chanset_t *chan = NULL;

  putlog(LOG_CMDS, "*", "#%s# down %s", dcc[idx].nick, par);

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

  chname = newsplit(&par);
  chan = findchan_by_dname(chname);
  if (!chan) {
    dprintf(idx, "%s is not a valid channel.\n", chname);
    return;
  }
  
  simple_snprintf(buf2, sizeof(buf2), "down %s", chan->dname);
  putallbots(buf2);
  if (!conf.bot->hub) {
    add_mode(chan, '-', 'o', botname);
    chan->channel.no_op = (now + 10);
  }
}
Пример #2
0
static void cmd_cycle(int idx, char *par)
{
  char *chname = NULL;
  int delay = 10;
  struct chanset_t *chan = NULL;

  putlog(LOG_CMDS, "*", "#%s# cycle %s", dcc[idx].nick, par);

  if (!par[0]) {
    dprintf(idx, "Usage: cycle [%s]<channel> [delay]\n", CHANMETA);
    dprintf(idx, "rejoin delay defaults to '10'\n");
    return;
  }

  chname = newsplit(&par);
  chan = findchan_by_dname(chname);
  if (!chan) {
    dprintf(idx, "%s is not a valid channel.\n", chname);
    return;
  }
  if (par[0])
    delay = atoi(newsplit(&par));

  if (conf.bot->hub) {
    char buf2[201] = "";

    simple_snprintf(buf2, sizeof(buf2), "cycle %s %d", chname, delay); /* this just makes the bot PART */
    putallbots(buf2);
  } else {
    do_chanset(NULL, chan, "+inactive", DO_LOCAL);
    dprintf(DP_SERVER, "PART %s\n", chan->name);
    chan->channel.jointime = ((now + delay) - server_lag);
  }
  dprintf(idx, "Cycling %s for %d seconds.\n", chan->dname, delay);
}
Пример #3
0
static void pls_chan(int idx, char *par, char *bot)
{
  char *chname = NULL, result[RESULT_LEN] = "", buf[2048] = "";
  struct chanset_t *chan = NULL;

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

  if (!par[0]) {
    dprintf(idx, "Usage: +chan [%s]<channel> [options]\n", CHANMETA);
    return;
  }

  chname = newsplit(&par);
  simple_snprintf(buf, sizeof(buf), "cjoin %s %s", chname, bot ? bot : "*");		/* +chan makes all bots join */
  if (par[0]) {
    strlcat(buf, " ", sizeof(buf));
    strlcat(buf, par, sizeof(buf));
    strlcat(buf, " ", sizeof(buf));
  }
    
  if (!bot && findchan_by_dname(chname)) {
    dprintf(idx, "That channel already exists!\n");
    return;
  } else if ((chan = findchan(chname)) && !bot) {
    dprintf(idx, "That channel already exists as %s!\n", chan->dname);
    return;
  } else if (strchr(CHANMETA, chname[0]) == NULL) {
    dprintf(idx, "Invalid channel prefix.\n");
    return;
  } else if (strchr(chname, ',') != NULL) {
    dprintf(idx, "Invalid channel name.\n");
    return;
  }
  if (!chan && !findchan_by_dname(chname) && channel_add(result, chname, par) == ERROR) {
    dprintf(idx, "Invalid channel or channel options.\n");
    if (result[0])
      dprintf(idx, " %s\n", result);
  } else {
    if ((chan = findchan_by_dname(chname))) {
      char tmp[51] = "";

      simple_snprintf(tmp, sizeof(tmp), "addedby %s addedts %li", dcc[idx].nick, (long) now);
      if (buf[0]) {
        strlcat(buf, " ", sizeof(buf));
        strlcat(buf, tmp, sizeof(buf));
      }
      do_chanset(NULL, chan, buf[0] ? buf : tmp, DO_LOCAL);
      if (!bot) {
        dprintf(idx, "Channel %s added to the botnet.\n", chname);
      } else {
        dprintf(idx, "Channel %s added to the bot: %s\n", chname, bot);
      }
      putallbots(buf);
    }
    if (conf.bot->hub)
      write_userfile(-1);
  }
}
Пример #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
/* do_chanset() set (options) on (chan)
 * USES DO_LOCAL|DO_NET bits.
 */
int do_chanset(char *result, struct chanset_t *chan, const char *options, int flags)
{
  int ret = OK;

  if (flags & DO_NET) {
    size_t bufsiz = 0;
         /* malloc(options,chan,'cset ',' ',+ 1) */
    if (chan)
      bufsiz = strlen(options) + strlen(chan->dname) + 5 + 1 + 1;
    else
      bufsiz = strlen(options) + 1 + 5 + 1 + 1;
    
    char *buf = (char*) my_calloc(1, bufsiz);

    strlcat(buf, "cset ", bufsiz);
    if (chan)
      strlcat(buf, chan->dname, bufsiz);
    else
      strlcat(buf, "*", bufsiz);
    strlcat(buf, " ", bufsiz);
    strlcat(buf, options, bufsiz);
    putlog(LOG_DEBUG, "*", "sending out cset: %s", buf);
    putallbots(buf); 
    free(buf);
  }

  if (flags & DO_LOCAL) {
    bool cmd = (flags & CMD);
    struct chanset_t *ch = NULL;
    int all = chan ? 0 : 1;

    if (chan)
      ch = chan;
    else
      ch = chanset_default; //First iteration changes default, then move on to all chans

    while (ch) {
      const char **item = NULL;
      int items = 0;

      if (SplitList(result, options, &items, &item) == OK) {
        ret = channel_modify(result, ch, items, (char **) item, cmd);
      } else 
        ret = ERROR;


      free(item);

      if (all) {
        if (ret == ERROR) /* just bail if there was an error, no sense in trying more */
          return ret;

        if (ch == chanset_default)
          ch = chanset;
        else
          ch = ch->next;
      } else {
        ch = NULL;
      }
    }
  }
  return ret;
}
Пример #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);
}