Esempio n. 1
0
/* Used to send a direct msg from Tcl on one bot to Tcl on another
 * zapf <frombot> <tobot> <code [param]>
 */
static void bot_zapf(int idx, char *par)
{
  char *from = NULL, *to = NULL;
  int i;

  from = newsplit(&par);
  to = newsplit(&par);
  i = nextbot(from);
  if (i != idx) {
    fake_alert(idx, "direction", from, "zapf");
    return;
  }
  if (!strcasecmp(to, conf.bot->nick)) {
    /* For me! */
    char *opcode;

    opcode = newsplit(&par);
    check_bind_bot(from, opcode, par);
    return;
  } else {
    i = nextbot(to);
    if (i >= 0)
      botnet_send_zapf(i, from, to, par);
  }
}
Esempio n. 2
0
void bot_remotereply(int idx, char *par) {
  char *tbot = NULL, *fbot = NULL, *fhnd = NULL, *fidx = NULL;

  if (par[0])
    tbot = newsplit(&par);
  if (par[0])
    fbot = newsplit(&par);
  if (par[0])
    fhnd = newsplit(&par);
  if (par[0])
    fidx = newsplit(&par);

  /* Make sure the bot is valid */
  int i = nextbot(fbot);
  if (i != idx) {
    fake_alert(idx, "direction", fbot, "rr");
    return;
  }

  if (!strcasecmp(tbot, conf.bot->nick)) {
    gotremotereply(fbot, fhnd, fidx, par);
  } else {
    if (nextbot(tbot)!= idx)
      botnet_send_cmdreply(fbot, tbot, fhnd, fidx, par);
  }
}
Esempio n. 3
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);
  }
}
Esempio n. 4
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);
  }
}
Esempio n. 5
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);
}
Esempio n. 6
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);
}
Esempio n. 7
0
static void zapf_assoc(char *botnick, char *code, char *par)
{
  int idx = nextbot(botnick);
  char *s, *s1, *nick;
  int linking = 0, chan;

  if ((idx >= 0) && !(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
    if (!egg_strcasecmp(dcc[idx].nick, botnick))
      linking = b_status(idx) & STAT_LINKING;
    s = newsplit(&par);
    chan = base64_to_int(s);
    if ((chan > 0) || (chan < GLOBAL_CHANS)) {
      nick = newsplit(&par);
      s1 = get_assoc_name(chan);
      if (linking && ((s1 == NULL) || (s1[0] == 0) ||
          (((intptr_t) get_user(find_entry_type("BOTFL"),
          dcc[idx].user) & BOT_HUB)))) {
        add_assoc(par, chan);
        botnet_send_assoc(idx, chan, nick, par);
        chanout_but(-1, chan, ASSOC_CHNAME_NAMED, nick, par);
      } else if (par[0] == '0') {
        kill_assoc(chan);
        chanout_but(-1, chan, ASSOC_CHNAME_REM, botnick, nick);
      } else if (get_assoc(par) != chan) {
        /* New one i didn't know about -- pass it on */
        s1 = get_assoc_name(chan);
        add_assoc(par, chan);
        chanout_but(-1, chan, ASSOC_CHNAME_NAMED2, botnick, nick, par);
      }
    }
  }
}
Esempio n. 8
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);
  }
}
Esempio n. 9
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;
}
Esempio n. 10
0
/* filereq <sock:nick@bot> <bot:file>
 */
static void bot_filereq(int idx, char *tobot)
{
  char *from, *path;
  int i;

  from = newsplit(&tobot);
  if ((path = strchr(tobot, ':'))) {
    *path++ = 0;

    if (!egg_strcasecmp(tobot, botnetnick)) {   /* For me! */
      /* Process this */
      module_entry *fs = module_find("filesys", 0, 0);

      if (fs == NULL)
        botnet_send_priv(idx, botnetnick, from, NULL, MOD_NOFILESYSMOD);
      else {
        Function f = fs->funcs[FILESYS_REMOTE_REQ];

        f(idx, from, path);
      }
    } else {                      /* Pass it on */
      i = nextbot(tobot);
      if (i >= 0)
        botnet_send_filereq(i, from, tobot, path);
    }
  }
}
Esempio n. 11
0
static int tcl_boot(ClientData cd, Tcl_Interp *irp,
                    int argc, char *argv[])
{
  char who[NOTENAMELEN + 1];
  int i, ok = 0;

  BADARGS(2, 3, " user@bot ?reason?");

  strncpyz(who, argv[1], sizeof who);

  if (strchr(who, '@') != NULL) {
    char whonick[HANDLEN + 1];

    splitc(whonick, who, '@');
    whonick[HANDLEN] = 0;
    if (!egg_strcasecmp(who, botnetnick))
      strncpyz(who, whonick, sizeof who);
    else if (remote_boots > 0) {
      i = nextbot(who);
      if (i < 0)
        return TCL_OK;
      botnet_send_reject(i, botnetnick, NULL, whonick, who,
                         argv[2] ? argv[2] : "");
    } else
      return TCL_OK;
  }
  for (i = 0; i < dcc_total; i++)
    if (!ok && (dcc[i].type->flags & DCT_CANBOOT) &&
        !egg_strcasecmp(dcc[i].nick, who)) {
      do_boot(i, botnetnick, argv[2] ? argv[2] : "");
      ok = 1;
    }
  return TCL_OK;
}
Esempio n. 12
0
static void bot_unlinked(int idx, char *par)
{
  int i;
  char *bot = NULL;

  bot = newsplit(&par);
  i = nextbot(bot);
  if ((i >= 0) && (i != idx))	/* Bot is NOT downstream along idx, so
				 * BOGUS! */
    fake_alert(idx, "direction", bot, "unlinked");
  else if (i >= 0) {		/* Valid bot downstream of idx */
    if (par[0])
/* #ifdef HUB */
      chatout("*** (%s) %s\n", lastbot(bot), par);
/*
#else
      chatout("*** %s unlinked from botnet.\n", par);
#endif 
*/
    botnet_send_unlinked(idx, bot, par);
    unvia(idx, findbot(bot));
    rembot(bot);
  }
  /* Otherwise it's not even a valid bot, so just ignore! */
}
Esempio n. 13
0
void write_userfile_protected(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
{
  int localhub = nextbot(u->handle);
  /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain */
  if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub)) {
    stream << bd::String::printf("--%s %s\n", e->type->name, e->u.string);
  }
}
Esempio n. 14
0
/* traced <to@bot> <chain:chain..>
 */
static void bot_traced(int idx, char *par)
{
  char *to = NULL, *p = NULL;
  int i, sock;

  to = newsplit(&par);
  p = strchr(to, '@');
  if (p == NULL)
    p = to;
  else {
    *p = 0;
    p++;
  }
  if (!strcasecmp(p, conf.bot->nick)) {
    time_t t = 0;
    char *p2 = par, *ss = TBUF;

    splitc(ss, to, ':');
    if (ss[0])
      sock = atoi(ss);
    else
      sock = (-1);
    if (par[0] == ':') {
      t = atoi(par + 1);
      p2 = strchr(par + 1, ':');
      if (p2)
	p2++;
      else
	p2 = par + 1;
    }
    for (i = 0; i < dcc_total; i++) {
      if (dcc[i].type && (dcc[i].type->flags & DCT_CHAT) && (!strcasecmp(dcc[i].nick, to)) &&
          ((sock == (-1)) || (sock == dcc[i].sock))) {
	if (t) {
          int j=0;
          register char *c = p2;
          for (; *c != '\0'; c++) if (*c == ':') j++;

          time_t tm;
          egg_timeval_t tv;

          timer_get_now(&tv);
          tm = ((tv.sec % 10000) * 100 + (tv.usec * 100) / (1000000)) - t;

          dprintf(i, "%s -> %s (%d.%d secs, %d hop%s)\n", "Trace result", p2,
            (int)(tm / 100), (int)(tm % 100), j, (j != 1) ? "s" : "");
	} else
	  dprintf(i, "%s -> %s\n", "Trace result", p);
      }
    }
  } else {
    i = nextbot(p);
    if (p != to)
      *--p = '@';
    if (i >= 0)
      botnet_send_traced(i, to, par);
  }
}
Esempio n. 15
0
/* traced <to@bot> <chain:chain..>
 */
static void bot_traced(int idx, char *par)
{
  char *to, *p;
  int i, sock;

  to = newsplit(&par);
  p = strchr(to, '@');
  if (p == NULL)
    p = to;
  else {
    *p = 0;
    p++;
  }
  if (!egg_strcasecmp(p, botnetnick)) {
    time_t t = 0;
    char *p = par, *ss = TBUF;

    splitc(ss, to, ':');
    if (ss[0])
      sock = atoi(ss);
    else
      sock = -1;
    if (par[0] == ':') {
      t = atoi(par + 1);
      p = strchr(par + 1, ':');
      if (p)
        p++;
      else
        p = par + 1;
    }
    for (i = 0; i < dcc_total; i++)
      if ((dcc[i].type->flags & DCT_CHAT) &&
          (!egg_strcasecmp(dcc[i].nick, to)) &&
          ((sock == -1) || (sock == dcc[i].sock))) {
        if (t) {
          int j = 0;

          {
            register char *c = p;

            for (; *c != '\0'; c++)
              if (*c == ':')
                j++;
          }
          dprintf(i, "%s -> %s (%lu secs, %d hop%s)\n", BOT_TRACERESULT, p,
                  now - t, j, (j != 1) ? "s" : "");
        } else
          dprintf(i, "%s -> %s\n", BOT_TRACERESULT, p);
      }
  } else {
    i = nextbot(p);
    if (p != to)
      *--p = '@';
    if (i >= 0)
      botnet_send_traced(i, to, par);
  }
}
Esempio n. 16
0
/* v <frombot> <tobot> <idx:nick>
 */
static void bot_versions(int sock, char *par)
{
  char *frombot = newsplit(&par), *tobot = NULL, *from = NULL;

  if (nextbot(frombot) != sock)
    fake_alert(sock, "direction", frombot, "versions");
  else if (strcasecmp(tobot = newsplit(&par), conf.bot->nick)) {
    if ((sock = nextbot(tobot)) >= 0)
      dprintf(sock, "v %s %s %s\n", frombot, tobot, par);
  } else {
    from = newsplit(&par);
    botnet_send_priv(sock, conf.bot->nick, from, frombot, "Modules loaded:\n");
/* wtf?
    for (me = module_list; me; me = me->next)
      botnet_send_priv(sock, conf.bot->nick, from, frombot, "  Module: %s\n", me->name);
*/
    botnet_send_priv(sock, conf.bot->nick, from, frombot, "End of module list.\n");
  }
}
Esempio n. 17
0
/* v <frombot> <tobot> <idx:nick>
 */
static void bot_versions(int sock, char *par)
{
  char *frombot = newsplit(&par), *tobot, *from;
  module_entry *me;

  if (nextbot(frombot) != sock)
    fake_alert(sock, "versions-direction", frombot);
  else if (egg_strcasecmp(tobot = newsplit(&par), botnetnick)) {
    if ((sock = nextbot(tobot)) >= 0)
      dprintf(sock, "v %s %s %s\n", frombot, tobot, par);
  } else {
    from = newsplit(&par);
    botnet_send_priv(sock, botnetnick, from, frombot, "Modules loaded:\n");
    for (me = module_list; me; me = me->next)
      botnet_send_priv(sock, botnetnick, from, frombot,
                       "  Module: %s (v%d.%d)\n", me->name, me->major,
                       me->minor);
    botnet_send_priv(sock, botnetnick, from, frombot, "End of module list.\n");
  }
}
Esempio n. 18
0
/* Show motd to someone
 */
static void bot_motd(int idx, char *par)
{
  FILE *vv;
  char *s = TBUF, *who, *p;
  int i;
  struct flag_record fr = { FR_BOT, USER_BOT, 0, 0, 0, 0 };

  who = newsplit(&par);
  if (!par[0] || !egg_strcasecmp(par, botnetnick)) {
    int irc = 0;

    p = strchr(who, ':');
    if (p)
      p++;
    else
      p = who;
    if (who[0] == '!') {
      irc = HELP_IRC;
      fr.global |=USER_HIGHLITE;

      who++;
    } else if (who[0] == '#') {
      fr.global |=USER_HIGHLITE;

      who++;
    }
    putlog(LOG_CMDS, "*", "#%s# motd", p);
    vv = fopen(motdfile, "r");
    if (vv != NULL) {
      botnet_send_priv(idx, botnetnick, who, NULL, "--- %s\n", MISC_MOTDFILE);
      help_subst(NULL, NULL, 0, irc, NULL);
      while (!feof(vv)) {
        fgets(s, 120, vv);
        if (!feof(vv)) {
          if (s[strlen(s) - 1] == '\n')
            s[strlen(s) - 1] = 0;
          if (!s[0])
            strcpy(s, " ");
          help_subst(s, who, &fr, HELP_DCC, dcc[idx].nick);
          if (s[0])
            botnet_send_priv(idx, botnetnick, who, NULL, "%s", s);
        }
      }
      fclose(vv);
    } else
      botnet_send_priv(idx, botnetnick, who, NULL, "%s :(", MISC_NOMOTDFILE);
  } else {
    /* Pass it on */
    i = nextbot(par);
    if (i >= 0)
      botnet_send_motd(i, who, par);
  }
}
Esempio n. 19
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);
}
Esempio n. 20
0
static void set_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
{
  int localhub = nextbot(u->handle);
  struct xtra_key *x = (struct xtra_key *) e->u.extra;

  for (; x; x = x->next) {
    /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain, or sending 'groups' */
    if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub) || !strcmp(x->key, "groups")) {
      stream << bd::String::printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
    }
  }
}
Esempio n. 21
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);
}
Esempio n. 22
0
/* priv <from> <to> <message>
 */
static void bot_priv(int idx, char *par)
{
  char *from = NULL, *p = NULL, *to = TBUF, *tobot = NULL;
  int i;

  from = newsplit(&par);
  tobot = newsplit(&par);
  splitc(to, tobot, '@');
  p = strchr(from, '@');
  if (p != NULL)
    p++;
  else
    p = from;
  i = nextbot(p);
  if (i != idx) {
    fake_alert(idx, "direction", p, "priv_i");
    return;
  }
  if (!to[0])
    return;			/* Silently ignore notes to '@bot' this
				 * is legacy code */
  if (!strcasecmp(tobot, conf.bot->nick)) {		/* For me! */
    if (p == from)
      add_note(to, from, par, -2, 0);
    else {
      i = add_note(to, from, par, -1, 0);
      if (from[0] != '@')
	switch (i) {
	case NOTE_ERROR:
	  botnet_send_priv(idx, conf.bot->nick, from, NULL, "%s %s.", "No such user", to);
	  break;
	}
    }
  } else {			/* Pass it on */
    i = nextbot(tobot);
    if (i >= 0)
      botnet_send_priv(i, from, to, tobot, "%s", par);
  }
}
Esempio n. 23
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);
  }
}
Esempio n. 24
0
static int tcl_islinked(ClientData cd, Tcl_Interp *irp,
                        int argc, char *argv[])
{
  int i;

  BADARGS(2, 2, " bot");

  i = nextbot(argv[1]);
  if (i < 0)
    Tcl_AppendResult(irp, "0", NULL);
  else
    Tcl_AppendResult(irp, "1", NULL);
  return TCL_OK;
}
Esempio n. 25
0
/* Used to send a direct msg from Tcl on one bot to Tcl on another
 * zapf <frombot> <tobot> <code [param]>
 */
static void bot_zapf(int idx, char *par)
{
  char *from, *to;
  int i;

  from = newsplit(&par);
  to = newsplit(&par);
  i = nextbot(from);
  if (i != idx) {
    fake_alert(idx, "direction", from);
    return;
  }
  if (!egg_strcasecmp(to, botnetnick)) {
    /* For me! */
    char *opcode;

    opcode = newsplit(&par);
    check_tcl_bot(from, opcode, par);
    return;
  }
  i = nextbot(to);
  if (i >= 0)
    botnet_send_zapf(i, from, to, par);
}
Esempio n. 26
0
/* join <bot> <nick> <chan> <flag><sock> <from>
 */
static void bot_join(int idx, char *par)
{
  char *bot = NULL, *nick = NULL, *x = NULL, *y = NULL;
  struct userrec *u = NULL;
  int i, sock, chan, i2, linking = 0;

  bot = newsplit(&par);
  if (bot[0] == '!') {
    linking = 1;
    bot++;
  }
  if (b_status(idx) & STAT_LINKING) {
    linking = 1;
  }
  nick = newsplit(&par);
  x = newsplit(&par);
  chan = base64_to_int(x);
  y = newsplit(&par);
  if ((chan < 0) || !y[0])
    return;			/* Woops! pre 1.2.1's send .chat off'ers
				 * too!! */
  if (!y[0]) {
    y[0] = '-';
    sock = 0;
  } else {
    sock = base64_to_int(y + 1);
  }
  i = nextbot(bot);
  if (i != idx) {		/* Ok, garbage from a 1.0g (who uses that
				 * now?) OR raistlin being evil :) */
    fake_alert(idx, "direction", bot, "join");
    return;
  }
  u = get_user_by_handle(userlist, nick);
  if (u) {
    simple_snprintf(TBUF, sizeof(TBUF), "@%s", bot);
    touch_laston(u, TBUF, now);
  }
  i = addparty(bot, nick, chan, y[0], sock, par, &i2);
  botnet_send_join_party(idx, linking, i2);
  if (i != chan) {
    if (i >= 0) {
      chanout_but(-1, i, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick, "has left the", i ? "channel" : "party line");
    }
    if (!linking)
    chanout_but(-1, chan, "*** (%s) %s %s %s.\n", conf.bot->hub ? bot : "[botnet]", nick, "has joined the", chan ? "channel" : "party line");
  }
}
Esempio n. 27
0
/* chan <from> <chan> <text>
 */
static void bot_chan2(int idx, char *msg)
{
  char *from = NULL, *p = NULL;
  int i, chan;

  from = newsplit(&msg);
  p = newsplit(&msg);
  chan = base64_to_int(p);
  /* Strip annoying control chars */
  for (p = from; *p;) {
    if ((*p < 32) || (*p == 127))
      memmove(p, p + 1, strlen(p));
    else
      p++;
  }
  p = strchr(from, '@');
  if (p) {
    if (!conf.bot->hub) { /* Need to strip out the hub nick */
      char *q = NULL, newfrom[HANDLEN + 9 + 1]; /* HANDLEN@[botnet] */
   
      strlcpy(newfrom, from, sizeof(newfrom));
      q = strchr(newfrom, '@');
      *q = 0;
      simple_snprintf(TBUF, sizeof(TBUF), "<%s@[botnet]> %s", newfrom, msg);
    } else
      simple_snprintf(TBUF, sizeof(TBUF), "<%s> %s", from, msg);
    *p = 0;
    if (!partyidle(p + 1, from)) {
      *p = '@';
      fake_alert(idx, "user", from, "chan2_i");
      return;
    }
    *p = '@';
    p++;
  } else {
    simple_snprintf(TBUF, sizeof(TBUF), "*** (%s) %s", from, msg);
    p = from;
  }
  i = nextbot(p);
  if (i != idx) {
    fake_alert(idx, "direction", p, "chan2_ii");
  } else {
    chanout_but(-1, chan, "%s\n", TBUF);
    /* Send to new version bots */
    if (i >= 0)
      botnet_send_chan(idx, from, NULL, chan, msg);
  }
}
Esempio n. 28
0
/* Used to send a global msg from Tcl on one bot to every other bot
 * zapf-broad <frombot> <code [param]>
 */
static void bot_zapfbroad(int idx, char *par)
{
  char *from = NULL, *opcode = NULL;
  int i;

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

  i = nextbot(from);
  if (i != idx) {
    fake_alert(idx, "direction", from, "zapfb");
    return;
  }
  check_bind_bot(from, opcode, par);
  botnet_send_zapf_broad(idx, from, opcode, par);
}
Esempio n. 29
0
static void link_assoc(char *bot, char *via)
{
  char x[1024];

  if (!egg_strcasecmp(via, botnetnick)) {
    int idx = nextbot(bot);
    assoc_t *a;

    if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
      for (a = assoc; a && a->name[0]; a = a->next) {
        simple_sprintf(x, "assoc %D %s %s", (int) a->channel, botnetnick,
                       a->name);
        botnet_send_zapf(idx, botnetnick, dcc[idx].nick, x);
      }
    }
  }
}
Esempio n. 30
0
static int tcl_putbot(ClientData cd, Tcl_Interp *irp,
                      int argc, char *argv[])
{
  int i;
  char msg[401];

  BADARGS(3, 3, " botnick message");

  i = nextbot(argv[1]);
  if (i < 0) {
    Tcl_AppendResult(irp, "bot is not on the botnet", NULL);
    return TCL_ERROR;
  }
  strncpyz(msg, argv[2], sizeof msg);

  botnet_send_zapf(i, botnetnick, argv[1], msg);
  return TCL_OK;
}