Ejemplo n.º 1
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.º 2
0
/* info? <from@bot>   -> send priv
 */
static void bot_infoq(int idx, char *par)
{
  char s[200], s2[32], *realnick;
  struct chanset_t *chan;
  time_t now2;
  int hr, min;

  /* Strip the idx from user@bot */
  realnick = strchr(par, ':');
  if (realnick)
    realnick++;
  else
    realnick = par;
  putlog(LOG_BOTS, "*", "#%s# botinfo", realnick);

  now2 = now - online_since;
  s2[0] = 0;
  if (now2 > 86400) {
    int days = now2 / 86400;

    /* Days */
    sprintf(s2, "%d day", days);
    if (days >= 2)
      strcat(s2, "s");
    strcat(s2, ", ");
    now2 -= days * 86400;
  }
  hr = (time_t) ((int) now2 / 3600);
  now2 -= (hr * 3600);
  min = (time_t) ((int) now2 / 60);
  sprintf(&s2[strlen(s2)], "%02d:%02d", (int) hr, (int) min);
  if (module_find("server", 0, 0)) {
    s[0] = 0;
    for (chan = chanset; chan; chan = chan->next) {
      if (!channel_secret(chan)) {
        if ((strlen(s) + strlen(chan->dname) + strlen(network)
             + strlen(botnetnick) + strlen(ver) + 1) >= 200) {
          strcat(s, "++  ");
          break;                /* Yegads..! */
        }
        strcat(s, chan->dname);
        strcat(s, ", ");
      }
    }
    if (s[0]) {
      s[strlen(s) - 2] = 0;
      botnet_send_priv(idx, botnetnick, par, NULL,
                       "%s <%s> (%s) [UP %s]", ver, network, s, s2);
    } else
      botnet_send_priv(idx, botnetnick, par, NULL, "%s <%s> (%s) [UP %s]", ver,
                       network, BOT_NOCHANNELS, s2);
  } else
    botnet_send_priv(idx, botnetnick, par, NULL,
                     "%s <NO_IRC> [UP %s]", ver, s2);
  botnet_send_infoq(idx, par);
}
Ejemplo 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);
  }
}
Ejemplo n.º 4
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);
  }
}
Ejemplo n.º 5
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);
    }
  }
}
Ejemplo n.º 6
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");
  }
}
Ejemplo n.º 7
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");
  }
}
Ejemplo n.º 8
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);
  }
}
Ejemplo n.º 9
0
/* link <from@bot> <who> <to-whom>
 */
static void bot_link(int idx, char *par)
{
  char *from = NULL, *bot = NULL, *rfrom = NULL;
  int i;

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

  if (!strcasecmp(bot, conf.bot->nick)) {
    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, conf.bot->nick, from, NULL, "%s %s ...", "Attempting to link", par);
    else
      botnet_send_priv(idx, conf.bot->nick, from, NULL, "%s.", "Can't link there");
  } else {
    i = nextbot(bot);
    if (i >= 0)
      botnet_send_link(i, from, bot, par);
  }
}
Ejemplo n.º 10
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);
    }
  }
}
Ejemplo n.º 11
0
static void remote_tell_who(int idx, char *nick, int chan)
{
  int i = 10, k, l, ok = 0;
  char s[1024] = "", *realnick = NULL;
  struct chanset_t *c = NULL;

  realnick = strchr(nick, ':');
  if (realnick)
    realnick++;
  else
    realnick = nick;
  putlog(LOG_BOTS, "*", "#%s# who", realnick);
  strlcpy(s, "Channels: ", sizeof(s));
  for (c = chanset; c; c = c->next)
    if (!channel_secret(c) && shouldjoin(c)) {
      l = strlen(c->dname);
      if (i + l < 1021) {
	if (i > 10) {
          strlcat(s, ", ", sizeof(s));
          strlcat(s, c->dname, sizeof(s));
	} else {
          strlcpy(s, c->dname, sizeof(s));
	  i += (l + 2);
        }
      }
    }
  if (i > 10) {
    botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s  (%s)", s, ver);
  } else {
    botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s  (%s)", "no channels", ver);
  }
  if (admin[0])
    botnet_send_priv(idx, conf.bot->nick, nick, NULL, "Admin: %s", admin);
  if (chan == 0) {
    botnet_send_priv(idx, conf.bot->nick, nick, NULL,
		     "Party line members:  (^ = admin, * = owner, + = master, @ = op)");
  } else {
      botnet_send_priv(idx, conf.bot->nick, nick, NULL,
		       "People on channel %s%d:  (^ = admin, * = owner, + = master, @ = op)\n",
		       (chan < GLOBAL_CHANS) ? "" : "*",
		       chan % GLOBAL_CHANS);
  }
  for (i = 0; i < dcc_total; i++) {
    if (dcc[i].type && dcc[i].type->flags & DCT_REMOTEWHO) {
      if (dcc[i].u.chat->channel == chan) {
	k = simple_snprintf(s, sizeof(s), "  %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)),
		    dcc[i].nick, dcc[i].host);
	if (now - dcc[i].timeval > 300) {
	  unsigned long mydays, hrs, mins;

	  mydays = (now - dcc[i].timeval) / 86400;
	  hrs = ((now - dcc[i].timeval) - (mydays * 86400)) / 3600;
	  mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
	  if (mydays > 0)
	    simple_snprintf(s + k, sizeof(s) - k, " (idle %lud%luh)", mydays, hrs);
	  else if (hrs > 0)
	    simple_snprintf(s + k, sizeof(s) - k, " (idle %luh%lum)", hrs, mins);
	  else
	    simple_snprintf(s + k, sizeof(s) - k, " (idle %lum)", mins);
	}
	botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s", s);
	if (dcc[i].u.chat->away != NULL)
	  botnet_send_priv(idx, conf.bot->nick, nick, NULL, "      AWAY: %s", dcc[i].u.chat->away);
      }
    }
  }
  for (i = 0; i < dcc_total; i++) {
    if (dcc[i].type && dcc[i].type == &DCC_BOT) {
      if (!ok) {
	ok = 1;
	botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s:", "Bots connected");
      }
      simple_snprintf(s, sizeof(s), "  %s%c%-15s %s",
	      dcc[i].status & STAT_CALLED ? "<-" : "->",
	      dcc[i].status & STAT_SHARE ? '+' : ' ',
	      dcc[i].nick, dcc[i].u.bot->version);
      botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s", s);
    }
  }
  ok = 0;
  for (i = 0; i < dcc_total; i++) {
    if (dcc[i].type && dcc[i].type->flags & DCT_REMOTEWHO) {
      if (dcc[i].u.chat->channel != chan) {
	if (!ok) {
	  ok = 1;
	  botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s:", "Other people on the bot");
	}
	l = simple_snprintf(s, sizeof(s), "  %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick, dcc[i].host);
	if (now - dcc[i].timeval > 300) {
	  k = (now - dcc[i].timeval) / 60;
	  if (k < 60)
	    simple_snprintf(s + l, sizeof(s) - l, " (idle %dm)", k);
	  else
	    simple_snprintf(s + l, sizeof(s) - l, " (idle %dh%dm)", k / 60, k % 60);
	}
	botnet_send_priv(idx, conf.bot->nick, nick, NULL, "%s", s);
	if (dcc[i].u.chat->away != NULL)
	  botnet_send_priv(idx, conf.bot->nick, nick, NULL, "      AWAY: %s", dcc[i].u.chat->away);
      }
    }
  }
}
Ejemplo n.º 12
0
/* reject <from> <bot>
 */
static void bot_reject(int idx, char *par)
{
  char *from, *who, *destbot, *frombot;
  struct userrec *u;
  int i;

  if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
    return;
  from = newsplit(&par);
  frombot = strchr(from, '@');
  if (frombot)
    frombot++;
  else
    frombot = from;
  i = nextbot(frombot);
  if (i != idx) {
    fake_alert(idx, "direction", frombot);
    return;
  }
  who = newsplit(&par);
  if (!(destbot = strchr(who, '@'))) {
    /* Rejecting a bot */
    i = nextbot(who);
    if (i < 0) {
      botnet_send_priv(idx, botnetnick, from, NULL, "%s %s (%s)",
                       BOT_CANTUNLINK, who, BOT_DOESNTEXIST);
    } else if (!egg_strcasecmp(dcc[i].nick, who)) {
      char s[1024];

      /* I'm the connection to the rejected bot */
      putlog(LOG_BOTS, "*", "%s %s %s", from, MISC_REJECTED, dcc[i].nick);
      dprintf(i, "bye %s\n", par[0] ? par : MISC_REJECTED);
      simple_sprintf(s, "%s %s (%s: %s)",
                     MISC_DISCONNECTED, dcc[i].nick, from,
                     par[0] ? par : MISC_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 (!egg_strcasecmp(destbot, botnetnick)) {
      /* Kick someone here! */
      int ok = 0;

      if (remote_boots == 1) {
        frombot = strchr(from, '@');
        if (frombot == NULL)
          frombot = from;
        else
          frombot++;
        u = get_user_by_handle(userlist, frombot);
        if (!(bot_flags(u) & BOT_SHARE)) {
          add_note(from, botnetnick, "No non sharebot boots.", -1, 0);
          ok = 1;
        }
      } else if (remote_boots == 0) {
        botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOREMOTEBOOT);
        ok = 1;
      }
      for (i = 0; (i < dcc_total) && !ok; i++)
        if ((!egg_strcasecmp(who, dcc[i].nick)) &&
            (dcc[i].type->flags & DCT_CHAT)) {
          u = get_user_by_handle(userlist, dcc[i].nick);
          if (u && (u->flags & USER_OWNER)) {
            add_note(from, botnetnick, BOT_NOOWNERBOOT, -1, 0);
            return;
          }
          do_boot(i, from, par);
          ok = 1;
          putlog(LOG_CMDS, "*", "#%s# boot %s (%s)", from, who,
                 par[0] ? par : "No reason");
        }
    } else {
      i = nextbot(destbot);
      *--destbot = '@';
      if (i >= 0)
        botnet_send_reject(i, from, NULL, who, NULL, par);
    }
  }
}
Ejemplo n.º 13
0
static void remote_tell_who(int idx, char *nick, int chan)
{
  int i = 10, k, l, ok = 0;
  char s[1024], *realnick;
  struct chanset_t *c;

  realnick = strchr(nick, ':');
  if (realnick)
    realnick++;
  else
    realnick = nick;
  putlog(LOG_BOTS, "*", "#%s# who", realnick);
  strcpy(s, "Channels: ");
  for (c = chanset; c; c = c->next)
    if (!channel_secret(c) && !channel_inactive(c)) {
      l = strlen(c->dname);
      if (i + l < 1021) {
        if (i > 10)
          sprintf(s, "%s, %s", s, c->dname);
        else {
          strcpy(s, c->dname);
          i += (l + 2);
        }
      }
    }
  if (i > 10) {
    botnet_send_priv(idx, botnetnick, nick, NULL, "%s (%s)", s, ver);
  } else
    botnet_send_priv(idx, botnetnick, nick, NULL, "%s (%s)", BOT_NOCHANNELS,
                     ver);
  if (admin[0])
    botnet_send_priv(idx, botnetnick, nick, NULL, "Admin: %s", admin);
  if (chan == 0)
    botnet_send_priv(idx, botnetnick, nick, NULL, "%s (* = owner, + = master,"
                     " %% = botmaster, @ = op, ^ = halfop)", BOT_PARTYMEMBS);
  else {
    simple_sprintf(s, "assoc %d", chan);
    if ((Tcl_Eval(interp, s) != TCL_OK) || !interp->result[0])
      botnet_send_priv(idx, botnetnick, nick, NULL, "%s %s%d: (* = owner, + ="
                       " master, %% = botmaster, @ = op, ^ = halfop)\n",
                       BOT_PEOPLEONCHAN, (chan < GLOBAL_CHANS) ? "" : "*",
                       chan % GLOBAL_CHANS);
    else
      botnet_send_priv(idx, botnetnick, nick, NULL, "%s '%s' (%s%d): (* = "
                       "owner, + = master, %% = botmaster, @ = op, ^ = halfop)\n",
                       BOT_PEOPLEONCHAN, interp->result, (chan < GLOBAL_CHANS) ?
                       "" : "*", chan % GLOBAL_CHANS);
  }
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type->flags & DCT_REMOTEWHO)
      if (dcc[i].u.chat->channel == chan) {
        k = sprintf(s, "  %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)),
                    dcc[i].nick, dcc[i].host);
        if (now - dcc[i].timeval > 300) {
          unsigned long days, hrs, mins;

          days = (now - dcc[i].timeval) / 86400;
          hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
          mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
          if (days > 0)
            sprintf(s + k, " (%s %lud%luh)", MISC_IDLE, days, hrs);
          else if (hrs > 0)
            sprintf(s + k, " (%s %luh%lum)", MISC_IDLE, hrs, mins);
          else
            sprintf(s + k, " (%s %lum)", MISC_IDLE, mins);
        }
        botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
        if (dcc[i].u.chat->away != NULL)
          botnet_send_priv(idx, botnetnick, nick, NULL, "      %s: %s",
                           MISC_AWAY, dcc[i].u.chat->away);
      }
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type == &DCC_BOT) {
      if (!ok) {
        ok = 1;
        botnet_send_priv(idx, botnetnick, nick, NULL, "%s:", BOT_BOTSCONNECTED);
      }
      sprintf(s, "  %s%c%-15s %s",
              dcc[i].status & BSTAT_CALLED ? "<-" : "->",
              dcc[i].status & BSTAT_SHARE ? '+' : ' ',
              dcc[i].nick, dcc[i].u.bot->version);
      botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
    }
  ok = 0;
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type->flags & DCT_REMOTEWHO)
      if (dcc[i].u.chat->channel != chan) {
        if (!ok) {
          ok = 1;
          botnet_send_priv(idx, botnetnick, nick, NULL, "%s:", BOT_OTHERPEOPLE);
        }
        l = sprintf(s, "  %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)),
                    dcc[i].nick, dcc[i].host);
        if (now - dcc[i].timeval > 300) {
          k = (now - dcc[i].timeval) / 60;
          if (k < 60)
            sprintf(s + l, " (%s %dm)", MISC_IDLE, k);
          else
            sprintf(s + l, " (%s %dh%dm)", MISC_IDLE, k / 60, k % 60);
        }
        botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
        if (dcc[i].u.chat->away != NULL)
          botnet_send_priv(idx, botnetnick, nick, NULL,
                           "      %s: %s", MISC_AWAY, dcc[i].u.chat->away);
      }
}
Ejemplo n.º 14
0
/* priv <from> <to> <message>
 */
static void bot_priv(int idx, char *par)
{
  char *from, *p, *to = TBUF, *tobot;
  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);
    return;
  }
  if (!to[0])
    return; /* Silently ignore notes to '@bot' */
  if (!egg_strcasecmp(tobot, botnetnick)) { /* 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, botnetnick, from, NULL,
                           "%s %s.", BOT_NOSUCHUSER, to);
          break;
        case NOTE_STORED:
          botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOTESTORED2);
          break;
        case NOTE_FULL:
          botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOTEBOXFULL);
          break;
        case NOTE_AWAY:
          botnet_send_priv(idx, botnetnick, from, NULL,
                           "%s %s", to, BOT_NOTEISAWAY);
          break;
        case NOTE_FWD:
          botnet_send_priv(idx, botnetnick, from, NULL,
                           "%s %s", "Not online; note forwarded to:", to);
          break;
        case NOTE_REJECT:
          botnet_send_priv(idx, botnetnick, from, NULL,
                           "%s %s", to, "rejected your note.");
          break;
        case NOTE_TCL:
          break;                /* Do nothing */
        case NOTE_OK:
          botnet_send_priv(idx, botnetnick, from, NULL,
                           "%s %s.", BOT_NOTESENTTO, to);
          break;
        }
    }
  } else {                        /* Pass it on */
    i = nextbot(tobot);
    if (i >= 0)
      botnet_send_priv(i, from, to, tobot, "%s", par);
  }
}