/* 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); } }
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; }
static void botnet_send_assoc(int idx, int chan, char *nick, char *buf) { char x[1024]; int idx2; simple_sprintf(x, "assoc %D %s %s", chan, nick, buf); for (idx2 = 0; idx2 < dcc_total; idx2++) if ((dcc[idx2].type == &DCC_BOT) && (idx2 != idx) && (b_numver(idx2) >= NEAT_BOTNET) && !(bot_flags(dcc[idx2].user) & BOT_ISOLATE)) botnet_send_zapf(idx2, botnetnick, dcc[idx2].nick, x); }
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); } } } }
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; }
/* 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); }