#include "main.h"
#include "tandem.h"
#include "users.h"
#include "chan.h"
#include "modules.h"
Go to the source code of this file.
Functions | |
int | base64_to_int (char *buf) |
static void | fake_alert (int idx, char *item, char *extra) |
static void | bot_chan2 (int idx, char *msg) |
static void | bot_chat (int idx, char *par) |
static void | bot_actchan (int idx, char *par) |
static void | bot_priv (int idx, char *par) |
static void | bot_bye (int idx, char *par) |
static void | remote_tell_who (int idx, char *nick, int chan) |
static void | bot_who (int idx, char *par) |
static void | bot_endlink (int idx, char *par) |
static void | bot_infoq (int idx, char *par) |
static void | bot_ping (int idx, char *par) |
static void | bot_pong (int idx, char *par) |
static void | bot_link (int idx, char *par) |
static void | bot_unlink (int idx, char *par) |
static void | bot_update (int idx, char *par) |
static void | bot_nlinked (int idx, char *par) |
static void | bot_linked (int idx, char *par) |
static void | bot_unlinked (int idx, char *par) |
static void | bot_trace (int idx, char *par) |
static void | bot_traced (int idx, char *par) |
static void | bot_reject (int idx, char *par) |
static void | bot_thisbot (int idx, char *par) |
static void | bot_handshake (int idx, char *par) |
static void | bot_zapf (int idx, char *par) |
static void | bot_zapfbroad (int idx, char *par) |
static void | bot_motd (int idx, char *par) |
static void | bot_filereject (int idx, char *par) |
static void | bot_filereq (int idx, char *tobot) |
static void | bot_filesend (int idx, char *par) |
static void | bot_error (int idx, char *par) |
static void | bot_nickchange (int idx, char *par) |
static void | bot_join (int idx, char *par) |
static void | bot_part (int idx, char *par) |
static void | bot_away (int idx, char *par) |
static void | bot_idle (int idx, char *par) |
static void | bot_ufno (int idx, char *par) |
static void | bot_old_userfile (int idx, char *par) |
void | bot_share (int idx, char *par) |
static void | bot_versions (int sock, char *par) |
Variables | |
char | botnetnick [] |
char | ver [] |
char | admin [] |
char | network [] |
char | motdfile [] |
int | dcc_total |
int | remote_boots |
int | noshare |
struct dcc_t * | dcc |
struct chanset_t * | chanset |
struct userrec * | userlist |
Tcl_Interp * | interp |
time_t | now |
time_t | online_since |
party_t * | party |
module_entry * | module_list |
static char | TBUF [1024] |
static char | base64to [256] |
static int | fakesock = 2300 |
botcmd_t | C_bot [] |
int base64_to_int | ( | char * | buf | ) |
static void bot_actchan | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 178 of file botcmd.c.
References b_numver, base64_to_int, bot_flags, BOT_ISOLATE, botnet_send_act(), chanout_but, check_tcl_act, fake_alert(), from, NEAT_BOTNET, newsplit, nextbot, NULL, partyidle(), and user.
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 /* How can a bot do an action? */ 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 }
static void bot_away | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1322 of file botcmd.c.
References b_numver, b_status, base64_to_int, bot_flags, BOT_ISOLATE, botnet_send_away(), chanout_but, check_tcl_away(), getparty(), NEAT_BOTNET, NET_AWAY, NET_UNAWAY, newsplit, partyaway(), partysock(), partystat(), PLSTAT_AWAY, STAT_LINKING, and user.
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 }
static void bot_bye | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 288 of file botcmd.c.
References BOT_DISCONNECTED, botnet_send_unlinked, bots_in_subtree, chatout, dprintf, findbot(), killsock, LOG_BOTS, lostdcc, putlog, simple_sprintf, and users_in_subtree.
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 }
static void bot_chan2 | ( | int | idx, | |
char * | msg | |||
) | [static] |
Definition at line 100 of file botcmd.c.
References b_numver, base64_to_int, bot_flags, BOT_ISOLATE, botnet_send_chan, chanout_but, check_tcl_bcst, check_tcl_chat, fake_alert(), from, NEAT_BOTNET, newsplit, nextbot, NULL, partyidle(), TBUF, and user.
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 /* Strip annoying control chars */ 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 /* Send to new version bots */ 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 }
static void bot_chat | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 153 of file botcmd.c.
References bot_flags, BOT_ISOLATE, botnet_send_chat, chatout, check_tcl_bcst, fake_alert(), from, newsplit, nextbot, NULL, and user.
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 /* Make sure the bot is valid */ 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 }
static void bot_endlink | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 444 of file botcmd.c.
References STAT_LINKING, and dcc_t::status.
00445 { 00446 dcc[idx].status &= ~STAT_LINKING; 00447 }
static void bot_error | ( | int | idx, | |
char * | par | |||
) | [static] |
static void bot_filereject | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1051 of file botcmd.c.
References BOT_XFERREJECTED, botnet_send_filereject, botnetnick, dcc_total, dprintf, egg_strcasecmp, LOG_FILES, MISC_REJECTED, newsplit, nextbot, NULL, and putlog.
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; /* Bot wants a file?! :) */ 01062 if (egg_strcasecmp(tobot, botnetnick)) { /* for me! */ 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 /* No ':'? malformed */ 01073 putlog(LOG_FILES, "*", "%s %s: %s", path, MISC_REJECTED, par); 01074 } else { /* Pass it on */ 01075 i = nextbot(tobot); 01076 if (i >= 0) 01077 botnet_send_filereject(i, path, to, par); 01078 } 01079 }
static void bot_filereq | ( | int | idx, | |
char * | tobot | |||
) | [static] |
Definition at line 1083 of file botcmd.c.
References botnet_send_filereq, botnet_send_priv(), botnetnick, egg_strcasecmp, FILESYS_REMOTE_REQ, from, _module_entry::funcs, MOD_NOFILESYSMOD, module_find, newsplit, nextbot, and NULL.
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)) { /* For me! */ 01093 /* Process this */ 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 { /* Pass it on */ 01104 i = nextbot(tobot); 01105 if (i >= 0) 01106 botnet_send_filereq(i, from, tobot, path); 01107 } 01108 } 01109 }
static void bot_filesend | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1113 of file botcmd.c.
References botnet_send_filesend, botnetnick, DP_SERVER, dprintf, egg_strcasecmp, newsplit, nextbot, and NULL.
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)) { /* For me! */ 01127 nfn = strrchr(botpath, '/'); 01128 if (nfn == NULL) { 01129 nfn = strrchr(botpath, ':'); 01130 if (nfn == NULL) 01131 nfn = botpath; /* That's odd. */ 01132 else 01133 nfn++; 01134 } else 01135 nfn++; 01136 if ((nick = strchr(to, ':'))) 01137 nick++; 01138 else 01139 nick = to; 01140 /* Send it to 'nick' as if it's from me */ 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 }
static void bot_handshake | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 932 of file botcmd.c.
References get_user_by_handle, noshare, set_user, and USERENTRY_PASS.
00933 { 00934 struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick); 00935 00936 /* We *don't* want botnet passwords migrating */ 00937 noshare = 1; 00938 set_user(&USERENTRY_PASS, u, par); 00939 noshare = 0; 00940 }
static void bot_idle | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1371 of file botcmd.c.
References b_numver, base64_to_int, bot_flags, BOT_ISOLATE, botnet_send_idle(), NEAT_BOTNET, newsplit, partyaway(), partysetidle(), partysock(), partystat(), PLSTAT_AWAY, and user.
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 }
static void bot_infoq | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 451 of file botcmd.c.
References BOT_NOCHANNELS, botnet_send_infoq(), botnet_send_priv(), botnetnick, channel_secret, days, chanset_t::dname, LOG_BOTS, module_find, network, chanset_t::next, now, NULL, online_since, putlog, time_t, and ver.
00452 { 00453 char s[200], s2[32], *realnick; 00454 struct chanset_t *chan; 00455 time_t now2; 00456 int hr, min; 00457 00458 /* Strip the idx from user@bot */ 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 /* Days */ 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; /* Yegads..! */ 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 }
static void bot_join | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1192 of file botcmd.c.
References addparty(), b_numver, b_status, base64_to_int, flag_record::bot, bot_flags, BOT_ISOLATE, botnet_send_join_party(), chanout_but, check_tcl_chjn, check_tcl_chpt(), fake_alert(), fakesock, get_user_by_handle, NEAT_BOTNET, NET_JOINEDTHE, NET_LEFTTHE, newsplit, nextbot, now, partysock(), STAT_LINKING, TBUF, touch_laston, and user.
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; /* Woops! pre 1.2.1's send .chat off'ers 01222 * too!! */ 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 /* 1.1 bots always send a sock#, even on a channel change 01235 * so if sock# is 0, this is from an old bot and we must tread softly 01236 * grab old sock# if there is one, otherwise make up one. 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) { /* Ok, garbage from a 1.0g (who uses that 01244 * now?) OR raistlin being evil :) */ 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 }
static void bot_link | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 520 of file botcmd.c.
References BOT_CANTLINKTHERE, BOT_LINKATTEMPT, botlink(), botnet_send_link(), botnet_send_priv(), botnetnick, egg_strcasecmp, from, LOG_CMDS, newsplit, nextbot, NULL, and putlog.
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 }
static void bot_linked | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 706 of file botcmd.c.
References BOT_OLDBOT, botnet_send_unlinked, bots_in_subtree, chatout, findbot(), killsock, LOG_BOTS, lostdcc, MISC_DISCONNECTED, MISC_OUTDATED, putlog, simple_sprintf, and users_in_subtree.
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 }
static void bot_motd | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 992 of file botcmd.c.
References botnet_send_motd(), botnet_send_priv(), botnetnick, egg_strcasecmp, FR_BOT, flag_record::global, HELP_DCC, HELP_IRC, help_subst(), LOG_CMDS, MISC_MOTDFILE, MISC_NOMOTDFILE, motdfile, newsplit, nextbot, NULL, putlog, TBUF, USER_BOT, and USER_HIGHLITE.
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 /* Pass it on */ 01040 i = nextbot(par); 01041 if (i >= 0) 01042 botnet_send_motd(i, who, par); 01043 } 01044 }
static void bot_nickchange | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1158 of file botcmd.c.
References b_numver, base64_to_int, flag_record::bot, bot_flags, BOT_ISOLATE, botnet_send_nkch_part(), flag_record::chan, chanout_but, fake_alert(), NEAT_BOTNET, newsplit, nextbot, partynick(), and user.
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 }
static void bot_nlinked | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 626 of file botcmd.c.
References addbot(), b_numver, base64_to_int, BOT_BOGUSLINK, BOT_DISCONNLEAF, bot_flags, BOT_ILLEGALLINK, BOT_LEAF, BOT_LINKEDTO, BOT_LOOPDETECT, BOT_REJECT, BOT_REJECTING, BOT_YOUREALEAF, botnet_send_nlinked(), botnet_send_reject(), botnet_send_unlinked, botnetnick, chatout, check_tcl_link(), dprintf, egg_strcasecmp, get_user_by_handle, HANDLEN, in_chain, killsock, LOG_BOTS, lostdcc, MISC_DISCONNECTED, MISC_FROM, MISC_INVALIDBOT, MISC_LOOP, NEAT_BOTNET, NET_LINKEDTO, newsplit, chanset_t::next, nextbot, NULL, putlog, simple_sprintf, and user.
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 /* Loop! */ 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 }
static void bot_old_userfile | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1413 of file botcmd.c.
References dprintf, LOG_BOTS, putlog, USERF_ANTIQUESHARE, and USERF_OLDSHARE.
01414 { 01415 putlog(LOG_BOTS, "*", "%s %s", USERF_OLDSHARE, dcc[idx].nick); 01416 dprintf(idx, "uf-no %s\n", USERF_ANTIQUESHARE); 01417 }
static void bot_part | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1271 of file botcmd.c.
References b_numver, base64_to_int, bot_flags, BOT_ISOLATE, botnet_send_part_party(), party_t::chan, chanout_but, check_tcl_chpt(), get_user_by_handle, getparty(), NEAT_BOTNET, NET_LEFTTHE, newsplit, now, partysock(), remparty(), TBUF, touch_laston, and user.
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 }
static void bot_ping | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 508 of file botcmd.c.
References botnet_send_pong().
00509 { 00510 botnet_send_pong(idx); 00511 }
static void bot_pong | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 513 of file botcmd.c.
References STAT_PINGED, and dcc_t::status.
00514 { 00515 dcc[idx].status &= ~STAT_PINGED; 00516 }
static void bot_priv | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 224 of file botcmd.c.
References add_note, BOT_NOSUCHUSER, BOT_NOTEBOXFULL, BOT_NOTEISAWAY, BOT_NOTESENTTO, BOT_NOTESTORED2, botnet_send_priv(), botnetnick, egg_strcasecmp, fake_alert(), from, newsplit, nextbot, NOTE_AWAY, NOTE_ERROR, NOTE_FULL, NOTE_FWD, NOTE_OK, NOTE_REJECT, NOTE_STORED, NOTE_TCL, NULL, splitc, and TBUF.
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; /* Silently ignore notes to '@bot' */ 00244 if (!egg_strcasecmp(tobot, botnetnick)) { /* For me! */ 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; /* Do nothing */ 00275 case NOTE_OK: 00276 botnet_send_priv(idx, botnetnick, from, NULL, 00277 "%s %s.", BOT_NOTESENTTO, to); 00278 break; 00279 } 00280 } 00281 } else { /* Pass it on */ 00282 i = nextbot(tobot); 00283 if (i >= 0) 00284 botnet_send_priv(i, from, to, tobot, "%s", par); 00285 } 00286 }
static void bot_reject | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 821 of file botcmd.c.
References add_note, BOT_CANTUNLINK, BOT_DOESNTEXIST, bot_flags, BOT_ISOLATE, BOT_NOOWNERBOOT, BOT_NOREMOTEBOOT, BOT_SHARE, botnet_send_priv(), botnet_send_reject(), botnet_send_unlinked, botnetnick, chatout, dcc_total, DCT_CHAT, do_boot(), dprintf, egg_strcasecmp, fake_alert(), userrec::flags, dcc_table::flags, from, get_user_by_handle, killsock, LOG_BOTS, LOG_CMDS, lostdcc, MISC_DISCONNECTED, MISC_REJECTED, newsplit, nextbot, NULL, putlog, remote_boots, simple_sprintf, dcc_t::type, user, and USER_OWNER.
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 /* Rejecting a bot */ 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 /* I'm the connection to the rejected bot */ 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 { /* Rejecting user */ 00865 *destbot++ = 0; 00866 if (!egg_strcasecmp(destbot, botnetnick)) { 00867 /* Kick someone here! */ 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 }
void bot_share | ( | int | idx, | |
char * | par | |||
) |
Definition at line 1421 of file botcmd.c.
References sharein.
Referenced by bot_version().
01422 { 01423 sharein(idx, par); 01424 }
static void bot_thisbot | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 907 of file botcmd.c.
References bot_flags, BOT_LEAF, botnet_send_unlinked, change_handle, chatout, dprintf, egg_strcasecmp, findbot(), killsock, LOG_BOTS, lostdcc, MISC_DISCONNECTED, MISC_IMPOSTER, NET_WRONGBOT, noshare, putlog, simple_sprintf, STAT_LEAF, dcc_t::status, unvia(), and user.
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 /* Set capitalization the way they want it */ 00926 noshare = 1; 00927 change_handle(dcc[idx].user, par); 00928 noshare = 0; 00929 strcpy(dcc[idx].nick, par); 00930 }
static void bot_trace | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 746 of file botcmd.c.
References botnet_send_trace(), botnet_send_traced(), botnetnick, egg_strcasecmp, from, newsplit, nextbot, simple_sprintf, and TBUF.
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 }
static void bot_traced | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 761 of file botcmd.c.
References BOT_TRACERESULT, botnet_send_traced(), botnetnick, dcc_total, DCT_CHAT, dprintf, egg_strcasecmp, newsplit, nextbot, now, NULL, splitc, TBUF, and time_t.
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 }
static void bot_ufno | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 1405 of file botcmd.c.
References LOG_BOTS, putlog, STAT_GETTING, STAT_OFFERED, STAT_SHARE, dcc_t::status, and USERF_REJECTED.
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 }
static void bot_unlink | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 548 of file botcmd.c.
References BOT_CANTUNLINK, botnet_send_priv(), botnet_send_unlink(), botnet_send_unlinked, botnetnick, botunlink(), egg_strcasecmp, from, LOG_CMDS, newsplit, nextbot, NULL, and putlog.
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 /* idx will change after unlink -- get new idx 00568 * 00569 * TODO: This has changed with the new lostdcc() behaviour. Check 00570 * if we can optimise the situation. 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 /* Ditto above, about idx */ 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 }
static void bot_unlinked | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 724 of file botcmd.c.
References botnet_send_unlinked, chatout, fake_alert(), findbot(), lastbot(), newsplit, nextbot, rembot(), and unvia().
00725 { 00726 int i; 00727 char *bot; 00728 00729 bot = newsplit(&par); 00730 i = nextbot(bot); 00731 if ((i >= 0) && (i != idx)) /* Bot is NOT downstream along idx, so 00732 * BOGUS! */ 00733 fake_alert(idx, "direction", bot); 00734 else if (i >= 0) { /* Valid bot downstream of idx */ 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 /* Otherwise it's not even a valid bot, so just ignore! */ 00742 }
static void bot_update | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 605 of file botcmd.c.
References b_numver, base64_to_int, in_chain, NEAT_BOTNET, newsplit, and updatebot.
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 }
static void bot_versions | ( | int | sock, | |
char * | par | |||
) | [static] |
Definition at line 1428 of file botcmd.c.
References botnet_send_priv(), botnetnick, dprintf, egg_strcasecmp, fake_alert(), from, _module_entry::major, _module_entry::minor, _module_entry::name, newsplit, _module_entry::next, and nextbot.
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 }
static void bot_who | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 416 of file botcmd.c.
References b_numver, base64_to_int, botnet_send_who(), botnetnick, egg_strcasecmp, from, NEAT_BOTNET, newsplit, nextbot, remote_tell_who(), and TBUF.
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 }
static void bot_zapf | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 945 of file botcmd.c.
References botnet_send_zapf, botnetnick, check_tcl_bot(), egg_strcasecmp, fake_alert(), from, newsplit, and nextbot.
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 /* For me! */ 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 }
static void bot_zapfbroad | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 973 of file botcmd.c.
References botnet_send_zapf_broad, check_tcl_bot(), fake_alert(), from, newsplit, and nextbot.
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 }
static void fake_alert | ( | int | idx, | |
char * | item, | |||
char * | extra | |||
) | [static] |
Definition at line 79 of file botcmd.c.
References b_numver, botnetnick, dprintf, LOG_BOTS, NEAT_BOTNET, NET_FAKEREJECT, now, and putlog.
Referenced by bot_actchan(), bot_chan2(), bot_chat(), bot_join(), bot_nickchange(), bot_priv(), bot_reject(), bot_unlinked(), bot_versions(), bot_zapf(), and bot_zapfbroad().
00080 { 00081 static unsigned long lastfake; /* The last time fake_alert was used */ 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 }
static void remote_tell_who | ( | int | idx, | |
char * | nick, | |||
int | chan | |||
) | [static] |
Definition at line 307 of file botcmd.c.
References admin, chat_info::away, dcc_t::bot, BOT_BOTSCONNECTED, BOT_NOCHANNELS, BOT_OTHERPEOPLE, BOT_PARTYMEMBS, BOT_PEOPLEONCHAN, botnet_send_priv(), botnetnick, chat_info::channel, channel_inactive, channel_secret, dcc_t::chat, days, DCC_BOT, dcc_total, DCT_REMOTEWHO, chanset_t::dname, geticon, GLOBAL_CHANS, interp, LOG_BOTS, MISC_AWAY, MISC_IDLE, chanset_t::next, now, NULL, putlog, simple_sprintf, STAT_CALLED, STAT_SHARE, chanset_t::status, tcl_resultempty(), tcl_resultstring(), dcc_t::timeval, chanset_t::type, ver, and bot_info::version.
Referenced by bot_who().
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 }
char admin[] |
Definition at line 61 of file chanprog.c.
char base64to[256] [static] |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 62, 0, 63, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
Definition at line 45 of file botcmd.c.
Referenced by base64_to_int().
char botnetnick[] |
Definition at line 60 of file chanprog.c.
int fakesock = 2300 [static] |
Definition at line 77 of file botcmd.c.
Referenced by bot_join().
char motdfile[] |
Definition at line 43 of file dccutil.c.
Referenced by bot_motd(), show_motd(), and tell_settings().
char network[] |
Definition at line 56 of file dcc.c.
Referenced by bot_infoq(), cmd_botinfo(), greet_new_bot(), and help_subst().
int noshare |
int remote_boots |
Definition at line 76 of file tcl.c.
Referenced by bot_reject(), and cmd_boot().
char TBUF[1024] [static] |
Definition at line 43 of file botcmd.c.
Referenced by bot_chan2(), bot_join(), bot_motd(), bot_part(), bot_priv(), bot_trace(), bot_traced(), and bot_who().