Ejemplo n.º 1
0
/* who <from@bot> <tobot> <chan#>
 */
static void bot_who(int idx, char *par)
{
  char *from, *to, *p;
  int i, chan;

  from = newsplit(&par);
  p = strchr(from, '@');
  if (!p) {
    sprintf(TBUF, "%s@%s", from, dcc[idx].nick);
    from = TBUF;
  }
  to = newsplit(&par);
  if (!egg_strcasecmp(to, botnetnick))
    to[0] = 0;
#ifndef NO_OLD_BOTNET
  if (dcc[idx].u.bot->numver < NEAT_BOTNET)
    chan = atoi(par);
  else
#endif
    chan = base64_to_int(par);
  if (to[0]) {
    i = nextbot(to);
    if (i >= 0)
      botnet_send_who(i, from, to, chan);
  } else
    remote_tell_who(idx, from, chan);
}
Ejemplo n.º 2
0
/* link <from@bot> <who> <to-whom>
 */
static void bot_link(int idx, char *par)
{
  char *from, *bot, *rfrom;
  int i;

  from = newsplit(&par);
  bot = newsplit(&par);

  if (!egg_strcasecmp(bot, botnetnick)) {
    if ((rfrom = strchr(from, ':')))
      rfrom++;
    else
      rfrom = from;
    putlog(LOG_CMDS, "*", "#%s# link %s", rfrom, par);
    if (botlink(from, -1, par))
      botnet_send_priv(idx, botnetnick, from, NULL, "%s %s ...",
                       BOT_LINKATTEMPT, par);
    else
      botnet_send_priv(idx, botnetnick, from, NULL, "%s.", BOT_CANTLINKTHERE);
  } else {
    i = nextbot(bot);
    if (i >= 0)
      botnet_send_link(i, from, bot, par);
  }
}
Ejemplo n.º 3
0
/* (a courtesy info to help during connect bursts)
 * idle <bot> <sock> <#secs> [away msg]
 */
static void bot_idle(int idx, char *par)
{
  char *bot, *work;
  int sock, idle;

  if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
    return;
  bot = newsplit(&par);
  work = newsplit(&par);
#ifndef NO_OLD_BOTNET
  if (dcc[idx].u.bot->numver < NEAT_BOTNET)
    sock = atoi(work);
  else
#endif
    sock = base64_to_int(work);
  if (sock == 0)
    sock = partysock(bot, work);
  work = newsplit(&par);
#ifndef NO_OLD_BOTNET
  if (dcc[idx].u.bot->numver < NEAT_BOTNET)
    idle = atoi(work);
  else
#endif
    idle = base64_to_int(work);
  partysetidle(bot, sock, idle);
  if (par[0]) {
    partystat(bot, sock, PLSTAT_AWAY, 0);
    partyaway(bot, sock, par);
  }
  botnet_send_idle(idx, bot, sock, idle, par);
}
Ejemplo n.º 4
0
/* 437 : Nickname juped (IRCnet)
 */
static int got437(char *from, char *msg)
{
  char *s;
  struct chanset_t *chan;

  newsplit(&msg);
  s = newsplit(&msg);
  if (s[0] && (strchr(CHANMETA, s[0]) != NULL)) {
    chan = findchan(s);
    if (chan) {
      if (chan->status & CHAN_ACTIVE) {
        putlog(LOG_MISC, "*", IRC_CANTCHANGENICK, s);
      } else {
        if (!channel_juped(chan)) {
          putlog(LOG_MISC, "*", IRC_CHANNELJUPED, s);
          chan->status |= CHAN_JUPED;
        }
      }
    }
  } else if (server_online) {
    if (!nick_juped)
      putlog(LOG_MISC, "*", "NICK IS JUPED: %s (keeping '%s').", s, botname);
    if (!rfc_casecmp(s, origbotname))
      nick_juped = 1;
  } else {
    putlog(LOG_MISC, "*", "%s: %s", IRC_BOTNICKJUPED, s);
    gotfake433(from);
  }
  return 0;
}
Ejemplo n.º 5
0
/* These are still here, so that they will pass the relevant
 * requests through even if no filesys is loaded.
 *
 * filereject <bot:filepath> <sock:nick@bot> <reason...>
 */
static void bot_filereject(int idx, char *par)
{
  char *path, *to, *tobot, *p;
  int i;

  path = newsplit(&par);
  to = newsplit(&par);
  if ((tobot = strchr(to, '@')))
    tobot++;
  else
    tobot = to;                 /* Bot wants a file?! :) */
  if (egg_strcasecmp(tobot, botnetnick)) {      /* for me! */
    p = strchr(to, ':');
    if (p != NULL) {
      *p = 0;
      for (i = 0; i < dcc_total; i++) {
        if (dcc[i].sock == atoi(to))
          dprintf(i, "%s (%s): %s\n", BOT_XFERREJECTED, path, par);
      }
      *p = ':';
    }
    /* No ':'? malformed */
    putlog(LOG_FILES, "*", "%s %s: %s", path, MISC_REJECTED, par);
  } else {                        /* Pass it on */
    i = nextbot(tobot);
    if (i >= 0)
      botnet_send_filereject(i, path, to, par);
  }
}
Ejemplo n.º 6
0
static int bot_gseen_req(char *bot, char *code, char *par)
{
  char *mask, *nick, *uhost, *chan, *reply;
  char tosend[256];
  int i;

  Context;
  if (seenflood())
    return 0;
  i = nextbot(bot);
  if (i < 0) {
    debug1("Couldn't answer botnet-seen-request from %s: no such bot", bot);
    return 0;
  }
  mask = newsplit(&par);
  nick = newsplit(&par);
  uhost = newsplit(&par);
  chan = newsplit(&par);
  reset_global_vars();
  glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
  glob_nick = nick;
  reply = do_seen(mask, nick, uhost, chan, -1);
  if (!reply)
    return 0;
  if ((strlen(nick) + strlen(chan) + strlen(reply)) < 255) {
    sprintf(tosend, "gseen_rep %s %s %s", nick, chan, reply);
    botnet_send_zapf(i, botnetnick, bot, tosend);
  }
  return 0;
}
Ejemplo n.º 7
0
static void got_cset(char *botnick, char *code, char *par)
{
  if (!par || !par[0])
   return;

  bool all = 0, isdefault = 0;
  char *chname = NULL;
  struct chanset_t *chan = NULL;

  if (par[0] == '*' && par[1] == ' ') {
    all = 1;
    newsplit(&par);
   } else {
     chname = newsplit(&par);
     if (!strcasecmp(chname, "default"))
       isdefault = 1;
     else if (!strchr(CHANMETA, chname[0])) {
       putlog(LOG_ERROR, "*", "Got bad cset: bot: %s code: %s par: %s %s", botnick, code, chname, par);
       return;
     }
     if (isdefault)
       chan = chanset_default;
     else if (!(chan = findchan_by_dname(chname)))
       return;
   }

  if (all)
   chan = NULL;
  do_chanset(NULL, chan, par, DO_LOCAL);
}
Ejemplo n.º 8
0
/* This is a reply on ISON :<current> <orig> [<alt>]
 */
static void got303(char *from, char *msg)
{
  char *tmp, *alt;
  int ison_orig = 0, ison_alt = 0;

  if (!keepnick || !strncmp(botname, origbotname, strlen(botname))) {
    return;
  }
  newsplit(&msg);
  fixcolon(msg);
  alt = get_altbotnick();
  tmp = newsplit(&msg);
  if (tmp[0] && !rfc_casecmp(botname, tmp)) {
    while ((tmp = newsplit(&msg))[0]) { /* no, it's NOT == */
      if (!rfc_casecmp(tmp, origbotname))
        ison_orig = 1;
      else if (alt[0] && !rfc_casecmp(tmp, alt))
        ison_alt = 1;
    }
    if (!ison_orig) {
      if (!nick_juped)
        putlog(LOG_MISC, "*", IRC_GETORIGNICK, origbotname);
      dprintf(DP_SERVER, "NICK %s\n", origbotname);
    } else if (alt[0] && !ison_alt && rfc_casecmp(botname, alt)) {
      putlog(LOG_MISC, "*", IRC_GETALTNICK, alt);
      dprintf(DP_SERVER, "NICK %s\n", alt);
    }
  }
}
Ejemplo n.º 9
0
/* nc <bot> <sock> <newnick>
 */
static void bot_nickchange(int idx, char *par)
{
  char *bot, *ssock, *newnick;
  int sock, i;

  if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
    return;
  bot = newsplit(&par);
#ifndef NO_OLD_BOTNET
  if (dcc[idx].u.bot->numver < NEAT_BOTNET) {
    fake_alert(idx, "botversion", "NEAT_BOTNET");
    return;
  }
#endif
  i = nextbot(bot);
  if (i != idx) {
    fake_alert(idx, "direction", bot);
    return;
  }
  ssock = newsplit(&par);
  sock = base64_to_int(ssock);
  newnick = newsplit(&par);
  i = partynick(bot, sock, newnick);
  if (i < 0) {
    fake_alert(idx, "sock#", ssock);
    return;
  }
  chanout_but(-1, party[i].chan, "*** (%s) Nick change: %s -> %s\n",
              bot, newnick, party[i].nick);
  botnet_send_nkch_part(idx, i, newnick);
}
Ejemplo n.º 10
0
static void server_activity(int idx, char *msg, int len)
{
  char *from, *code;

  if (trying_server) {
    strcpy(dcc[idx].nick, "(server)");
    putlog(LOG_SERV, "*", "Connected to %s", dcc[idx].host);
    trying_server = 0;
    SERVER_SOCKET.timeout_val = 0;
  }
  lastpingcheck = 0;
  from = "";
  if (msg[0] == ':') {
    msg++;
    from = newsplit(&msg);
  }
  code = newsplit(&msg);
  if (raw_log && ((strcmp(code, "PRIVMSG") && strcmp(code, "NOTICE")) ||
      !match_ignore(from))) {
    if (!strcmp(from, ""))
      putlog(LOG_RAW, "*", "[@] %s %s", code, msg);
    else
      putlog(LOG_RAW, "*", "[@] %s %s %s", from, code, msg);
  }
  /* This has GOT to go into the raw binding table, * merely because this
   * is less effecient.
   */
  check_tcl_raw(from, code, msg);
}
Ejemplo n.º 11
0
/* Got 442: not on channel
 */
static int got442(char *from, char *msg)
{
  char *chname, *key;
  struct chanset_t *chan;

  if (!realservername || egg_strcasecmp(from, realservername))
    return 0;
  newsplit(&msg);
  chname = newsplit(&msg);
  chan = findchan(chname);
  if (chan && !channel_inactive(chan)) {
    module_entry *me = module_find("channels", 0, 0);

    putlog(LOG_MISC, chname, IRC_SERVNOTONCHAN, chname);
    if (me && me->funcs)
      (me->funcs[CHANNEL_CLEAR]) (chan, 1);
    chan->status &= ~CHAN_ACTIVE;

    key = chan->channel.key[0] ? chan->channel.key : chan->key_prot;
    if (key[0])
      dprintf(DP_SERVER, "JOIN %s %s\n", chan->name, key);
    else
      dprintf(DP_SERVER, "JOIN %s\n", chan->name);
  }
  return 0;
}
Ejemplo n.º 12
0
/* away <bot> <sock> <message>
 * null message = unaway
 */
static void bot_away(int idx, char *par)
{
  char *bot = NULL, *etc = NULL;
  int sock, partyidx, linking = 0;

  bot = newsplit(&par);
  if (bot[0] == '!') {
    linking = 1;
    bot++;
  }
  if (b_status(idx) & STAT_LINKING) {
    linking = 1;
  }
  etc = newsplit(&par);
  sock = base64_to_int(etc);
  if (par[0]) {
    partystat(bot, sock, PLSTAT_AWAY, 0);
    partyaway(bot, sock, par);
  } else {
    partystat(bot, sock, 0, PLSTAT_AWAY);
  }
  partyidx = getparty(bot, sock);
  if (!linking) {
    if (par[0])
      chanout_but(-1, party[partyidx].chan,
		  "*** (%s) %s %s: %s.\n", conf.bot->hub ? bot : "[botnet]",
		  party[partyidx].nick, "is now away", par);
    else
      chanout_but(-1, party[partyidx].chan,
		  "*** (%s) %s %s.\n", conf.bot->hub ? bot : "[botnet]",
		  party[partyidx].nick, "is no longer away");
  }
  botnet_send_away(idx, bot, sock, par, linking);
}
Ejemplo n.º 13
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);
}
Ejemplo n.º 14
0
static int pub_seen(char *nick, char *host, char *hand,
        char *channel, char *text)
{
  char *dest;
#if EGG_IS_MIN_VER(10500)
  struct chanset_t *chan;
#endif

  Context;
  if (seenflood() || nopub(channel))
    return 0;
  reset_global_vars();
  glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, channel));
  glob_nick = nick;
  putlog(LOG_CMDS, "*", "<<%s>> !%s! seen %s", nick, hand, text);
  if (quietseen(channel)) {
    set_prefix(SLNOTPREFIX);
    dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix,
           do_seen(newsplit(&text), nick, host, channel, botnet_seen));
    return 0;
  }
#if EGG_IS_MIN_VER(10500)
  chan = findchan_by_dname(channel);
  if (chan)
    dest = chan->name;
  else
    dest = channel;
#else
  dest = channel;
#endif
  set_prefix(SLPUBPREFIX);
  dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", dest, reply_prefix,
  	  do_seen(newsplit(&text), nick, host, channel, botnet_seen));
  return 0;
}
Ejemplo n.º 15
0
static void got_cpart(char *botnick, char *code, char *par)
{
  if (!par[0])
   return;

  char *chname = newsplit(&par);
  struct chanset_t *chan = NULL;

  if (!(chan = findchan_by_dname(chname)))
   return;

  char *bots = newsplit(&par);
  int match = 0;

  /* if bots is '*' just remove_channel */
  if (!strcmp(bots, "*"))
    match = 0;
  else
    match = parsebots(bots, conf.bot->nick);
 
  if (match)
    do_chanset(NULL, chan, "+inactive", DO_LOCAL);
  else
    remove_channel(chan);

  if (conf.bot->hub)
    write_userfile(-1);
}
Ejemplo n.º 16
0
static int bot_gseen_rep(char *bot, char *code, char *par)
{
  char *nick, *chan, *reply;
  int i;

  Context;
  if (seenflood())
    return 0;
  if (!bnsnick || !bnschan) {
    if (bnsnick)
      nfree(bnsnick);
    if (bnschan)
      nfree(bnschan);
    bnsnick = bnschan = NULL;
    return 0;
  }
  nick = newsplit(&par);
  chan = newsplit(&par);
  reset_global_vars();
  glob_remotebot = bot;
  glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
  glob_nick = nick;
  reply = par;
  if (strcmp(nick, bnsnick) || strcmp(chan, bnschan))
    return 0; /* unwanted reply */
  if (findchan(chan)) {
    if (nopub(chan)) {
      nfree(bnsnick);
      nfree(bnschan);
      bnsnick = bnschan = NULL;
      debug1("%s is nopub, bns-reply dropped", chan);
      return 0;
    }
    if (quietseen(chan)) {
      set_prefix(SLNOTPREFIX);
      dprintf(DP_HELP, "NOTICE %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
    } else {
      set_prefix(SLPUBPREFIX);
      dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", chan, reply_prefix, SLRBOTSAYS, reply);
    }
  } else if (!strcmp(chan, "[/msg]")) {
    set_prefix(SLMSGPREFIX);
    dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
  } else if (!strcmp(chan, "[partyline]")) {
    for (i = 0; i < dcc_total; i++) {
      if ((!strcasecmp(nick, dcc[i].nick)) &&
         (dcc[i].type->flags & DCT_SIMUL)) {
	set_prefix(SLDCCPREFIX);
        dprintf(i, "%s%s%s\n", reply_prefix, SLRBOTSAYS, reply);
        break;
      }
    }
  } else
    debug1("Couldn't send received bns answer, no such chan %s", chan);
  nfree(bnsnick);
  nfree(bnschan);
  bnsnick = bnschan = NULL;
  return 0;
}
Ejemplo n.º 17
0
/* 438 : Nick change too fast
 */
static int got438(char *from, char *msg)
{
  newsplit(&msg);
  newsplit(&msg);
  fixcolon(msg);
  putlog(LOG_MISC, "*", "%s", msg);
  return 0;
}
Ejemplo n.º 18
0
static int slang_load(struct slang_header *slang, char *filename)
{
  FILE *f;
  char *buffer, *s;
  char *cmd, *sid, *strtol_ret;
#ifndef SLANG_NOTYPES
  char *type;
#endif
  int line, id;

  Assert(slang);
  putlog(LOG_MISC, "*", "Loading language \"%s\" from %s...", slang->lang, filename);
  f = fopen(filename, "r");
  if (!f) {
    putlog(LOG_MISC, "*", "Couldn't open slangfile \"%s\"!", filename);
    return 0;
  }
  buffer = nmalloc(2000);
  line = 0;
  while (!feof(f)) {
    s = buffer;
    if (fgets(s, 2000, f)) {
      line++;
      // at first, kill those stupid line feeds and carriage returns...
      if (s[strlen(s) - 1] == '\n')
        s[strlen(s) - 1] = 0;
      if (s[strlen(s) - 1] == '\r')
        s[strlen(s) - 1] = 0;
      if (!s[0])
        continue;
      cmd = newsplit(&s);

      if (!strcasecmp(cmd, "T")) {
#ifndef SLANG_NOTYPES
        type = newsplit(&s);
        slang->types = slang_type_add(slang->types, type, s);
#endif
      } else if (!strcasecmp(cmd, "D")) {
        sid = newsplit(&s);
        id = strtol(sid, &strtol_ret, 10);
        if (strtol_ret == sid) {
          putlog(LOG_MISC, "*", "ERROR in slangfile \"%s\", line %d: %s is not a valid "
                 "duration index!", filename, line, sid);
          continue;
        }
        slang->durations = slang_duration_add(slang->durations, id, s);
      } else {
        id = strtol(cmd, &strtol_ret, 10);
        if (strtol_ret == cmd)
          continue;
        slang->ids = slang_id_add(slang->ids, id, s);
      }
    }
  }
  fclose(f);
  nfree(buffer);
  return 1;
}
Ejemplo n.º 19
0
static void bot_rd(char* botnick, char* code, char* msg)
{
  size_t len = atoi(newsplit(&msg));
  if (msg[0]) {
    int idx = atoi(newsplit(&msg));
    if (msg[0])
      dprintf_real(idx, msg, len, len);
  }
}
Ejemplo n.º 20
0
/* unlink <from@bot> <linking-bot> <undesired-bot> <reason>
 */
static void bot_unlink(int idx, char *par)
{
  char *from, *bot, *rfrom, *p, *undes;
  int i;

  from = newsplit(&par);
  bot = newsplit(&par);
  undes = newsplit(&par);
  if (!egg_strcasecmp(bot, botnetnick)) {
    if ((rfrom = strchr(from, ':')))
      rfrom++;
    else
      rfrom = from;
    putlog(LOG_CMDS, "*", "#%s# unlink %s (%s)", rfrom, undes, par[0] ? par :
           "No reason");
    i = botunlink(-3, undes, par[0] ? par : NULL, rfrom);
    if (i == 1) {
      p = strchr(from, '@');
      if (p) {
        /* idx will change after unlink -- get new idx
         *
         * TODO: This has changed with the new lostdcc() behaviour. Check
         *       if we can optimise the situation.
         */
        i = nextbot(p + 1);
        if (i >= 0)
          botnet_send_priv(i, botnetnick, from, NULL,
                           "Unlinked from %s.", undes);
      }
    } else if (i == 0) {
      botnet_send_unlinked(-1, undes, "");
      p = strchr(from, '@');
      if (p) {
        /* Ditto above, about idx */
        i = nextbot(p + 1);
        if (i >= 0)
          botnet_send_priv(i, botnetnick, from, NULL,
                           "%s %s.", BOT_CANTUNLINK, undes);
      }
    } else {
      p = strchr(from, '@');
      if (p) {
        i = nextbot(p + 1);
        if (i >= 0)
          botnet_send_priv(i, botnetnick, from, NULL,
                           "Can't remotely unlink sharebots.");
      }
    }
  } else {
    i = nextbot(bot);
    if (i >= 0)
      botnet_send_unlink(i, from, bot, undes, par);
  }
}
Ejemplo n.º 21
0
/*
 * 465     ERR_YOUREBANNEDCREEP :You are banned from this server
 */
static int got465(char *from, char *msg)
{
  newsplit(&msg); /* 465 */
  newsplit(&msg); /* nick */

  fixcolon(msg);

  putlog(LOG_SERV, "*", "Server (%s) says I'm banned: %s", from, msg);
  putlog(LOG_SERV, "*", "Disconnecting from server.");
  nuke_server("Banned from server.");
  return 1;
}
Ejemplo n.º 22
0
/* trace <from@bot> <dest> <chain:chain..>
 */
static void bot_trace(int idx, char *par)
{
  char *from, *dest;
  int i;

  from = newsplit(&par);
  dest = newsplit(&par);
  simple_sprintf(TBUF, "%s:%s", par, botnetnick);
  botnet_send_traced(idx, from, TBUF);
  if (egg_strcasecmp(dest, botnetnick) && ((i = nextbot(dest)) > 0))
    botnet_send_trace(i, from, dest, par);
}
Ejemplo n.º 23
0
/* trace <from@bot> <dest> <chain:chain..>
 */
static void bot_trace(int idx, char *par)
{
  char *from = NULL, *dest = NULL;
  int i;

  from = newsplit(&par);
  dest = newsplit(&par);
  simple_snprintf(TBUF, sizeof(TBUF), "%s:%s", par, conf.bot->nick);
  botnet_send_traced(idx, from, TBUF);
  if (strcasecmp(dest, conf.bot->nick) && ((i = nextbot(dest)) > 0))
    botnet_send_trace(i, from, dest, par);
}
Ejemplo n.º 24
0
static void do_arg(char *s)
{
  char x[512], *z = x;
  int i;

  if (s[0] == '-')
    for (i = 1; i < strlen(s); i++) {
      switch (s[i]) {
      case 'n':
        backgrd = 0;
        break;
      case 'c':
        con_chan = 1;
        term_z = 0;
        break;
      case 't':
        con_chan = 0;
        term_z = 1;
        break;
      case 'm':
        make_userfile = 1;
        break;
      case 'v':
        strncpyz(x, egg_version, sizeof x);
        newsplit(&z);
        newsplit(&z);
        printf("%s\n", version);
        if (z[0])
          printf("  (patches: %s)\n", z);
        printf("Configured with: " EGG_AC_ARGS "\n");
        printf("Compiled with: ");
#ifdef IPV6
        printf("IPv6, ");
#endif
#ifdef TLS
        printf("TLS, ");
#endif
        printf("handlen=%d\n", HANDLEN);
        bg_send_quit(BG_ABORT);
        exit(0);
        break;                  /* this should never be reached */
      case 'h':
        printf("\n%s\n\n", version);
        printf(EGG_USAGE);
        printf("\n");
        bg_send_quit(BG_ABORT);
        exit(0);
        break;                  /* this should never be reached */
      }
    } else
    strncpyz(configfile, s, sizeof configfile);
}
Ejemplo n.º 25
0
static void bot_rsimr(char *botnick, char *code, char *msg)
{
  if (msg[0]) {
    char * par = strdup(msg), *parp = par;
    int idx = atoi(newsplit(&par, ' ', 0));
    char *nick = newsplit(&par, ' ', 0);

    if (dcc[idx].type && (dcc[idx].type == &DCC_CHAT) && dcc[idx].user && !strcmp(dcc[idx].user->handle, nick)) {
      dprintf(idx, "[%s] %s\n", botnick, par);
    }
    free(parp);
  }
}
Ejemplo n.º 26
0
/* chan <from> <chan> <text>
 */
static void bot_chan2(int idx, char *msg)
{
  char *from, *p;
  int i, chan;

  if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
    return;
  from = newsplit(&msg);
  p = newsplit(&msg);
#ifndef NO_OLD_BOTNET
  if (dcc[idx].u.bot->numver < NEAT_BOTNET)
    chan = atoi(p);
  else
#endif
    chan = base64_to_int(p);
  /* Strip annoying control chars */
  for (p = from; *p;) {
    if ((*p < 32) || (*p == 127))
      strcpy(p, p + 1);
    else
      p++;
  }
  p = strchr(from, '@');
  if (p) {
    sprintf(TBUF, "<%s> %s", from, msg);
    *p = 0;
    if (!partyidle(p + 1, from)) {
      *p = '@';
      fake_alert(idx, "user", from);
      return;
    }
    *p = '@';
    p++;
  } else {
    sprintf(TBUF, "*** (%s) %s", from, msg);
    p = from;
  }
  i = nextbot(p);
  if (i != idx) {
    fake_alert(idx, "direction", p);
  } else {
    chanout_but(-1, chan, "%s\n", TBUF);
    /* Send to new version bots */
    if (i >= 0)
      botnet_send_chan(idx, from, NULL, chan, msg);
    if (strchr(from, '@') != NULL)
      check_tcl_chat(from, chan, msg);
    else
      check_tcl_bcst(from, chan, msg);
  }
}
Ejemplo n.º 27
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.º 28
0
/* part <bot> <nick> <sock> [etc..]
 */
static void bot_part(int idx, char *par)
{
  char *bot = NULL, *nick = NULL, *etc = NULL;
  struct userrec *u = NULL;
  int sock, partyidx;
  int silent = 0;

  bot = newsplit(&par);
  if (bot[0] == '!') {
    silent = 1;
    bot++;
  }
  nick = newsplit(&par);
  etc = newsplit(&par);
  sock = base64_to_int(etc);

  u = get_user_by_handle(userlist, nick);
  if (u) {
    simple_snprintf(TBUF, sizeof(TBUF), "@%s", bot);
    touch_laston(u, TBUF, now);
  }
  if ((partyidx = getparty(bot, sock)) != -1) {
    if (!silent) {
      register int chan = party[partyidx].chan;

      if (par[0])
	chanout_but(-1, chan, "*** (%s) %s %s %s (%s).\n", conf.bot->hub ? bot : "[botnet]", nick,
		    "has left the",
		    chan ? "channel" : "party line", par);
      else
	chanout_but(-1, chan, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick,
		    "has left the",
		    chan ? "channel" : "party line");
    }
    botnet_send_part_party(idx, partyidx, par, silent);
    remparty(bot, sock);
  }

  /* check if we have a remote idx for them */
  int i = 0;

  for (i = 0; i < dcc_total; i++) {
    /* This will potentially close all simul-idxs with matching nick, even though they may be connected multiple times
       but, it won't matter as a new will just be made as needed. */
    if (dcc[i].type && dcc[i].simul >= 0 && !strcasecmp(dcc[i].nick, nick)) {
        dcc[i].simul = -1;
        lostdcc(i);
    }
  }

}
Ejemplo n.º 29
0
static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
{
  char *old = NULL, *mynew = NULL;

  if (match_my_nick(nick))
    return BIND_RET_BREAK;
  if (!u) {
    putlog(LOG_CMDS, "*", "(%s!%s) !*! PASS", nick, host);
    return BIND_RET_BREAK;
  }
  if (u->bot)
    return BIND_RET_BREAK;
  if (!par[0]) {
    notice(nick, u_pass_match(u, "-") ? "You don't have a password set." : "You have a password set.", DP_HELP);
    putlog(LOG_CMDS, "*", "(%s!%s) !%s! PASS?", nick, host, u->handle);
    return BIND_RET_BREAK;
  }
  old = newsplit(&par);
  if (!u_pass_match(u, "-") && !par[0]) {
    putlog(LOG_CMDS, "*", "(%s!%s) !%s! $b!$bPASS...", nick, host, u->handle);
    notice(nick, "You already have a password set.", DP_HELP);
    return BIND_RET_BREAK;
  }
  if (par[0]) {
    if (!u_pass_match(u, old)) {
      putlog(LOG_CMDS, "*", "(%s!%s) !%s! $b!$bPASS...", nick, host, u->handle);
      notice(nick, "Incorrect password.", DP_HELP);
      return BIND_RET_BREAK;
    }
    mynew = newsplit(&par);
  } else {
    mynew = old;
  }
  if (strlen(mynew) > MAXPASSLEN)
    mynew[MAXPASSLEN] = 0;

  if (!goodpass(mynew, 0, nick)) {
    putlog(LOG_CMDS, "*", "(%s!%s) !%s! $b!$bPASS...", nick, host, u->handle);
    return BIND_RET_BREAK;
  }

  putlog(LOG_CMDS, "*", "(%s!%s) !%s! PASS", nick, host, u->handle);

  set_user(&USERENTRY_PASS, u, mynew);
  bd::String msg;
  msg = bd::String::printf("%s '%s'.", mynew == old ? "Password set to:" : "Password changed to:", mynew);
  notice(nick, msg.c_str(), DP_HELP);
  return BIND_RET_BREAK;
}
Ejemplo n.º 30
0
static void got_cjoin(char *botnick, char *code, char *par)
{
  if (!par[0])
   return;

  char *chname = newsplit(&par), *options = NULL;
  struct chanset_t *chan = findchan_by_dname(chname);
  int match = 0;

  if (conf.bot->hub) {
    newsplit(&par);	/* hubs ignore the botmatch param */
    options = par;
  } else {
    /* ALL hubs should add the channel, leaf should check the list for a match */
    bool inactive = 0;
    char *bots = newsplit(&par);
    match = parsebots(bots, conf.bot->nick);

    if (strstr(par, "+inactive"))
      inactive = 1;

    if (chan && !match)
      return;

    if (!match) {
      size_t size = strlen(par) + 12 + 1;

      options = (char *) my_calloc(1, size);
      simple_snprintf(options, size, "%s +inactive", par);
    } else if (match && chan && !shouldjoin(chan)) {
      if (!inactive)
        do_chanset(NULL, chan, "-inactive", DO_LOCAL);
      return;
    } else
      options = par;
  }

  if (chan)
    return;
sdprintf("OPTIONS: %s", options);
  char result[RESULT_LEN] = "";

  if (channel_add(result, chname, options) == ERROR) /* drummer */
    putlog(LOG_BOTS, "@", "Invalid channel or channel options from %s for %s: %s", botnick, chname, result);
  if (conf.bot->hub)
    write_userfile(-1);
  if (!match && !conf.bot->hub)
    free(options);
}