00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "main.h"
00028 #include "tandem.h"
00029 #include "users.h"
00030 #include "chan.h"
00031 #include "modules.h"
00032
00033 extern char botnetnick[], ver[], admin[], network[], motdfile[];
00034 extern int dcc_total, remote_boots, noshare;
00035 extern struct dcc_t *dcc;
00036 extern struct chanset_t *chanset;
00037 extern struct userrec *userlist;
00038 extern Tcl_Interp *interp;
00039 extern time_t now, online_since;
00040 extern party_t *party;
00041 extern module_entry *module_list;
00042
00043 static char TBUF[1024];
00044
00045 static char base64to[256] = {
00046 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00047 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00048 0, 0, 0, 0, 0, 0, 0, 0, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0,
00049 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
00050 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 62, 0, 63, 0, 0, 0, 26, 27, 28,
00051 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
00052 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00053 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00055 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00056 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00057 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00058 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00059 };
00060
00061
00062 int base64_to_int(char *buf)
00063 {
00064 int i = 0;
00065
00066 while (*buf) {
00067 i = i << 6;
00068 i += base64to[(int) *buf];
00069 buf++;
00070 }
00071 return i;
00072 }
00073
00074
00075
00076
00077 static int fakesock = 2300;
00078
00079 static void fake_alert(int idx, char *item, char *extra)
00080 {
00081 static unsigned long lastfake;
00082
00083 if (now - lastfake > 10) {
00084 #ifndef NO_OLD_BOTNET
00085 if (b_numver(idx) < NEAT_BOTNET)
00086 dprintf(idx, "chat %s NOTICE: %s (%s != %s).\n",
00087 botnetnick, NET_FAKEREJECT, item, extra);
00088 else
00089 #endif
00090 dprintf(idx, "ct %s NOTICE: %s (%s != %s).\n",
00091 botnetnick, NET_FAKEREJECT, item, extra);
00092 putlog(LOG_BOTS, "*", "%s %s (%s != %s).", dcc[idx].nick, NET_FAKEREJECT,
00093 item, extra);
00094 lastfake = now;
00095 }
00096 }
00097
00098
00099
00100 static void bot_chan2(int idx, char *msg)
00101 {
00102 char *from, *p, *s;
00103 int i, chan;
00104
00105 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
00106 return;
00107 from = newsplit(&msg);
00108 p = newsplit(&msg);
00109 #ifndef NO_OLD_BOTNET
00110 if (b_numver(idx) < NEAT_BOTNET)
00111 chan = atoi(p);
00112 else
00113 #endif
00114 chan = base64_to_int(p);
00115
00116 for (p = s = from; *s; s++)
00117 if ((*s > 31) && (*s != 127))
00118 *p++ = *s;
00119 if (*p)
00120 *p = 0;
00121 p = strchr(from, '@');
00122 if (p) {
00123 snprintf(TBUF, sizeof(TBUF), "<%s> %s", from, msg);
00124 *p = 0;
00125 if (!partyidle(p + 1, from)) {
00126 *p = '@';
00127 fake_alert(idx, "user", from);
00128 return;
00129 }
00130 *p = '@';
00131 p++;
00132 } else {
00133 sprintf(TBUF, "*** (%s) %s", from, msg);
00134 p = from;
00135 }
00136 i = nextbot(p);
00137 if (i != idx) {
00138 fake_alert(idx, "direction", p);
00139 } else {
00140 chanout_but(-1, chan, "%s\n", TBUF);
00141
00142 if (i >= 0)
00143 botnet_send_chan(idx, from, NULL, chan, msg);
00144 if (strchr(from, '@') != NULL)
00145 check_tcl_chat(from, chan, msg);
00146 else
00147 check_tcl_bcst(from, chan, msg);
00148 }
00149 }
00150
00151
00152
00153 static void bot_chat(int idx, char *par)
00154 {
00155 char *from;
00156 int i;
00157
00158 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
00159 return;
00160 from = newsplit(&par);
00161 if (strchr(from, '@') != NULL) {
00162 fake_alert(idx, "bot", from);
00163 return;
00164 }
00165
00166 i = nextbot(from);
00167 if (i != idx) {
00168 fake_alert(idx, "direction", from);
00169 return;
00170 }
00171 chatout("*** (%s) %s\n", from, par);
00172 botnet_send_chat(idx, from, par);
00173 check_tcl_bcst(from, -1, par);
00174 }
00175
00176
00177
00178 static void bot_actchan(int idx, char *par)
00179 {
00180 char *from, *p, *s;
00181 int i, chan;
00182
00183 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
00184 return;
00185 from = newsplit(&par);
00186 p = strchr(from, '@');
00187 if (p == NULL) {
00188
00189 fake_alert(idx, "user@bot", from);
00190 return;
00191 }
00192 *p = 0;
00193 if (!partyidle(p + 1, from)) {
00194 *p = '@';
00195 fake_alert(idx, "user", from);
00196 return;
00197 }
00198 *p = '@';
00199 p++;
00200 i = nextbot(p);
00201 if (i != idx) {
00202 fake_alert(idx, "direction", p);
00203 return;
00204 }
00205 p = newsplit(&par);
00206 #ifndef NO_OLD_BOTNET
00207 if (b_numver(idx) < NEAT_BOTNET)
00208 chan = atoi(p);
00209 else
00210 #endif
00211 chan = base64_to_int(p);
00212 for (p = s = from; *s; s++)
00213 if ((*s > 31) && (*s != 127))
00214 *p++ = *s;
00215 if (*p)
00216 *p = 0;
00217 chanout_but(-1, chan, "* %s %s\n", from, par);
00218 botnet_send_act(idx, from, NULL, chan, par);
00219 check_tcl_act(from, chan, par);
00220 }
00221
00222
00223
00224 static void bot_priv(int idx, char *par)
00225 {
00226 char *from, *p, *to = TBUF, *tobot;
00227 int i;
00228
00229 from = newsplit(&par);
00230 tobot = newsplit(&par);
00231 splitc(to, tobot, '@');
00232 p = strchr(from, '@');
00233 if (p != NULL)
00234 p++;
00235 else
00236 p = from;
00237 i = nextbot(p);
00238 if (i != idx) {
00239 fake_alert(idx, "direction", p);
00240 return;
00241 }
00242 if (!to[0])
00243 return;
00244 if (!egg_strcasecmp(tobot, botnetnick)) {
00245 if (p == from)
00246 add_note(to, from, par, -2, 0);
00247 else {
00248 i = add_note(to, from, par, -1, 0);
00249 if (from[0] != '@')
00250 switch (i) {
00251 case NOTE_ERROR:
00252 botnet_send_priv(idx, botnetnick, from, NULL,
00253 "%s %s.", BOT_NOSUCHUSER, to);
00254 break;
00255 case NOTE_STORED:
00256 botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOTESTORED2);
00257 break;
00258 case NOTE_FULL:
00259 botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOTEBOXFULL);
00260 break;
00261 case NOTE_AWAY:
00262 botnet_send_priv(idx, botnetnick, from, NULL,
00263 "%s %s", to, BOT_NOTEISAWAY);
00264 break;
00265 case NOTE_FWD:
00266 botnet_send_priv(idx, botnetnick, from, NULL,
00267 "%s %s", "Not online; note forwarded to:", to);
00268 break;
00269 case NOTE_REJECT:
00270 botnet_send_priv(idx, botnetnick, from, NULL,
00271 "%s %s", to, "rejected your note.");
00272 break;
00273 case NOTE_TCL:
00274 break;
00275 case NOTE_OK:
00276 botnet_send_priv(idx, botnetnick, from, NULL,
00277 "%s %s.", BOT_NOTESENTTO, to);
00278 break;
00279 }
00280 }
00281 } else {
00282 i = nextbot(tobot);
00283 if (i >= 0)
00284 botnet_send_priv(i, from, to, tobot, "%s", par);
00285 }
00286 }
00287
00288 static void bot_bye(int idx, char *par)
00289 {
00290 char s[1024];
00291 int users, bots;
00292
00293 bots = bots_in_subtree(findbot(dcc[idx].nick));
00294 users = users_in_subtree(findbot(dcc[idx].nick));
00295 simple_sprintf(s, "%s %s. %s (lost %d bot%s and %d user%s)",
00296 BOT_DISCONNECTED, dcc[idx].nick, par[0] ?
00297 par : "No reason", bots, (bots != 1) ?
00298 "s" : "", users, (users != 1) ? "s" : "");
00299 putlog(LOG_BOTS, "*", "%s", s);
00300 chatout("*** %s\n", s);
00301 botnet_send_unlinked(idx, dcc[idx].nick, s);
00302 dprintf(idx, "*bye\n");
00303 killsock(dcc[idx].sock);
00304 lostdcc(idx);
00305 }
00306
00307 static void remote_tell_who(int idx, char *nick, int chan)
00308 {
00309 int i = 10, k, l, ok = 0;
00310 char s[1024], *realnick;
00311 struct chanset_t *c;
00312
00313 realnick = strchr(nick, ':');
00314 if (realnick)
00315 realnick++;
00316 else
00317 realnick = nick;
00318 putlog(LOG_BOTS, "*", "#%s# who", realnick);
00319 strcpy(s, "Channels: ");
00320 for (c = chanset; c; c = c->next)
00321 if (!channel_secret(c) && !channel_inactive(c)) {
00322 l = strlen(c->dname);
00323 if (i + l < 1021) {
00324 if (i > 10)
00325 sprintf(s, "%s, %s", s, c->dname);
00326 else {
00327 strcpy(s, c->dname);
00328 i += (l + 2);
00329 }
00330 }
00331 }
00332 if (i > 10) {
00333 botnet_send_priv(idx, botnetnick, nick, NULL, "%s (%s)", s, ver);
00334 } else
00335 botnet_send_priv(idx, botnetnick, nick, NULL, "%s (%s)", BOT_NOCHANNELS,
00336 ver);
00337 if (admin[0])
00338 botnet_send_priv(idx, botnetnick, nick, NULL, "Admin: %s", admin);
00339 if (chan == 0)
00340 botnet_send_priv(idx, botnetnick, nick, NULL, "%s (* = owner, + = master,"
00341 " %% = botmaster, @ = op, ^ = halfop)", BOT_PARTYMEMBS);
00342 else {
00343 simple_sprintf(s, "assoc %d", chan);
00344 if ((Tcl_Eval(interp, s) != TCL_OK) || tcl_resultempty())
00345 botnet_send_priv(idx, botnetnick, nick, NULL, "%s %s%d: (* = owner, + ="
00346 " master, %% = botmaster, @ = op, ^ = halfop)\n",
00347 BOT_PEOPLEONCHAN, (chan < GLOBAL_CHANS) ? "" : "*",
00348 chan % GLOBAL_CHANS);
00349 else
00350 botnet_send_priv(idx, botnetnick, nick, NULL, "%s '%s' (%s%d): (* = "
00351 "owner, + = master, %% = botmaster, @ = op, ^ = halfop)\n",
00352 BOT_PEOPLEONCHAN, tcl_resultstring(), (chan < GLOBAL_CHANS) ?
00353 "" : "*", chan % GLOBAL_CHANS);
00354 }
00355 for (i = 0; i < dcc_total; i++)
00356 if (dcc[i].type->flags & DCT_REMOTEWHO)
00357 if (dcc[i].u.chat->channel == chan) {
00358 k = sprintf(s, " %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)),
00359 dcc[i].nick, dcc[i].host);
00360 if (now - dcc[i].timeval > 300) {
00361 unsigned long days, hrs, mins;
00362
00363 days = (now - dcc[i].timeval) / 86400;
00364 hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
00365 mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
00366 if (days > 0)
00367 sprintf(s + k, " (%s %lud%luh)", MISC_IDLE, days, hrs);
00368 else if (hrs > 0)
00369 sprintf(s + k, " (%s %luh%lum)", MISC_IDLE, hrs, mins);
00370 else
00371 sprintf(s + k, " (%s %lum)", MISC_IDLE, mins);
00372 }
00373 botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
00374 if (dcc[i].u.chat->away != NULL)
00375 botnet_send_priv(idx, botnetnick, nick, NULL, " %s: %s",
00376 MISC_AWAY, dcc[i].u.chat->away);
00377 }
00378 for (i = 0; i < dcc_total; i++)
00379 if (dcc[i].type == &DCC_BOT) {
00380 if (!ok) {
00381 ok = 1;
00382 botnet_send_priv(idx, botnetnick, nick, NULL, "%s:", BOT_BOTSCONNECTED);
00383 }
00384 sprintf(s, " %s%c%-15s %s",
00385 dcc[i].status & STAT_CALLED ? "<-" : "->",
00386 dcc[i].status & STAT_SHARE ? '+' : ' ',
00387 dcc[i].nick, dcc[i].u.bot->version);
00388 botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
00389 }
00390 ok = 0;
00391 for (i = 0; i < dcc_total; i++)
00392 if (dcc[i].type->flags & DCT_REMOTEWHO)
00393 if (dcc[i].u.chat->channel != chan) {
00394 if (!ok) {
00395 ok = 1;
00396 botnet_send_priv(idx, botnetnick, nick, NULL, "%s:", BOT_OTHERPEOPLE);
00397 }
00398 l = sprintf(s, " %c%-15s %s", (geticon(i) == '-' ? ' ' : geticon(i)),
00399 dcc[i].nick, dcc[i].host);
00400 if (now - dcc[i].timeval > 300) {
00401 k = (now - dcc[i].timeval) / 60;
00402 if (k < 60)
00403 sprintf(s + l, " (%s %dm)", MISC_IDLE, k);
00404 else
00405 sprintf(s + l, " (%s %dh%dm)", MISC_IDLE, k / 60, k % 60);
00406 }
00407 botnet_send_priv(idx, botnetnick, nick, NULL, "%s", s);
00408 if (dcc[i].u.chat->away != NULL)
00409 botnet_send_priv(idx, botnetnick, nick, NULL,
00410 " %s: %s", MISC_AWAY, dcc[i].u.chat->away);
00411 }
00412 }
00413
00414
00415
00416 static void bot_who(int idx, char *par)
00417 {
00418 char *from, *to, *p;
00419 int i, chan;
00420
00421 from = newsplit(&par);
00422 p = strchr(from, '@');
00423 if (!p) {
00424 sprintf(TBUF, "%s@%s", from, dcc[idx].nick);
00425 from = TBUF;
00426 }
00427 to = newsplit(&par);
00428 if (!egg_strcasecmp(to, botnetnick))
00429 to[0] = 0;
00430 #ifndef NO_OLD_BOTNET
00431 if (b_numver(idx) < NEAT_BOTNET)
00432 chan = atoi(par);
00433 else
00434 #endif
00435 chan = base64_to_int(par);
00436 if (to[0]) {
00437 i = nextbot(to);
00438 if (i >= 0)
00439 botnet_send_who(i, from, to, chan);
00440 } else
00441 remote_tell_who(idx, from, chan);
00442 }
00443
00444 static void bot_endlink(int idx, char *par)
00445 {
00446 dcc[idx].status &= ~STAT_LINKING;
00447 }
00448
00449
00450
00451 static void bot_infoq(int idx, char *par)
00452 {
00453 char s[200], s2[32], *realnick;
00454 struct chanset_t *chan;
00455 time_t now2;
00456 int hr, min;
00457
00458
00459 realnick = strchr(par, ':');
00460 if (realnick)
00461 realnick++;
00462 else
00463 realnick = par;
00464 putlog(LOG_BOTS, "*", "#%s# botinfo", realnick);
00465
00466 now2 = now - online_since;
00467 s2[0] = 0;
00468 if (now2 > 86400) {
00469 int days = now2 / 86400;
00470
00471
00472 sprintf(s2, "%d day", days);
00473 if (days >= 2)
00474 strcat(s2, "s");
00475 strcat(s2, ", ");
00476 now2 -= days * 86400;
00477 }
00478 hr = (time_t) ((int) now2 / 3600);
00479 now2 -= (hr * 3600);
00480 min = (time_t) ((int) now2 / 60);
00481 sprintf(&s2[strlen(s2)], "%02d:%02d", (int) hr, (int) min);
00482 if (module_find("server", 0, 0)) {
00483 s[0] = 0;
00484 for (chan = chanset; chan; chan = chan->next) {
00485 if (!channel_secret(chan)) {
00486 if ((strlen(s) + strlen(chan->dname) + strlen(network)
00487 + strlen(botnetnick) + strlen(ver) + 1) >= 200) {
00488 strcat(s, "++ ");
00489 break;
00490 }
00491 strcat(s, chan->dname);
00492 strcat(s, ", ");
00493 }
00494 }
00495 if (s[0]) {
00496 s[strlen(s) - 2] = 0;
00497 botnet_send_priv(idx, botnetnick, par, NULL,
00498 "%s <%s> (%s) [UP %s]", ver, network, s, s2);
00499 } else
00500 botnet_send_priv(idx, botnetnick, par, NULL, "%s <%s> (%s) [UP %s]", ver,
00501 network, BOT_NOCHANNELS, s2);
00502 } else
00503 botnet_send_priv(idx, botnetnick, par, NULL,
00504 "%s <NO_IRC> [UP %s]", ver, s2);
00505 botnet_send_infoq(idx, par);
00506 }
00507
00508 static void bot_ping(int idx, char *par)
00509 {
00510 botnet_send_pong(idx);
00511 }
00512
00513 static void bot_pong(int idx, char *par)
00514 {
00515 dcc[idx].status &= ~STAT_PINGED;
00516 }
00517
00518
00519
00520 static void bot_link(int idx, char *par)
00521 {
00522 char *from, *bot, *rfrom;
00523 int i;
00524
00525 from = newsplit(&par);
00526 bot = newsplit(&par);
00527
00528 if (!egg_strcasecmp(bot, botnetnick)) {
00529 if ((rfrom = strchr(from, ':')))
00530 rfrom++;
00531 else
00532 rfrom = from;
00533 putlog(LOG_CMDS, "*", "#%s# link %s", rfrom, par);
00534 if (botlink(from, -1, par))
00535 botnet_send_priv(idx, botnetnick, from, NULL, "%s %s ...",
00536 BOT_LINKATTEMPT, par);
00537 else
00538 botnet_send_priv(idx, botnetnick, from, NULL, "%s.", BOT_CANTLINKTHERE);
00539 } else {
00540 i = nextbot(bot);
00541 if (i >= 0)
00542 botnet_send_link(i, from, bot, par);
00543 }
00544 }
00545
00546
00547
00548 static void bot_unlink(int idx, char *par)
00549 {
00550 char *from, *bot, *rfrom, *p, *undes;
00551 int i;
00552
00553 from = newsplit(&par);
00554 bot = newsplit(&par);
00555 undes = newsplit(&par);
00556 if (!egg_strcasecmp(bot, botnetnick)) {
00557 if ((rfrom = strchr(from, ':')))
00558 rfrom++;
00559 else
00560 rfrom = from;
00561 putlog(LOG_CMDS, "*", "#%s# unlink %s (%s)", rfrom, undes, par[0] ? par :
00562 "No reason");
00563 i = botunlink(-3, undes, par[0] ? par : NULL, rfrom);
00564 if (i == 1) {
00565 p = strchr(from, '@');
00566 if (p) {
00567
00568
00569
00570
00571
00572 i = nextbot(p + 1);
00573 if (i >= 0)
00574 botnet_send_priv(i, botnetnick, from, NULL,
00575 "Unlinked from %s.", undes);
00576 }
00577 } else if (i == 0) {
00578 botnet_send_unlinked(-1, undes, "");
00579 p = strchr(from, '@');
00580 if (p) {
00581
00582 i = nextbot(p + 1);
00583 if (i >= 0)
00584 botnet_send_priv(i, botnetnick, from, NULL,
00585 "%s %s.", BOT_CANTUNLINK, undes);
00586 }
00587 } else {
00588 p = strchr(from, '@');
00589 if (p) {
00590 i = nextbot(p + 1);
00591 if (i >= 0)
00592 botnet_send_priv(i, botnetnick, from, NULL,
00593 "Can't remotely unlink sharebots.");
00594 }
00595 }
00596 } else {
00597 i = nextbot(bot);
00598 if (i >= 0)
00599 botnet_send_unlink(i, from, bot, undes, par);
00600 }
00601 }
00602
00603
00604
00605 static void bot_update(int idx, char *par)
00606 {
00607 char *bot, x;
00608 int vnum;
00609
00610 bot = newsplit(&par);
00611 x = par[0];
00612 if (x)
00613 par++;
00614 #ifndef NO_OLD_BOTNET
00615 if (b_numver(idx) < NEAT_BOTNET)
00616 vnum = atoi(par);
00617 else
00618 #endif
00619 vnum = base64_to_int(par);
00620 if (in_chain(bot))
00621 updatebot(idx, bot, x, vnum);
00622 }
00623
00624
00625
00626 static void bot_nlinked(int idx, char *par)
00627 {
00628 char *newbot, *next, *p, s[1024], x;
00629 int bogus = 0, i;
00630 struct userrec *u;
00631
00632 newbot = newsplit(&par);
00633 next = newsplit(&par);
00634 s[0] = 0;
00635 if (!next[0]) {
00636 putlog(LOG_BOTS, "*", "Invalid eggnet protocol from %s (zapfing)",
00637 dcc[idx].nick);
00638 simple_sprintf(s, "%s %s (%s)", MISC_DISCONNECTED, dcc[idx].nick,
00639 MISC_INVALIDBOT);
00640 dprintf(idx, "error invalid eggnet protocol for 'nlinked'\n");
00641 } else if ((in_chain(newbot)) || (!egg_strcasecmp(newbot, botnetnick))) {
00642
00643 putlog(LOG_BOTS, "*", "%s %s (mutual: %s)",
00644 BOT_LOOPDETECT, dcc[idx].nick, newbot);
00645 simple_sprintf(s, "%s %s: disconnecting %s", MISC_LOOP, newbot,
00646 dcc[idx].nick);
00647 dprintf(idx, "error Loop (%s)\n", newbot);
00648 }
00649 if (!s[0]) {
00650 for (p = newbot; *p; p++)
00651 if ((*p < 32) || (*p == 127) || ((p - newbot) >= HANDLEN))
00652 bogus = 1;
00653 i = nextbot(next);
00654 if (i != idx)
00655 bogus = 1;
00656 }
00657 if (bogus) {
00658 putlog(LOG_BOTS, "*", "%s %s! (%s -> %s)", BOT_BOGUSLINK, dcc[idx].nick,
00659 next, newbot);
00660 simple_sprintf(s, "%s: %s %s", BOT_BOGUSLINK, dcc[idx].nick,
00661 MISC_DISCONNECTED);
00662 dprintf(idx, "error %s (%s -> %s)\n", BOT_BOGUSLINK, next, newbot);
00663 }
00664 if (bot_flags(dcc[idx].user) & BOT_LEAF) {
00665 putlog(LOG_BOTS, "*", "%s %s (%s %s)",
00666 BOT_DISCONNLEAF, dcc[idx].nick, newbot, BOT_LINKEDTO);
00667 simple_sprintf(s, "%s %s (to %s): %s",
00668 BOT_ILLEGALLINK, dcc[idx].nick, newbot, MISC_DISCONNECTED);
00669 dprintf(idx, "error %s\n", BOT_YOUREALEAF);
00670 }
00671 if (s[0]) {
00672 chatout("*** %s\n", s);
00673 botnet_send_unlinked(idx, dcc[idx].nick, s);
00674 dprintf(idx, "bye %s\n", BOT_ILLEGALLINK);
00675 killsock(dcc[idx].sock);
00676 lostdcc(idx);
00677 return;
00678 }
00679 x = par[0];
00680 if (x)
00681 par++;
00682 else
00683 x = '-';
00684 #ifndef NO_OLD_BOTNET
00685 if (b_numver(idx) < NEAT_BOTNET)
00686 i = atoi(par);
00687 else
00688 #endif
00689 i = base64_to_int(par);
00690 botnet_send_nlinked(idx, newbot, next, x, i);
00691 if (x == '!') {
00692 chatout("*** (%s) %s %s.\n", next, NET_LINKEDTO, newbot);
00693 x = '-';
00694 }
00695 addbot(newbot, dcc[idx].nick, next, x, i);
00696 check_tcl_link(newbot, next);
00697 u = get_user_by_handle(userlist, newbot);
00698 if (bot_flags(u) & BOT_REJECT) {
00699 botnet_send_reject(idx, botnetnick, NULL, newbot, NULL, NULL);
00700 putlog(LOG_BOTS, "*", "%s %s %s %s", BOT_REJECTING,
00701 newbot, MISC_FROM, dcc[idx].nick);
00702 }
00703 }
00704
00705 #ifndef NO_OLD_BOTNET
00706 static void bot_linked(int idx, char *par)
00707 {
00708 char s[1024];
00709 int bots, users;
00710
00711 bots = bots_in_subtree(findbot(dcc[idx].nick));
00712 users = users_in_subtree(findbot(dcc[idx].nick));
00713 putlog(LOG_BOTS, "*", "%s", BOT_OLDBOT);
00714 simple_sprintf(s, "%s %s (%s) (lost %d bot%s and %d user%s",
00715 MISC_DISCONNECTED, dcc[idx].nick, MISC_OUTDATED,
00716 bots, (bots != 1) ? "s" : "", users, (users != 1) ? "s" : "");
00717 chatout("*** %s\n", s);
00718 botnet_send_unlinked(idx, dcc[idx].nick, s);
00719 killsock(dcc[idx].sock);
00720 lostdcc(idx);
00721 }
00722 #endif
00723
00724 static void bot_unlinked(int idx, char *par)
00725 {
00726 int i;
00727 char *bot;
00728
00729 bot = newsplit(&par);
00730 i = nextbot(bot);
00731 if ((i >= 0) && (i != idx))
00732
00733 fake_alert(idx, "direction", bot);
00734 else if (i >= 0) {
00735 if (par[0])
00736 chatout("*** (%s) %s\n", lastbot(bot), par);
00737 botnet_send_unlinked(idx, bot, par);
00738 unvia(idx, findbot(bot));
00739 rembot(bot);
00740 }
00741
00742 }
00743
00744
00745
00746 static void bot_trace(int idx, char *par)
00747 {
00748 char *from, *dest;
00749 int i;
00750
00751 from = newsplit(&par);
00752 dest = newsplit(&par);
00753 simple_sprintf(TBUF, "%s:%s", par, botnetnick);
00754 botnet_send_traced(idx, from, TBUF);
00755 if (egg_strcasecmp(dest, botnetnick) && ((i = nextbot(dest)) > 0))
00756 botnet_send_trace(i, from, dest, par);
00757 }
00758
00759
00760
00761 static void bot_traced(int idx, char *par)
00762 {
00763 char *to, *p;
00764 int i, sock;
00765
00766 to = newsplit(&par);
00767 p = strchr(to, '@');
00768 if (p == NULL)
00769 p = to;
00770 else {
00771 *p = 0;
00772 p++;
00773 }
00774 if (!egg_strcasecmp(p, botnetnick)) {
00775 time_t t = 0;
00776 char *p = par, *ss = TBUF;
00777
00778 splitc(ss, to, ':');
00779 if (ss[0])
00780 sock = atoi(ss);
00781 else
00782 sock = -1;
00783 if (par[0] == ':') {
00784 t = atoi(par + 1);
00785 p = strchr(par + 1, ':');
00786 if (p)
00787 p++;
00788 else
00789 p = par + 1;
00790 }
00791 for (i = 0; i < dcc_total; i++)
00792 if ((dcc[i].type->flags & DCT_CHAT) &&
00793 (!egg_strcasecmp(dcc[i].nick, to)) &&
00794 ((sock == -1) || (sock == dcc[i].sock))) {
00795 if (t) {
00796 int j = 0;
00797
00798 {
00799 register char *c = p;
00800
00801 for (; *c != '\0'; c++)
00802 if (*c == ':')
00803 j++;
00804 }
00805 dprintf(i, "%s -> %s (%lu secs, %d hop%s)\n", BOT_TRACERESULT, p,
00806 now - t, j, (j != 1) ? "s" : "");
00807 } else
00808 dprintf(i, "%s -> %s\n", BOT_TRACERESULT, p);
00809 }
00810 } else {
00811 i = nextbot(p);
00812 if (p != to)
00813 *--p = '@';
00814 if (i >= 0)
00815 botnet_send_traced(i, to, par);
00816 }
00817 }
00818
00819
00820
00821 static void bot_reject(int idx, char *par)
00822 {
00823 char *from, *who, *destbot, *frombot;
00824 struct userrec *u;
00825 int i;
00826
00827 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
00828 return;
00829 from = newsplit(&par);
00830 frombot = strchr(from, '@');
00831 if (frombot)
00832 frombot++;
00833 else
00834 frombot = from;
00835 i = nextbot(frombot);
00836 if (i != idx) {
00837 fake_alert(idx, "direction", frombot);
00838 return;
00839 }
00840 who = newsplit(&par);
00841 if (!(destbot = strchr(who, '@'))) {
00842
00843 i = nextbot(who);
00844 if (i < 0) {
00845 botnet_send_priv(idx, botnetnick, from, NULL, "%s %s (%s)",
00846 BOT_CANTUNLINK, who, BOT_DOESNTEXIST);
00847 } else if (!egg_strcasecmp(dcc[i].nick, who)) {
00848 char s[1024];
00849
00850
00851 putlog(LOG_BOTS, "*", "%s %s %s", from, MISC_REJECTED, dcc[i].nick);
00852 dprintf(i, "bye %s\n", par[0] ? par : MISC_REJECTED);
00853 simple_sprintf(s, "%s %s (%s: %s)",
00854 MISC_DISCONNECTED, dcc[i].nick, from,
00855 par[0] ? par : MISC_REJECTED);
00856 chatout("*** %s\n", s);
00857 botnet_send_unlinked(i, dcc[i].nick, s);
00858 killsock(dcc[i].sock);
00859 lostdcc(i);
00860 } else {
00861 if (i >= 0)
00862 botnet_send_reject(i, from, NULL, who, NULL, par);
00863 }
00864 } else {
00865 *destbot++ = 0;
00866 if (!egg_strcasecmp(destbot, botnetnick)) {
00867
00868 int ok = 0;
00869
00870 if (remote_boots == 1) {
00871 frombot = strchr(from, '@');
00872 if (frombot == NULL)
00873 frombot = from;
00874 else
00875 frombot++;
00876 u = get_user_by_handle(userlist, frombot);
00877 if (!(bot_flags(u) & BOT_SHARE)) {
00878 add_note(from, botnetnick, "No non sharebot boots.", -1, 0);
00879 ok = 1;
00880 }
00881 } else if (remote_boots == 0) {
00882 botnet_send_priv(idx, botnetnick, from, NULL, "%s", BOT_NOREMOTEBOOT);
00883 ok = 1;
00884 }
00885 for (i = 0; (i < dcc_total) && (!ok); i++)
00886 if ((!egg_strcasecmp(who, dcc[i].nick)) &&
00887 (dcc[i].type->flags & DCT_CHAT)) {
00888 u = get_user_by_handle(userlist, dcc[i].nick);
00889 if (u && (u->flags & USER_OWNER)) {
00890 add_note(from, botnetnick, BOT_NOOWNERBOOT, -1, 0);
00891 return;
00892 }
00893 do_boot(i, from, par);
00894 ok = 1;
00895 putlog(LOG_CMDS, "*", "#%s# boot %s (%s)", from, who,
00896 par[0] ? par : "No reason");
00897 }
00898 } else {
00899 i = nextbot(destbot);
00900 *--destbot = '@';
00901 if (i >= 0)
00902 botnet_send_reject(i, from, NULL, who, NULL, par);
00903 }
00904 }
00905 }
00906
00907 static void bot_thisbot(int idx, char *par)
00908 {
00909 if (egg_strcasecmp(par, dcc[idx].nick)) {
00910 char s[1024];
00911
00912 putlog(LOG_BOTS, "*", NET_WRONGBOT, dcc[idx].nick, par);
00913 dprintf(idx, "bye %s\n", MISC_IMPOSTER);
00914 simple_sprintf(s, "%s %s (%s)", MISC_DISCONNECTED, dcc[idx].nick,
00915 MISC_IMPOSTER);
00916 chatout("*** %s\n", s);
00917 botnet_send_unlinked(idx, dcc[idx].nick, s);
00918 unvia(idx, findbot(dcc[idx].nick));
00919 killsock(dcc[idx].sock);
00920 lostdcc(idx);
00921 return;
00922 }
00923 if (bot_flags(dcc[idx].user) & BOT_LEAF)
00924 dcc[idx].status |= STAT_LEAF;
00925
00926 noshare = 1;
00927 change_handle(dcc[idx].user, par);
00928 noshare = 0;
00929 strcpy(dcc[idx].nick, par);
00930 }
00931
00932 static void bot_handshake(int idx, char *par)
00933 {
00934 struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick);
00935
00936
00937 noshare = 1;
00938 set_user(&USERENTRY_PASS, u, par);
00939 noshare = 0;
00940 }
00941
00942
00943
00944
00945 static void bot_zapf(int idx, char *par)
00946 {
00947 char *from, *to;
00948 int i;
00949
00950 from = newsplit(&par);
00951 to = newsplit(&par);
00952 i = nextbot(from);
00953 if (i != idx) {
00954 fake_alert(idx, "direction", from);
00955 return;
00956 }
00957 if (!egg_strcasecmp(to, botnetnick)) {
00958
00959 char *opcode;
00960
00961 opcode = newsplit(&par);
00962 check_tcl_bot(from, opcode, par);
00963 return;
00964 }
00965 i = nextbot(to);
00966 if (i >= 0)
00967 botnet_send_zapf(i, from, to, par);
00968 }
00969
00970
00971
00972
00973 static void bot_zapfbroad(int idx, char *par)
00974 {
00975 char *from, *opcode;
00976 int i;
00977
00978 from = newsplit(&par);
00979 opcode = newsplit(&par);
00980
00981 i = nextbot(from);
00982 if (i != idx) {
00983 fake_alert(idx, "direction", from);
00984 return;
00985 }
00986 check_tcl_bot(from, opcode, par);
00987 botnet_send_zapf_broad(idx, from, opcode, par);
00988 }
00989
00990
00991
00992 static void bot_motd(int idx, char *par)
00993 {
00994 FILE *vv;
00995 char *s = TBUF, *who, *p;
00996 int i;
00997 struct flag_record fr = { FR_BOT, USER_BOT, 0, 0, 0, 0 };
00998
00999 who = newsplit(&par);
01000 if (!par[0] || !egg_strcasecmp(par, botnetnick)) {
01001 int irc = 0;
01002
01003 p = strchr(who, ':');
01004 if (p)
01005 p++;
01006 else
01007 p = who;
01008 if (who[0] == '!') {
01009 irc = HELP_IRC;
01010 fr.global |=USER_HIGHLITE;
01011
01012 who++;
01013 } else if (who[0] == '#') {
01014 fr.global |=USER_HIGHLITE;
01015
01016 who++;
01017 }
01018 putlog(LOG_CMDS, "*", "#%s# motd", p);
01019 vv = fopen(motdfile, "r");
01020 if (vv != NULL) {
01021 botnet_send_priv(idx, botnetnick, who, NULL, "--- %s\n", MISC_MOTDFILE);
01022 help_subst(NULL, NULL, 0, irc, NULL);
01023 while (!feof(vv)) {
01024 fgets(s, 120, vv);
01025 if (!feof(vv)) {
01026 if (s[strlen(s) - 1] == '\n')
01027 s[strlen(s) - 1] = 0;
01028 if (!s[0])
01029 strcpy(s, " ");
01030 help_subst(s, who, &fr, HELP_DCC, dcc[idx].nick);
01031 if (s[0])
01032 botnet_send_priv(idx, botnetnick, who, NULL, "%s", s);
01033 }
01034 }
01035 fclose(vv);
01036 } else
01037 botnet_send_priv(idx, botnetnick, who, NULL, "%s :(", MISC_NOMOTDFILE);
01038 } else {
01039
01040 i = nextbot(par);
01041 if (i >= 0)
01042 botnet_send_motd(i, who, par);
01043 }
01044 }
01045
01046
01047
01048
01049
01050
01051 static void bot_filereject(int idx, char *par)
01052 {
01053 char *path, *to, *tobot, *p;
01054 int i;
01055
01056 path = newsplit(&par);
01057 to = newsplit(&par);
01058 if ((tobot = strchr(to, '@')))
01059 tobot++;
01060 else
01061 tobot = to;
01062 if (egg_strcasecmp(tobot, botnetnick)) {
01063 p = strchr(to, ':');
01064 if (p != NULL) {
01065 *p = 0;
01066 for (i = 0; i < dcc_total; i++) {
01067 if (dcc[i].sock == atoi(to))
01068 dprintf(i, "%s (%s): %s\n", BOT_XFERREJECTED, path, par);
01069 }
01070 *p = ':';
01071 }
01072
01073 putlog(LOG_FILES, "*", "%s %s: %s", path, MISC_REJECTED, par);
01074 } else {
01075 i = nextbot(tobot);
01076 if (i >= 0)
01077 botnet_send_filereject(i, path, to, par);
01078 }
01079 }
01080
01081
01082
01083 static void bot_filereq(int idx, char *tobot)
01084 {
01085 char *from, *path;
01086 int i;
01087
01088 from = newsplit(&tobot);
01089 if ((path = strchr(tobot, ':'))) {
01090 *path++ = 0;
01091
01092 if (!egg_strcasecmp(tobot, botnetnick)) {
01093
01094 module_entry *fs = module_find("filesys", 0, 0);
01095
01096 if (fs == NULL)
01097 botnet_send_priv(idx, botnetnick, from, NULL, MOD_NOFILESYSMOD);
01098 else {
01099 Function f = fs->funcs[FILESYS_REMOTE_REQ];
01100
01101 f(idx, from, path);
01102 }
01103 } else {
01104 i = nextbot(tobot);
01105 if (i >= 0)
01106 botnet_send_filereq(i, from, tobot, path);
01107 }
01108 }
01109 }
01110
01111
01112
01113 static void bot_filesend(int idx, char *par)
01114 {
01115 char *botpath, *to, *tobot, *nick;
01116 int i;
01117 char *nfn;
01118
01119 botpath = newsplit(&par);
01120 to = newsplit(&par);
01121 if ((tobot = strchr(to, '@'))) {
01122 *tobot = 0;
01123 tobot++;
01124 } else
01125 tobot = to;
01126 if (!egg_strcasecmp(tobot, botnetnick)) {
01127 nfn = strrchr(botpath, '/');
01128 if (nfn == NULL) {
01129 nfn = strrchr(botpath, ':');
01130 if (nfn == NULL)
01131 nfn = botpath;
01132 else
01133 nfn++;
01134 } else
01135 nfn++;
01136 if ((nick = strchr(to, ':')))
01137 nick++;
01138 else
01139 nick = to;
01140
01141 dprintf(DP_SERVER, "PRIVMSG %s :\001DCC SEND %s %s\001\n", nick, nfn, par);
01142 } else {
01143 i = nextbot(tobot);
01144 if (i >= 0) {
01145 *--tobot = '@';
01146 botnet_send_filesend(i, botpath, to, par);
01147 }
01148 }
01149 }
01150
01151 static void bot_error(int idx, char *par)
01152 {
01153 putlog(LOG_MISC | LOG_BOTS, "*", "%s: %s", dcc[idx].nick, par);
01154 }
01155
01156
01157
01158 static void bot_nickchange(int idx, char *par)
01159 {
01160 char *bot, *ssock, *newnick;
01161 int sock, i;
01162
01163 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
01164 return;
01165 bot = newsplit(&par);
01166 #ifndef NO_OLD_BOTNET
01167 if (b_numver(idx) < NEAT_BOTNET) {
01168 fake_alert(idx, "botversion", "NEAT_BOTNET");
01169 return;
01170 }
01171 #endif
01172 i = nextbot(bot);
01173 if (i != idx) {
01174 fake_alert(idx, "direction", bot);
01175 return;
01176 }
01177 ssock = newsplit(&par);
01178 sock = base64_to_int(ssock);
01179 newnick = newsplit(&par);
01180 i = partynick(bot, sock, newnick);
01181 if (i < 0) {
01182 fake_alert(idx, "sock#", ssock);
01183 return;
01184 }
01185 chanout_but(-1, party[i].chan, "*** (%s) Nick change: %s -> %s\n",
01186 bot, newnick, party[i].nick);
01187 botnet_send_nkch_part(idx, i, newnick);
01188 }
01189
01190
01191
01192 static void bot_join(int idx, char *par)
01193 {
01194 char *bot, *nick, *x, *y;
01195 struct userrec *u;
01196 int i, sock, chan, i2, linking = 0;
01197
01198 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
01199 return;
01200 bot = newsplit(&par);
01201 #ifndef NO_OLD_BOTNET
01202 if (b_numver(idx) >= NEAT_BOTNET)
01203 #endif
01204 if (bot[0] == '!') {
01205 linking = 1;
01206 bot++;
01207 }
01208 if (b_status(idx) & STAT_LINKING) {
01209 linking = 1;
01210 }
01211 nick = newsplit(&par);
01212 x = newsplit(&par);
01213 #ifndef NO_OLD_BOTNET
01214 if (b_numver(idx) < NEAT_BOTNET)
01215 chan = atoi(x);
01216 else
01217 #endif
01218 chan = base64_to_int(x);
01219 y = newsplit(&par);
01220 if ((chan < 0) || !y[0])
01221 return;
01222
01223 if (!y[0]) {
01224 y[0] = '-';
01225 sock = 0;
01226 } else {
01227 #ifndef NO_OLD_BOTNET
01228 if (b_numver(idx) < NEAT_BOTNET)
01229 sock = atoi(y + 1);
01230 else
01231 #endif
01232 sock = base64_to_int(y + 1);
01233 }
01234
01235
01236
01237
01238 if (sock == 0)
01239 sock = partysock(bot, nick);
01240 if (sock == 0)
01241 sock = fakesock++;
01242 i = nextbot(bot);
01243 if (i != idx) {
01244
01245 fake_alert(idx, "direction", bot);
01246 return;
01247 }
01248 u = get_user_by_handle(userlist, nick);
01249 if (u) {
01250 sprintf(TBUF, "@%s", bot);
01251 touch_laston(u, TBUF, now);
01252 }
01253 i = addparty(bot, nick, chan, y[0], sock, par, &i2);
01254 botnet_send_join_party(idx, linking, i2, i);
01255 if (i != chan) {
01256 if (i >= 0) {
01257 if (b_numver(idx) >= NEAT_BOTNET)
01258 chanout_but(-1, i, "*** (%s) %s %s %s.\n", bot, nick, NET_LEFTTHE,
01259 i ? "channel" : "party line");
01260 check_tcl_chpt(bot, nick, sock, i);
01261 }
01262 if ((b_numver(idx) >= NEAT_BOTNET) && !linking)
01263 chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, NET_JOINEDTHE,
01264 chan ? "channel" : "party line");
01265 check_tcl_chjn(bot, nick, chan, y[0], sock, par);
01266 }
01267 }
01268
01269
01270
01271 static void bot_part(int idx, char *par)
01272 {
01273 char *bot, *nick, *etc;
01274 struct userrec *u;
01275 int sock, partyidx;
01276 int silent = 0;
01277
01278 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
01279 return;
01280 bot = newsplit(&par);
01281 if (bot[0] == '!') {
01282 silent = 1;
01283 bot++;
01284 }
01285 nick = newsplit(&par);
01286 etc = newsplit(&par);
01287 #ifndef NO_OLD_BOTNET
01288 if (b_numver(idx) < NEAT_BOTNET) {
01289 sock = atoi(etc);
01290 silent = 1;
01291 } else
01292 #endif
01293 sock = base64_to_int(etc);
01294 if (sock == 0)
01295 sock = partysock(bot, nick);
01296 u = get_user_by_handle(userlist, nick);
01297 if (u) {
01298 sprintf(TBUF, "@%s", bot);
01299 touch_laston(u, TBUF, now);
01300 }
01301 if ((partyidx = getparty(bot, sock)) != -1) {
01302 if (party[partyidx].chan >= 0)
01303 check_tcl_chpt(bot, nick, sock, party[partyidx].chan);
01304 if ((b_numver(idx) >= NEAT_BOTNET) && !silent) {
01305 register int chan = party[partyidx].chan;
01306
01307 if (par[0])
01308 chanout_but(-1, chan, "*** (%s) %s %s %s (%s).\n", bot, nick,
01309 NET_LEFTTHE, chan ? "channel" : "party line", par);
01310 else
01311 chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick,
01312 NET_LEFTTHE, chan ? "channel" : "party line");
01313 }
01314 botnet_send_part_party(idx, partyidx, par, silent);
01315 remparty(bot, sock);
01316 }
01317 }
01318
01319
01320
01321
01322 static void bot_away(int idx, char *par)
01323 {
01324 char *bot, *etc;
01325 int sock, partyidx, linking = 0;
01326
01327 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
01328 return;
01329 bot = newsplit(&par);
01330 #ifndef NO_OLD_BOTNET
01331 if (b_numver(idx) >= NEAT_BOTNET)
01332 #endif
01333 if (bot[0] == '!') {
01334 linking = 1;
01335 bot++;
01336 }
01337 if (b_status(idx) & STAT_LINKING) {
01338 linking = 1;
01339 }
01340 etc = newsplit(&par);
01341 #ifndef NO_OLD_BOTNET
01342 if (b_numver(idx) < NEAT_BOTNET)
01343 sock = atoi(etc);
01344 else
01345 #endif
01346 sock = base64_to_int(etc);
01347 if (sock == 0)
01348 sock = partysock(bot, etc);
01349 check_tcl_away(bot, sock, par);
01350 if (par[0]) {
01351 partystat(bot, sock, PLSTAT_AWAY, 0);
01352 partyaway(bot, sock, par);
01353 } else
01354 partystat(bot, sock, 0, PLSTAT_AWAY);
01355 partyidx = getparty(bot, sock);
01356 if ((b_numver(idx) >= NEAT_BOTNET) && !linking) {
01357 if (par[0])
01358 chanout_but(-1, party[partyidx].chan,
01359 "*** (%s) %s %s: %s.\n", bot,
01360 party[partyidx].nick, NET_AWAY, par);
01361 else
01362 chanout_but(-1, party[partyidx].chan,
01363 "*** (%s) %s %s.\n", bot, party[partyidx].nick, NET_UNAWAY);
01364 }
01365 botnet_send_away(idx, bot, sock, par, linking);
01366 }
01367
01368
01369
01370
01371 static void bot_idle(int idx, char *par)
01372 {
01373 char *bot, *work;
01374 int sock, idle;
01375
01376 if (bot_flags(dcc[idx].user) & BOT_ISOLATE)
01377 return;
01378 bot = newsplit(&par);
01379 work = newsplit(&par);
01380 #ifndef NO_OLD_BOTNET
01381 if (b_numver(idx) < NEAT_BOTNET)
01382 sock = atoi(work);
01383 else
01384 #endif
01385 sock = base64_to_int(work);
01386 if (sock == 0)
01387 sock = partysock(bot, work);
01388 work = newsplit(&par);
01389 #ifndef NO_OLD_BOTNET
01390 if (b_numver(idx) < NEAT_BOTNET)
01391 idle = atoi(work);
01392 else
01393 #endif
01394 idle = base64_to_int(work);
01395 partysetidle(bot, sock, idle);
01396 if (par[0]) {
01397 partystat(bot, sock, PLSTAT_AWAY, 0);
01398 partyaway(bot, sock, par);
01399 }
01400 botnet_send_idle(idx, bot, sock, idle, par);
01401 }
01402
01403 #ifndef NO_OLD_BOTNET
01404
01405 static void bot_ufno(int idx, char *par)
01406 {
01407 putlog(LOG_BOTS, "*", "%s %s: %s", USERF_REJECTED, dcc[idx].nick, par);
01408 dcc[idx].status &= ~STAT_OFFERED;
01409 if (!(dcc[idx].status & STAT_GETTING))
01410 dcc[idx].status &= ~STAT_SHARE;
01411 }
01412
01413 static void bot_old_userfile(int idx, char *par)
01414 {
01415 putlog(LOG_BOTS, "*", "%s %s", USERF_OLDSHARE, dcc[idx].nick);
01416 dprintf(idx, "uf-no %s\n", USERF_ANTIQUESHARE);
01417 }
01418
01419 #endif
01420
01421 void bot_share(int idx, char *par)
01422 {
01423 sharein(idx, par);
01424 }
01425
01426
01427
01428 static void bot_versions(int sock, char *par)
01429 {
01430 char *frombot = newsplit(&par), *tobot, *from;
01431 module_entry *me;
01432
01433 if (nextbot(frombot) != sock)
01434 fake_alert(sock, "versions-direction", frombot);
01435 else if (egg_strcasecmp(tobot = newsplit(&par), botnetnick)) {
01436 if ((sock = nextbot(tobot)) >= 0)
01437 dprintf(sock, "v %s %s %s\n", frombot, tobot, par);
01438 } else {
01439 from = newsplit(&par);
01440 botnet_send_priv(sock, botnetnick, from, frombot, "Modules loaded:\n");
01441 for (me = module_list; me; me = me->next)
01442 botnet_send_priv(sock, botnetnick, from, frombot,
01443 " Module: %s (v%d.%d)\n", me->name, me->major,
01444 me->minor);
01445 botnet_send_priv(sock, botnetnick, from, frombot, "End of module list.\n");
01446 }
01447 }
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459 botcmd_t C_bot[] =
01460 {
01461 {"a", (IntFunc) bot_actchan},
01462 #ifndef NO_OLD_BOTNET
01463 {"actchan", (IntFunc) bot_actchan},
01464 #endif
01465 {"aw", (IntFunc) bot_away},
01466 {"away", (IntFunc) bot_away},
01467 {"bye", (IntFunc) bot_bye},
01468 {"c", (IntFunc) bot_chan2},
01469 #ifndef NO_OLD_BOTNET
01470 {"chan", (IntFunc) bot_chan2},
01471 {"chat", (IntFunc) bot_chat},
01472 #endif
01473 {"ct", (IntFunc) bot_chat},
01474 {"e", (IntFunc) bot_error},
01475 {"el", (IntFunc) bot_endlink},
01476 #ifndef NO_OLD_BOTNET
01477 {"error", (IntFunc) bot_error},
01478 #endif
01479 {"f!", (IntFunc) bot_filereject},
01480 #ifndef NO_OLD_BOTNET
01481 {"filereject", (IntFunc) bot_filereject},
01482 {"filereq", (IntFunc) bot_filereq},
01483 {"filesend", (IntFunc) bot_filesend},
01484 #endif
01485 {"fr", (IntFunc) bot_filereq},
01486 {"fs", (IntFunc) bot_filesend},
01487 {"h", (IntFunc) bot_handshake},
01488 #ifndef NO_OLD_BOTNET
01489 {"handshake", (IntFunc) bot_handshake},
01490 #endif
01491 {"i", (IntFunc) bot_idle},
01492 {"i?", (IntFunc) bot_infoq},
01493 #ifndef NO_OLD_BOTNET
01494 {"idle", (IntFunc) bot_idle},
01495 {"info?", (IntFunc) bot_infoq},
01496 #endif
01497 {"j", (IntFunc) bot_join},
01498 #ifndef NO_OLD_BOTNET
01499 {"join", (IntFunc) bot_join},
01500 #endif
01501 {"l", (IntFunc) bot_link},
01502 #ifndef NO_OLD_BOTNET
01503 {"link", (IntFunc) bot_link},
01504 {"linked", (IntFunc) bot_linked},
01505 #endif
01506 {"m", (IntFunc) bot_motd},
01507 #ifndef NO_OLD_BOTNET
01508 {"motd", (IntFunc) bot_motd},
01509 #endif
01510 {"n", (IntFunc) bot_nlinked},
01511 {"nc", (IntFunc) bot_nickchange},
01512 #ifndef NO_OLD_BOTNET
01513 {"nlinked", (IntFunc) bot_nlinked},
01514 #endif
01515 {"p", (IntFunc) bot_priv},
01516 #ifndef NO_OLD_BOTNET
01517 {"part", (IntFunc) bot_part},
01518 #endif
01519 {"pi", (IntFunc) bot_ping},
01520 #ifndef NO_OLD_BOTNET
01521 {"ping", (IntFunc) bot_ping},
01522 #endif
01523 {"po", (IntFunc) bot_pong},
01524 #ifndef NO_OLD_BOTNET
01525 {"pong", (IntFunc) bot_pong},
01526 {"priv", (IntFunc) bot_priv},
01527 #endif
01528 {"pt", (IntFunc) bot_part},
01529 {"r", (IntFunc) bot_reject},
01530 #ifndef NO_OLD_BOTNET
01531 {"reject", (IntFunc) bot_reject},
01532 #endif
01533 {"s", (IntFunc) bot_share},
01534 {"t", (IntFunc) bot_trace},
01535 {"tb", (IntFunc) bot_thisbot},
01536 {"td", (IntFunc) bot_traced},
01537 #ifndef NO_OLD_BOTNET
01538 {"thisbot", (IntFunc) bot_thisbot},
01539 {"trace", (IntFunc) bot_trace},
01540 {"traced", (IntFunc) bot_traced},
01541 #endif
01542 {"u", (IntFunc) bot_update},
01543 #ifndef NO_OLD_BOTNET
01544 {"uf-no", (IntFunc) bot_ufno},
01545 #endif
01546 {"ul", (IntFunc) bot_unlink},
01547 {"un", (IntFunc) bot_unlinked},
01548 #ifndef NO_OLD_BOTNET
01549 {"unaway", (IntFunc) bot_away},
01550 {"unlink", (IntFunc) bot_unlink},
01551 {"unlinked", (IntFunc) bot_unlinked},
01552 {"update", (IntFunc) bot_update},
01553 {"userfile?", (IntFunc) bot_old_userfile},
01554 #endif
01555 {"v", (IntFunc) bot_versions},
01556 {"w", (IntFunc) bot_who},
01557 #ifndef NO_OLD_BOTNET
01558 {"who", (IntFunc) bot_who},
01559 #endif
01560 {"z", (IntFunc) bot_zapf},
01561 #ifndef NO_OLD_BOTNET
01562 {"zapf", (IntFunc) bot_zapf},
01563 {"zapf-broad", (IntFunc) bot_zapfbroad},
01564 #endif
01565 {"zb", (IntFunc) bot_zapfbroad},
01566 {NULL, NULL}
01567 };