コード例 #1
0
ファイル: botnet.c プロジェクト: Estella/eggdrop-1.4
static void eof_dcc_relay(int idx)
{
  register int j;
  struct chat_info *ci;

  for (j = 0; dcc[j].sock != dcc[idx].u.relay->sock; j++);
  dcc[j].status = dcc[j].u.relay->old_status;
  /* in case echo was off, turn it back on: */
  if (dcc[j].status & STAT_TELNET)
    dprintf(j, "\377\374\001\n");
  putlog(LOG_MISC, "*", "%s: %s -> %s", BOT_ENDRELAY1, dcc[j].nick,
	 dcc[idx].nick);
  dprintf(j, "\n\n*** %s %s\n", BOT_ENDRELAY2, botnetnick);
  ci = dcc[j].u.relay->chat;
  nfree(dcc[j].u.relay);
  dcc[j].u.chat = ci;
  dcc[j].type = &DCC_CHAT;
  if (dcc[j].u.chat->channel >= 0) {
    chanout_but(-1, dcc[j].u.chat->channel, "*** %s %s.\n",
		dcc[j].nick, BOT_PARTYREJOINED);
    Context;
    if (dcc[j].u.chat->channel < 100000)
      botnet_send_join_idx(j, -1);
  }
  check_tcl_chon(dcc[j].nick, dcc[j].sock);
  check_tcl_chjn(botnetnick, dcc[j].nick, dcc[j].u.chat->channel,
		 geticon(j), dcc[j].sock, dcc[j].host);
  killsock(dcc[idx].sock);
  lostdcc(idx);
}
コード例 #2
0
ファイル: geticon.c プロジェクト: mklab/gnuplot-android
int
main(int argc, char *argv[])
{
    if ((argc < 2) || (argc > 3)) {
	fprintf(stderr,"Usage:  geticon  resource_file [icon_directory]\n");
	return(1);
    }
    if ( (rcfile = fopen(argv[1],"r")) == (FILE *)NULL) {
	fprintf(stderr,"Can't open RC file\n");
	return(2);
    }
    line = 0;
    while (fgets(inputline,MAXLINE,rcfile)) {
        line++;
	tok1 = strtok(inputline," \t\r\n");
	tok2 = strtok(NULL," \t\r\n");
	tok3 = strtok(NULL," \t\r\n");
	if (tok2 && !strcmp(tok2,"ICON") && (tok3 == (char *)NULL)) {
            iconname[0] = '\0';
	    if (argc == 3) {
                strcpy(iconname,argv[2]);
                strcat(iconname,"\\");
            }
            strcat(iconname,tok1);
            strcat(iconname,".ico");
	    fprintf(stdout,"%s\n",iconname);
	    geticon();
	}
    }
    return 0;
}
コード例 #3
0
ファイル: tcldcc.c プロジェクト: Estella/eggdrop-1.7
static int tcl_setchan(ClientData cd, Tcl_Interp *irp,
                       int argc, char *argv[])
{
  int idx, chan;
  module_entry *me;

  BADARGS(3, 3, " idx channel");

  idx = findidx(atoi(argv[1]));
  if (idx < 0 || (dcc[idx].type != &DCC_CHAT &&
      dcc[idx].type != &DCC_SCRIPT)) {
    Tcl_AppendResult(irp, "invalid idx", NULL);
    return TCL_ERROR;
  }
  if (argv[2][0] < '0' || argv[2][0] > '9') {
    if (!strcmp(argv[2], "-1") || !egg_strcasecmp(argv[2], "off"))
      chan = -1;
    else {
      Tcl_SetVar(irp, "chan", argv[2], 0);
      if (Tcl_VarEval(irp, "assoc ", "$chan", NULL) != TCL_OK ||
          !interp->result[0]) {
        Tcl_AppendResult(irp, "channel name is invalid", NULL);
        return TCL_ERROR;
      }
      chan = atoi(interp->result);
    }
  } else
    chan = atoi(argv[2]);
  if ((chan < -1) || (chan > 199999)) {
    Tcl_AppendResult(irp, "channel out of range; must be -1 through 199999",
                     NULL);
    return TCL_ERROR;
  }
  if (dcc[idx].type == &DCC_SCRIPT)
    dcc[idx].u.script->u.chat->channel = chan;
  else {
    int oldchan = dcc[idx].u.chat->channel;

    if (dcc[idx].u.chat->channel >= 0) {
      if ((chan >= GLOBAL_CHANS) && (oldchan < GLOBAL_CHANS))
        botnet_send_part_idx(idx, "*script*");
      check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
                     dcc[idx].u.chat->channel);
    }
    dcc[idx].u.chat->channel = chan;
    if (chan < GLOBAL_CHANS)
      botnet_send_join_idx(idx, oldchan);
    check_tcl_chjn(botnetnick, dcc[idx].nick, chan, geticon(idx),
                   dcc[idx].sock, dcc[idx].host);
  }
  /* Console autosave. */
  if ((me = module_find("console", 1, 1))) {
    Function *func = me->funcs;

    (func[CONSOLE_DOSTORE]) (idx);
  }
  return TCL_OK;
}
コード例 #4
0
ファイル: wire.c プロジェクト: Protospace/protobot
static int cmd_onwire(struct userrec *u, int idx, char *par)
{
  wire_list *w, *w2;
  char wiretmp[512], wirecmd[512], idxtmp[512];
  char idle[20], *enctmp;
  time_t now2 = now;

  w = wirelist;
  while (w) {
    if (w->sock == dcc[idx].sock)
      break;
    w = w->next;
  }
  if (!w) {
    dprintf(idx, "%s\n", WIRE_NOTONWIRE);
    return 0;
  }
  dprintf(idx, "----- %s '%s':\n", WIRE_CURRENTLYON, w->key);
  dprintf(idx, "----- Nick       Bot        Host\n");
  dprintf(idx, "----- ---------- ---------- ------------------------------\n");
  enctmp = encrypt_string(w->key, "wire");
  sprintf(wirecmd, "!wire%s", enctmp);
  nfree(enctmp);
  enctmp = encrypt_string(w->key, dcc[idx].nick);
  strcpy(wiretmp, enctmp);
  nfree(enctmp);
  simple_sprintf(idxtmp, "!wirereq %d %s", dcc[idx].sock, wiretmp);
  botnet_send_zapf_broad(-1, botnetnick, wirecmd, idxtmp);
  w2 = wirelist;
  while (w2) {
    if (!strcmp(w2->key, w->key)) {
      int idx2 = findanyidx(w2->sock);

      if (now2 - dcc[idx2].timeval > 300) {
        unsigned long Days, hrs, mins;

        Days = (now2 - dcc[idx2].timeval) / 86400;
        hrs = ((now2 - dcc[idx2].timeval) - (Days * 86400)) / 3600;
        mins = ((now2 - dcc[idx2].timeval) - (hrs * 3600)) / 60;
        if (Days > 0)
          sprintf(idle, " [%s %lud%luh]", WIRE_IDLE, Days, hrs);
        else if (hrs > 0)
          sprintf(idle, " [%s %luh%lum]", WIRE_IDLE, hrs, mins);
        else
          sprintf(idle, " [%s %lum]", WIRE_IDLE, mins);
      } else
        idle[0] = 0;
      dprintf(idx, "----- %c%-9s %-9s  %s%s\n",
              geticon(idx2), dcc[idx2].nick, botnetnick, dcc[idx2].host, idle);
      if (dcc[idx2].u.chat->away)
        dprintf(idx, "-----    %s: %s\n", WIRE_AWAY, dcc[idx2].u.chat->away);
    }
    w2 = w2->next;
  }
  return 0;
}
コード例 #5
0
ファイル: botnet.c プロジェクト: Estella/eggdrop-1.4
void restart_chons()
{
  int i;

  /* dump party line members */
  Context;
  for (i = 0; i < dcc_total; i++) {
    if (dcc[i].type == &DCC_CHAT) {
      check_tcl_chon(dcc[i].nick, dcc[i].sock);
      check_tcl_chjn(botnetnick, dcc[i].nick, dcc[i].u.chat->channel,
		     geticon(i), dcc[i].sock, dcc[i].host);
    }
  }
  for (i = 0; i < parties; i++) {
    check_tcl_chjn(party[i].bot, party[i].nick, party[i].chan,
		   party[i].flag, party[i].sock, party[i].from);
  }
  Context;
}
コード例 #6
0
ファイル: dccutil.c プロジェクト: ArNz8o8/Fr3shness
void dcc_chatter(int idx)
{
  int i, j;
  struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };

  get_user_flagrec(dcc[idx].user, &fr, NULL);
  show_motd(idx);
  i = dcc[idx].u.chat->channel;
  dcc[idx].u.chat->channel = 234567;
  j = dcc[idx].sock;
  strcpy(dcc[idx].u.chat->con_chan, "***");
  check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
  /* Still there? */
  if ((idx >= dcc_total) || (dcc[idx].sock != j))
    return;                     /* Nope */
  /* Tcl script may have taken control */
  if (dcc[idx].type == &DCC_CHAT) {
    if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
      strcpy(dcc[idx].u.chat->con_chan, "*");
    if (dcc[idx].u.chat->channel == 234567) {
      /* If the chat channel has already been altered it's *highly*
       * probably join/part messages have been broadcast everywhere,
       * so dont bother sending them
       */
      if (i == -2)
        i = 0;
      dcc[idx].u.chat->channel = i;
      if ((dcc[idx].u.chat->channel >= 0) &&
          (dcc[idx].u.chat->channel < GLOBAL_CHANS))
        botnet_send_join_idx(idx, -1);
      check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
                     geticon(idx), dcc[idx].sock, dcc[idx].host);
    }
    /* But *do* bother with sending it locally */
    if (!dcc[idx].u.chat->channel) {
      chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick);
    } else if (dcc[idx].u.chat->channel > 0) {
      chanout_but(-1, dcc[idx].u.chat->channel,
                  "*** %s joined the channel.\n", dcc[idx].nick);
    }
  }
}
コード例 #7
0
ファイル: botnet.c プロジェクト: Estella/eggdrop-1.4
static void dcc_relaying(int idx, char *buf, int j)
{
  struct chat_info *ci;

  if (strcasecmp(buf, "*bye*")) {
    dprintf(-dcc[idx].u.relay->sock, "%s\n", buf);
    return;
  }
  for (j = 0; (dcc[j].sock != dcc[idx].u.relay->sock) ||
       (dcc[j].type != &DCC_RELAY); j++);
  dcc[idx].status = dcc[idx].u.relay->old_status;
  /* in case echo was off, turn it back on: */
  if (dcc[idx].status & STAT_TELNET)
    dprintf(idx, "\377\374\001\n");
  dprintf(idx, "\n(%s %s.)\n", BOT_BREAKRELAY, dcc[j].nick);
  dprintf(idx, "%s %s.\n\n", BOT_ABORTRELAY2, botnetnick);
  putlog(LOG_MISC, "*", "%s: %s -> %s", BOT_RELAYBROKEN,
	 dcc[idx].nick, dcc[j].nick);
  if (dcc[idx].u.relay->chat->channel >= 0) {
    chanout_but(-1, dcc[idx].u.relay->chat->channel,
		"*** %s joined the party line.\n", dcc[idx].nick);
    Context;
    if (dcc[idx].u.relay->chat->channel < 100000)
      botnet_send_join_idx(idx, -1);
  }
  ci = dcc[idx].u.relay->chat;
  nfree(dcc[idx].u.relay);
  dcc[idx].u.chat = ci;
  dcc[idx].type = &DCC_CHAT;
  check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
  if (dcc[idx].u.chat->channel >= 0)
    check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
		   geticon(idx), dcc[idx].sock, dcc[idx].host);
  killsock(dcc[j].sock);
  lostdcc(j);
}
コード例 #8
0
ファイル: botcmd.c プロジェクト: vap0r/wraith
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);
      }
    }
  }
}
コード例 #9
0
ファイル: tcldcc.c プロジェクト: Estella/eggdrop-1.7
static int tcl_whom(ClientData cd, Tcl_Interp *irp,
                    int argc, char *argv[])
{
  int chan, i;
  char c[2], idle[11], work[20], *p;
  long tv = 0;
  EGG_CONST char *list[7];

  BADARGS(2, 2, " chan");

  if (argv[1][0] == '*')
    chan = -1;
  else {
    if ((argv[1][0] < '0') || (argv[1][0] > '9')) {
      Tcl_SetVar(interp, "chan", argv[1], 0);
      if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) != TCL_OK) ||
          !interp->result[0]) {
        Tcl_AppendResult(irp, "channel name is invalid", NULL);
        return TCL_ERROR;
      }
      chan = atoi(interp->result);
    } else
      chan = atoi(argv[1]);
    if ((chan < 0) || (chan > 199999)) {
      Tcl_AppendResult(irp, "channel out of range; must be 0 through 199999",
                       NULL);
      return TCL_ERROR;
    }
  }
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type == &DCC_CHAT) {
      if (dcc[i].u.chat->channel == chan || chan == -1) {
        c[0] = geticon(i);
        c[1] = 0;
        tv = (now - dcc[i].timeval) / 60;
        egg_snprintf(idle, sizeof idle, "%li", tv);
        list[0] = dcc[i].nick;
        list[1] = botnetnick;
        list[2] = dcc[i].host;
        list[3] = c;
        list[4] = idle;
        list[5] = dcc[i].u.chat->away ? dcc[i].u.chat->away : "";
        if (chan == -1) {
          egg_snprintf(work, sizeof work, "%d", dcc[i].u.chat->channel);
          list[6] = work;
        }
        p = Tcl_Merge((chan == -1) ? 7 : 6, list);
        Tcl_AppendElement(irp, p);
        Tcl_Free((char *) p);
      }
    }
  for (i = 0; i < parties; i++) {
    if (party[i].chan == chan || chan == -1) {
      c[0] = party[i].flag;
      c[1] = 0;
      if (party[i].timer == 0L)
        strcpy(idle, "0");
      else {
        tv = (now - party[i].timer) / 60;
        egg_snprintf(idle, sizeof idle, "%li", tv);
      }
      list[0] = party[i].nick;
      list[1] = party[i].bot;
      list[2] = party[i].from ? party[i].from : "";
      list[3] = c;
      list[4] = idle;
      list[5] = party[i].status & PLSTAT_AWAY ? party[i].away : "";
      if (chan == -1) {
        egg_snprintf(work, sizeof work, "%d", party[i].chan);
        list[6] = work;
      }
      p = Tcl_Merge((chan == -1) ? 7 : 6, list);
      Tcl_AppendElement(irp, p);
      Tcl_Free((char *) p);
    }
  }
  return TCL_OK;
}
コード例 #10
0
ファイル: wire.c プロジェクト: Protospace/protobot
static void wire_filter(char *from, char *cmd, char *param)
{
  char wirecrypt[512];
  char wirewho[512];
  char wiretmp2[512];
  char wiretmp[512];
  char wirereq[512];
  wire_list *w = wirelist;
  char reqsock;
  time_t now2 = now;
  char idle[20];
  char *enctmp;

  strcpy(wirecrypt, &cmd[5]);
  strcpy(wiretmp, param);
  nsplit(wirereq, param);

/*
 * !wire<crypt"wire"> !wirereq <destbotsock> <crypt"destbotnick">
 * -----  wirecrypt    wirereq    wirewho         param
 */

  if (!strcmp(wirereq, "!wirereq")) {
    nsplit(wirewho, param);
    while (w) {
      if (!strcmp(w->crypt, wirecrypt)) {
        int idx = findanyidx(w->sock);

        reqsock = atoi(wirewho);
        if (now2 - dcc[idx].timeval > 300) {
          unsigned long Days, hrs, mins;

          Days = (now2 - dcc[idx].timeval) / 86400;
          hrs = ((now2 - dcc[idx].timeval) - (Days * 86400)) / 3600;
          mins = ((now2 - dcc[idx].timeval) - (hrs * 3600)) / 60;
          if (Days > 0)
            sprintf(idle, " [%s %lud%luh]", WIRE_IDLE, Days, hrs);
          else if (hrs > 0)
            sprintf(idle, " [%s %luh%lum]", WIRE_IDLE, hrs, mins);
          else
            sprintf(idle, " [%s %lum]", WIRE_IDLE, mins);
        } else
          idle[0] = 0;
        sprintf(wirereq, "----- %c%-9s %-9s  %s%s",
                geticon(idx), dcc[idx].nick, botnetnick, dcc[idx].host, idle);
        enctmp = encrypt_string(w->key, wirereq);
        strcpy(wiretmp, enctmp);
        nfree(enctmp);
        sprintf(wirereq, "zapf %s %s !wire%s !wireresp %s %s %s",
                botnetnick, from, wirecrypt, wirewho, param, wiretmp);
        dprintf(nextbot(from), "%s\n", wirereq);
        if (dcc[idx].u.chat->away) {
          sprintf(wirereq, "-----    %s: %s\n", WIRE_AWAY,
                  dcc[idx].u.chat->away);
          enctmp = encrypt_string(w->key, wirereq);
          strcpy(wiretmp, enctmp);
          nfree(enctmp);
          sprintf(wirereq, "zapf %s %s !wire%s !wireresp %s %s %s",
                  botnetnick, from, wirecrypt, wirewho, param, wiretmp);
          dprintf(nextbot(from), "%s\n", wirereq);
        }
      }
      w = w->next;
    }
    return;
  }
  if (!strcmp(wirereq, "!wireresp")) {
    nsplit(wirewho, param);
    reqsock = atoi(wirewho);
    w = wirelist;
    nsplit(wiretmp2, param);
    while (w) {
      if (w->sock == reqsock) {
        int idx = findanyidx(reqsock);

        enctmp = decrypt_string(w->key, wiretmp2);
        strcpy(wirewho, enctmp);
        nfree(enctmp);
        if (!strcmp(dcc[idx].nick, wirewho)) {
          enctmp = decrypt_string(w->key, param);
          dprintf(idx, "%s\n", enctmp);
          nfree(enctmp);
          return;
        }
      }
      w = w->next;
    }
    return;
  }
  while (w) {
    if (!strcmp(wirecrypt, w->crypt))
      wire_display(findanyidx(w->sock), w->key, wirereq, param);
    w = w->next;
  }
}
コード例 #11
0
ファイル: botcmd.c プロジェクト: Estella/eggdrop-1.7
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);
      }
}
コード例 #12
0
ファイル: botnet.c プロジェクト: Estella/eggdrop-1.4
/* dump list of links to a new bot */
void dump_links(int z)
{
  register int i, l;
  char x[1024];
  tand_t *bot;

  Context;
  for (bot = tandbot; bot; bot = bot->next) {
    char *p;

    if (bot->uplink == (tand_t *) 1)
      p = botnetnick;
    else
      p = bot->uplink->bot;
#ifndef NO_OLD_BOTNET
    if (b_numver(z) < NEAT_BOTNET)
      l = simple_sprintf(x, "nlinked %s %s %c%d\n", bot->bot,
			 p, bot->share, bot->ver);
    else
#endif
      l = simple_sprintf(x, "n %s %s %c%D\n", bot->bot, p,
			 bot->share, bot->ver);
    tputs(dcc[z].sock, x, l);
  }
  Context;
  if (!(bot_flags(dcc[z].user) & BOT_ISOLATE)) {
    /* dump party line members */
    for (i = 0; i < dcc_total; i++) {
      if (dcc[i].type == &DCC_CHAT) {
	if ((dcc[i].u.chat->channel >= 0) &&
	    (dcc[i].u.chat->channel < 100000)) {
#ifndef NO_OLD_BOTNET
	  if (b_numver(z) < NEAT_BOTNET)
	    l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
			       botnetnick, dcc[i].nick,
			       dcc[i].u.chat->channel, geticon(i),
			       dcc[i].sock, dcc[i].host);
	  else
#endif
	    l = simple_sprintf(x, "j !%s %s %D %c%D %s\n",
			       botnetnick, dcc[i].nick,
			       dcc[i].u.chat->channel, geticon(i),
			       dcc[i].sock, dcc[i].host);
	  tputs(dcc[z].sock, x, l);
#ifndef NO_OLD_BOTNET
	  if (b_numver(z) < NEAT_BOTNET) {
	    if (dcc[i].u.chat->away) {
	      l = simple_sprintf(x, "away %s %d %s\n", botnetnick,
				 dcc[i].sock, dcc[i].u.chat->away);
	      tputs(dcc[z].sock, x, l);
	    }
	    l = simple_sprintf(x, "idle %s %d %d\n", botnetnick,
			       dcc[i].sock, now - dcc[i].timeval);
	  } else
#endif
	    l = simple_sprintf(x, "i %s %D %D %s\n", botnetnick,
			       dcc[i].sock, now - dcc[i].timeval,
			 dcc[i].u.chat->away ? dcc[i].u.chat->away : "");
	  tputs(dcc[z].sock, x, l);
	}
      }
    }
    Context;
    for (i = 0; i < parties; i++) {
#ifndef NO_OLD_BOTNET
      if (b_numver(z) < NEAT_BOTNET)
	l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
			   party[i].bot, party[i].nick,
			   party[i].chan, party[i].flag,
			   party[i].sock, party[i].from);
      else
#endif
	l = simple_sprintf(x, "j %s %s %D %c%D %s\n",
			   party[i].bot, party[i].nick,
			   party[i].chan, party[i].flag,
			   party[i].sock, party[i].from);
      tputs(dcc[z].sock, x, l);
      if ((party[i].status & PLSTAT_AWAY) || (party[i].timer != 0)) {
#ifndef NO_OLD_BOTNET
	if (b_numver(z) < NEAT_BOTNET) {
	  if (party[i].status & PLSTAT_AWAY) {
	    l = simple_sprintf(x, "away %s %d %s\n", party[i].bot,
			       party[i].sock, party[i].away);
	    tputs(dcc[z].sock, x, l);
	  }
	  l = simple_sprintf(x, "idle %s %d %d\n", party[i].bot,
			     party[i].sock, now - party[i].timer);
	} else
#endif
	  l = simple_sprintf(x, "i %s %D %D %s\n", party[i].bot,
			     party[i].sock, now - party[i].timer,
			     party[i].away ? party[i].away : "");
	tputs(dcc[z].sock, x, l);
      }
    }
  }
  Context;
}
コード例 #13
0
ファイル: botnet.c プロジェクト: Estella/eggdrop-1.4
/* modern version of 'whom' (use local data) */
void answer_local_whom(int idx, int chan)
{
  char c, idle[40], spaces2[33] = "                               ";
  int i, len, len2;

  Context;
  if (chan == (-1))
    dprintf(idx, "%s (+: %s, *: %s)\n", BOT_BOTNETUSERS, BOT_PARTYLINE,
	    BOT_LOCALCHAN);
  else if (chan > 0) {
    simple_sprintf(idle, "assoc %d", chan);
    if ((Tcl_Eval(interp, idle) != TCL_OK) || !interp->result[0])
      dprintf(idx, "%s %s%d:\n", BOT_USERSONCHAN,
	      (chan < 100000) ? "" : "*", chan % 100000);
    else
      dprintf(idx, "%s '%s%s' (%s%d):\n", BOT_USERSONCHAN,
	      (chan < 100000) ? "" : "*", interp->result,
	      (chan < 100000) ? "" : "*", chan % 100000);
  }
  spaces[HANDLEN - 9] = 0;
  dprintf(idx, " Nick     %s   Bot      %s  Host\n", spaces, spaces);
  dprintf(idx, "----------%s   ---------%s  --------------------\n",
	  spaces, spaces);
  spaces[HANDLEN - 9] = ' ';
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type == &DCC_CHAT) {
      if ((chan == (-1)) || ((chan >= 0) && (dcc[i].u.chat->channel == chan))) {
	c = geticon(i);
	if (c == '-')
	  c = ' ';
	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(idle, " [idle %lud%luh]", days, hrs);
	  else if (hrs > 0)
	    sprintf(idle, " [idle %luh%lum]", hrs, mins);
	  else
	    sprintf(idle, " [idle %lum]", mins);
	} else
	  idle[0] = 0;
	spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
	spaces2[len2 = HANDLEN - strlen(botnetnick)] = 0;
	dprintf(idx, "%c%s%s %c %s%s  %s%s\n", c, dcc[i].nick, spaces,
		(dcc[i].u.chat->channel == 0) && (chan == (-1)) ? '+' :
		(dcc[i].u.chat->channel > 100000) &&
		(chan == (-1)) ? '*' : ' ',
		botnetnick, spaces2, dcc[i].host, idle);
	spaces[len] = ' ';
	spaces2[len2] = ' ';
	if (dcc[i].u.chat->away != NULL)
	  dprintf(idx, "   AWAY: %s\n", dcc[i].u.chat->away);
      }
    }
  for (i = 0; i < parties; i++) {
    if ((chan == (-1)) || ((chan >= 0) && (party[i].chan == chan))) {
      c = party[i].flag;
      if (c == '-')
	c = ' ';
      if (party[i].timer == 0L)
	strcpy(idle, " [idle?]");
      else if (now - party[i].timer > 300) {
	unsigned long days, hrs, mins;

	days = (now - party[i].timer) / 86400;
	hrs = ((now - party[i].timer) - (days * 86400)) / 3600;
	mins = ((now - party[i].timer) - (hrs * 3600)) / 60;
	if (days > 0)
	  sprintf(idle, " [idle %lud%luh]", days, hrs);
	else if (hrs > 0)
	  sprintf(idle, " [idle %luh%lum]", hrs, mins);
	else
	  sprintf(idle, " [idle %lum]", mins);
      } else
	idle[0] = 0;
      spaces[len = HANDLEN - strlen(party[i].nick)] = 0;
      spaces2[len2 = HANDLEN - strlen(party[i].bot)] = 0;
      dprintf(idx, "%c%s%s %c %s%s  %s%s\n", c, party[i].nick, spaces,
	      (party[i].chan == 0) && (chan == (-1)) ? '+' : ' ',
	      party[i].bot, spaces2, party[i].from, idle);
      spaces[len] = ' ';
      spaces2[len2] = ' ';
      if (party[i].status & PLSTAT_AWAY)
	dprintf(idx, "   %s: %s\n", MISC_AWAY, safe_str(party[i].away));
    }
  }
}