/* 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); }
/* 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); } } }
/* part <bot> <nick> <sock> [etc..] */ static void bot_part(int idx, char *par) { char *bot, *nick, *etc; struct userrec *u; int sock, partyidx; int silent = 0; if (bot_flags(dcc[idx].user) & BOT_ISOLATE) return; bot = newsplit(&par); if (bot[0] == '!') { silent = 1; bot++; } nick = newsplit(&par); etc = newsplit(&par); #ifndef NO_OLD_BOTNET if (dcc[idx].u.bot->numver < NEAT_BOTNET) { sock = atoi(etc); silent = 1; } else #endif sock = base64_to_int(etc); if (sock == 0) sock = partysock(bot, nick); u = get_user_by_handle(userlist, nick); if (u) { sprintf(TBUF, "@%s", bot); touch_laston(u, TBUF, now); } if ((partyidx = getparty(bot, sock)) != -1) { if (party[partyidx].chan >= 0) check_tcl_chpt(bot, nick, sock, party[partyidx].chan); if ((dcc[idx].u.bot->numver >= NEAT_BOTNET) && !silent) { register int chan = party[partyidx].chan; if (par[0]) chanout_but(-1, chan, "*** (%s) %s %s %s (%s).\n", bot, nick, NET_LEFTTHE, chan ? "channel" : "party line", par); else chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, NET_LEFTTHE, chan ? "channel" : "party line"); } botnet_send_part_party(idx, partyidx, par, silent); remparty(bot, sock); } }
/* away <bot> <sock> <message> * null message = unaway */ static void bot_away(int idx, char *par) { char *bot, *etc; int sock, partyidx, linking = 0; if (bot_flags(dcc[idx].user) & BOT_ISOLATE) return; bot = newsplit(&par); #ifndef NO_OLD_BOTNET if (dcc[idx].u.bot->numver >= NEAT_BOTNET) #endif if (bot[0] == '!') { linking = 1; bot++; } if (dcc[idx].status & BSTAT_LINKING) linking = 1; etc = newsplit(&par); #ifndef NO_OLD_BOTNET if (dcc[idx].u.bot->numver < NEAT_BOTNET) sock = atoi(etc); else #endif sock = base64_to_int(etc); if (sock == 0) sock = partysock(bot, etc); check_tcl_away(bot, sock, par); 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 ((dcc[idx].u.bot->numver >= NEAT_BOTNET) && !linking) { if (par[0]) chanout_but(-1, party[partyidx].chan, "*** (%s) %s %s: %s.\n", bot, party[partyidx].nick, NET_AWAY, par); else chanout_but(-1, party[partyidx].chan, "*** (%s) %s %s.\n", bot, party[partyidx].nick, NET_UNAWAY); } botnet_send_away(idx, bot, sock, par, linking); }