#include "main.h"
#include "tandem.h"
Go to the source code of this file.
Functions | |
void tandout_but | EGG_VARARGS_DEF (int, arg1) |
char * | int_to_base64 (unsigned int val) |
char * | int_to_base10 (int val) |
char * | unsigned_int_to_base10 (unsigned int val) |
int simple_sprintf | EGG_VARARGS_DEF (char *, arg1) |
void | send_tand_but (int x, char *buf, int len) |
void | botnet_send_bye () |
void | botnet_send_chan (int idx, char *botnick, char *user, int chan, char *data) |
void | botnet_send_act (int idx, char *botnick, char *user, int chan, char *data) |
void | botnet_send_chat (int idx, char *botnick, char *data) |
void | botnet_send_ping (int idx) |
void | botnet_send_pong (int idx) |
void | botnet_send_who (int idx, char *from, char *to, int chan) |
void | botnet_send_infoq (int idx, char *par) |
void | botnet_send_unlink (int idx, char *who, char *via, char *bot, char *reason) |
void | botnet_send_link (int idx, char *who, char *via, char *bot) |
void | botnet_send_unlinked (int idx, char *bot, char *args) |
void | botnet_send_nlinked (int idx, char *bot, char *next, char flag, int vernum) |
void | botnet_send_traced (int idx, char *bot, char *buf) |
void | botnet_send_trace (int idx, char *to, char *from, char *buf) |
void | botnet_send_update (int idx, tand_t *ptr) |
void | botnet_send_reject (int idx, char *fromp, char *frombot, char *top, char *tobot, char *reason) |
void | botnet_send_zapf (int idx, char *a, char *b, char *c) |
void | botnet_send_zapf_broad (int idx, char *a, char *b, char *c) |
void | botnet_send_motd (int idx, char *from, char *to) |
void | botnet_send_filereject (int idx, char *path, char *from, char *reason) |
void | botnet_send_filesend (int idx, char *path, char *from, char *data) |
void | botnet_send_filereq (int idx, char *from, char *bot, char *path) |
void | botnet_send_idle (int idx, char *bot, int sock, int idle, char *away) |
void | botnet_send_away (int idx, char *bot, int sock, char *msg, int linking) |
void | botnet_send_join_idx (int useridx, int oldchan) |
void | botnet_send_join_party (int idx, int linking, int useridx, int oldchan) |
void | botnet_send_part_idx (int useridx, char *reason) |
void | botnet_send_part_party (int idx, int partyidx, char *reason, int silent) |
void | botnet_send_nkch (int useridx, char *oldnick) |
void | botnet_send_nkch_part (int butidx, int useridx, char *oldnick) |
int | add_note (char *to, char *from, char *msg, int idx, int echo) |
Variables | |
struct dcc_t * | dcc |
int | dcc_total |
int | tands |
char | botnetnick [] |
party_t * | party |
Tcl_Interp * | interp |
struct userrec * | userlist |
static char | OBUF [1024] |
static char | tobase64array [64] |
int add_note | ( | char * | to, | |
char * | from, | |||
char * | msg, | |||
int | idx, | |||
int | echo | |||
) |
Definition at line 759 of file botmsg.c.
References add_note, BOT_NONOTES, BOT_NOTEARRIVED, BOT_NOTHERE, BOT_USERAWAY, botnet_send_priv(), botnetnick, check_tcl_note(), DCC_CHAT, dcc_total, DCT_GETNOTES, dprintf, egg_strcasecmp, fr, get_user_by_handle, userrec::handle, interp, is_bot, match_noterej, newsplit, nextbot, NOTE_AWAY, NOTE_ERROR, NOTE_FWD, NOTE_OK, NOTE_REJECT, NOTE_STORED, NOTE_TCL, NULL, rmspace, simple_sprintf, dcc_t::sock, splitc, tcl_resultempty(), and USERF_UNKNOWN.
00760 { 00761 int status, i, iaway, sock; 00762 char *p, botf[81], ss[81], ssf[81]; 00763 struct userrec *u; 00764 00765 /* Notes have a length limit. Note + PRIVMSG header + nick + date must 00766 * be less than 512. 00767 */ 00768 if (strlen(msg) > 450) 00769 msg[450] = 0; 00770 00771 /* Is this a cross-bot note? If it is, 'to' will be of the format 00772 * 'user@bot'. 00773 */ 00774 p = strchr(to, '@'); 00775 if (p != NULL) { 00776 char x[21]; 00777 00778 *p = 0; 00779 strncpy(x, to, 20); 00780 x[20] = 0; 00781 *p = '@'; 00782 p++; 00783 00784 if (!egg_strcasecmp(p, botnetnick)) /* To me?? */ 00785 return add_note(x, from, msg, idx, echo); /* Start over, dimwit. */ 00786 00787 if (egg_strcasecmp(from, botnetnick)) { 00788 if (strlen(from) > 40) 00789 from[40] = 0; 00790 00791 if (strchr(from, '@')) { 00792 strcpy(botf, from); 00793 } else 00794 sprintf(botf, "%s@%s", from, botnetnick); 00795 00796 } else 00797 strcpy(botf, botnetnick); 00798 00799 i = nextbot(p); 00800 if (i < 0) { 00801 if (idx >= 0) 00802 dprintf(idx, BOT_NOTHERE); 00803 00804 return NOTE_ERROR; 00805 } 00806 00807 if (idx >= 0 && echo) 00808 dprintf(idx, "-> %s@%s: %s\n", x, p, msg); 00809 00810 if (idx >= 0) { 00811 sprintf(ssf, "%lu:%s", dcc[idx].sock, botf); 00812 botnet_send_priv(i, ssf, x, p, "%s", msg); 00813 } else 00814 botnet_send_priv(i, botf, x, p, "%s", msg); 00815 00816 return NOTE_OK; /* Forwarded to the right bot */ 00817 } 00818 00819 /* Might be form "sock:nick" */ 00820 splitc(ssf, from, ':'); 00821 rmspace(ssf); 00822 splitc(ss, to, ':'); 00823 rmspace(ss); 00824 if (!ss[0]) 00825 sock = -1; 00826 else 00827 sock = atoi(ss); 00828 00829 /* Don't process if there's a note binding for it */ 00830 if (idx != -2) { /* Notes from bots don't trigger it */ 00831 if (check_tcl_note(from, to, msg)) { 00832 if (idx >= 0 && echo) 00833 dprintf(idx, "-> %s: %s\n", to, msg); 00834 00835 return NOTE_TCL; 00836 } 00837 } 00838 00839 /* Valid user? */ 00840 u = get_user_by_handle(userlist, to); 00841 if (!u) { 00842 if (idx >= 0) 00843 dprintf(idx, USERF_UNKNOWN); 00844 00845 return NOTE_ERROR; 00846 } 00847 00848 /* Is the note to a bot? */ 00849 if (is_bot(u)) { 00850 if (idx >= 0) 00851 dprintf(idx, BOT_NONOTES); 00852 00853 return NOTE_ERROR; 00854 } 00855 00856 /* Is user rejecting notes from this source? */ 00857 if (match_noterej(u, from)) { 00858 if (idx >= 0) 00859 dprintf(idx, "%s rejected your note.\n", u->handle); 00860 00861 return NOTE_REJECT; 00862 } 00863 00864 status = NOTE_STORED; 00865 iaway = 0; 00866 00867 /* Online right now? */ 00868 for (i = 0; i < dcc_total; i++) { 00869 if ((dcc[i].type->flags & DCT_GETNOTES) && 00870 (sock == -1 || sock == dcc[i].sock) && 00871 !egg_strcasecmp(dcc[i].nick, to)) { 00872 int aok = 1; 00873 00874 if (dcc[i].type == &DCC_CHAT) { 00875 00876 /* Only check away if it's not from a bot. */ 00877 if (dcc[i].u.chat->away != NULL && idx != -2) { 00878 aok = 0; 00879 00880 if (idx >= 0) 00881 dprintf(idx, "%s %s: %s\n", dcc[i].nick, BOT_USERAWAY, 00882 dcc[i].u.chat->away); 00883 00884 if (!iaway) 00885 iaway = i; 00886 status = NOTE_AWAY; 00887 } 00888 } 00889 00890 if (aok) { 00891 char *p, *fr = from, work[1024]; 00892 int l = 0; 00893 00894 while (*msg == '<' || *msg == '>') { 00895 p = newsplit(&msg); 00896 00897 if (*p == '<') 00898 l += simple_sprintf(work + l, "via %s, ", p + 1); 00899 else if (*from == '@') 00900 fr = p + 1; 00901 } 00902 00903 if (idx == -2 || !egg_strcasecmp(from, botnetnick)) 00904 dprintf(i, "*** [%s] %s%s\n", fr, l ? work : "", msg); 00905 else 00906 dprintf(i, "%cNote [%s]: %s%s\n", 7, fr, l ? work : "", msg); 00907 00908 if (idx >= 0 && echo) 00909 dprintf(idx, "-> %s: %s\n", to, msg); 00910 00911 return NOTE_OK; 00912 } 00913 } 00914 } 00915 00916 if (idx == -2) 00917 return NOTE_OK; /* Error msg from a tandembot: don't store. */ 00918 00919 /* Call 'storenote' Tcl command. */ 00920 simple_sprintf(ss, "%d", (idx >= 0) ? dcc[idx].sock : -1); 00921 Tcl_SetVar(interp, "_from", from, 0); 00922 Tcl_SetVar(interp, "_to", to, 0); 00923 Tcl_SetVar(interp, "_data", msg, 0); 00924 Tcl_SetVar(interp, "_idx", ss, 0); 00925 if (Tcl_VarEval(interp, "storenote", " $_from $_to $_data $_idx", NULL) == 00926 TCL_OK) { 00927 00928 if (!tcl_resultempty()) 00929 status = NOTE_FWD; 00930 00931 /* User is away in all sessions -- just notify the user that a 00932 * message arrived and was stored (only oldest session is notified). 00933 */ 00934 if (status == NOTE_AWAY) 00935 dprintf(iaway, "*** %s.\n", BOT_NOTEARRIVED); 00936 00937 return status; 00938 } 00939 00940 /* If we haven't returned anything else by now, assume an error occurred. */ 00941 return NOTE_ERROR; 00942 }
void botnet_send_act | ( | int | idx, | |
char * | botnick, | |||
char * | user, | |||
int | chan, | |||
char * | data | |||
) |
Definition at line 241 of file botmsg.c.
References GLOBAL_CHANS, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_actchan(), and cmd_me().
00242 { 00243 int i; 00244 00245 if ((tands > 0) && (chan < GLOBAL_CHANS)) { 00246 if (user) { 00247 i = simple_sprintf(OBUF, "a %s@%s %D %s\n", user, botnick, chan, data); 00248 } else { 00249 i = simple_sprintf(OBUF, "a %s %D %s\n", botnick, chan, data); 00250 } 00251 send_tand_but(idx, OBUF, -i); 00252 #ifndef NO_OLD_BOTNET 00253 tandout_but(idx, "actchan %s%s%s %d %s\n", user ? user : "", 00254 user ? "@" : "", botnick, chan, data); 00255 #endif 00256 } 00257 }
void botnet_send_away | ( | int | idx, | |
char * | bot, | |||
int | sock, | |||
char * | msg, | |||
int | linking | |||
) |
Definition at line 568 of file botmsg.c.
References b_numver, chat_info::channel, dcc_t::chat, getparty(), NEAT_BOTNET, NET_AWAY, NET_UNAWAY, dcc_t::nick, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_away(), not_away(), and set_away().
00569 { 00570 int l; 00571 00572 if (tands > 0) { 00573 l = simple_sprintf(OBUF, "aw %s%s %D %s\n", 00574 ((idx >= 0) && linking) ? "!" : "", 00575 bot, sock, msg ? msg : ""); 00576 send_tand_but(idx, OBUF, -l); 00577 #ifndef NO_OLD_BOTNET 00578 if (msg) { 00579 if (idx < 0) { 00580 tandout_but(idx, "chan %s %d %s is now away: %s.\n", bot, 00581 dcc[linking].u.chat->channel, dcc[linking].nick, msg); 00582 } else if ((b_numver(idx) >= NEAT_BOTNET)) { 00583 int partyidx = getparty(bot, sock); 00584 00585 if (partyidx >= 0) 00586 tandout_but(idx, "chan %s %d %s %s: %s.\n", bot, 00587 party[partyidx].chan, party[partyidx].nick, 00588 NET_AWAY, msg); 00589 } 00590 tandout_but(idx, "away %s %d %s\n", bot, sock, msg); 00591 } else { 00592 if (idx < 0) { 00593 tandout_but(idx, "chan %s %d %s %s.\n", bot, 00594 dcc[linking].u.chat->channel, dcc[linking].nick, 00595 NET_UNAWAY); 00596 } else if (b_numver(idx) >= NEAT_BOTNET) { 00597 int partyidx = getparty(bot, sock); 00598 00599 if (partyidx >= 0) 00600 tandout_but(idx, "chan %s %d %s %s.\n", bot, 00601 party[partyidx].chan, party[partyidx].nick, NET_UNAWAY); 00602 } 00603 tandout_but(idx, "unaway %s %d\n", bot, sock); 00604 } 00605 #endif 00606 } 00607 }
void botnet_send_bye | ( | ) |
Definition at line 213 of file botmsg.c.
References send_tand_but(), tandout_but(), and tands.
00214 { 00215 if (tands > 0) { 00216 send_tand_but(-1, "bye\n", 4); 00217 #ifndef NO_OLD_BOTNET 00218 tandout_but(-1, "bye\n"); 00219 #endif 00220 } 00221 }
void botnet_send_chan | ( | int | idx, | |
char * | botnick, | |||
char * | user, | |||
int | chan, | |||
char * | data | |||
) |
Definition at line 223 of file botmsg.c.
References GLOBAL_CHANS, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
00224 { 00225 int i; 00226 00227 if ((tands > 0) && (chan < GLOBAL_CHANS)) { 00228 if (user) { 00229 i = simple_sprintf(OBUF, "c %s@%s %D %s\n", user, botnick, chan, data); 00230 } else { 00231 i = simple_sprintf(OBUF, "c %s %D %s\n", botnick, chan, data); 00232 } 00233 send_tand_but(idx, OBUF, -i); 00234 #ifndef NO_OLD_BOTNET 00235 tandout_but(idx, "chan %s%s%s %d %s\n", user ? user : "", 00236 user ? "@" : "", botnick, chan, data); 00237 #endif 00238 } 00239 }
void botnet_send_chat | ( | int | idx, | |
char * | botnick, | |||
char * | data | |||
) |
Definition at line 259 of file botmsg.c.
References OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
00260 { 00261 int i; 00262 00263 if (tands > 0) { 00264 i = simple_sprintf(OBUF, "ct %s %s\n", botnick, data); 00265 send_tand_but(idx, OBUF, -i); 00266 #ifndef NO_OLD_BOTNET 00267 tandout_but(idx, "chat %s %s\n", botnick, data); 00268 #endif 00269 } 00270 }
void botnet_send_filereject | ( | int | idx, | |
char * | path, | |||
char * | from, | |||
char * | reason | |||
) |
Definition at line 513 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
00514 { 00515 int l; 00516 00517 #ifndef NO_OLD_BOTNET 00518 if (b_numver(idx) < NEAT_BOTNET) 00519 l = simple_sprintf(OBUF, "filereject %s %s %s\n", path, from, reason); 00520 else 00521 #endif 00522 l = simple_sprintf(OBUF, "f! %s %s %s\n", path, from, reason); 00523 tputs(dcc[idx].sock, OBUF, l); 00524 }
void botnet_send_filereq | ( | int | idx, | |
char * | from, | |||
char * | bot, | |||
char * | path | |||
) |
Definition at line 539 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
00540 { 00541 int l; 00542 00543 #ifndef NO_OLD_BOTNET 00544 if (b_numver(idx) < NEAT_BOTNET) 00545 l = simple_sprintf(OBUF, "filereq %s %s:%s\n", from, bot, path); 00546 else 00547 #endif 00548 l = simple_sprintf(OBUF, "fr %s %s:%s\n", from, bot, path); 00549 tputs(dcc[idx].sock, OBUF, l); 00550 }
void botnet_send_filesend | ( | int | idx, | |
char * | path, | |||
char * | from, | |||
char * | data | |||
) |
Definition at line 526 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
00527 { 00528 int l; 00529 00530 #ifndef NO_OLD_BOTNET 00531 if (b_numver(idx) < NEAT_BOTNET) 00532 l = simple_sprintf(OBUF, "filesend %s %s %s\n", path, from, data); 00533 else 00534 #endif 00535 l = simple_sprintf(OBUF, "fs %s %s %s\n", path, from, data); 00536 tputs(dcc[idx].sock, OBUF, l); 00537 }
void botnet_send_idle | ( | int | idx, | |
char * | bot, | |||
int | sock, | |||
int | idle, | |||
char * | away | |||
) |
Definition at line 552 of file botmsg.c.
References OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_idle().
00553 { 00554 int l; 00555 00556 if (tands > 0) { 00557 l = simple_sprintf(OBUF, "i %s %D %D %s\n", bot, sock, idle, 00558 away ? away : ""); 00559 send_tand_but(idx, OBUF, -l); 00560 #ifndef NO_OLD_BOTNET 00561 if (away && away[0]) 00562 tandout_but(idx, "away %s %d %s\n", bot, sock, away); 00563 tandout_but(idx, "idle %s %d %d\n", bot, sock, idle); 00564 #endif 00565 } 00566 }
void botnet_send_infoq | ( | int | idx, | |
char * | par | |||
) |
Definition at line 340 of file botmsg.c.
References OBUF, send_tand_but(), simple_sprintf, and tandout_but().
Referenced by bot_infoq(), and cmd_botinfo().
00341 { 00342 int i = simple_sprintf(OBUF, "i? %s\n", par); 00343 00344 send_tand_but(idx, OBUF, i); 00345 #ifndef NO_OLD_BOTNET 00346 tandout_but(idx, "info? %s\n", par); 00347 #endif 00348 }
void botnet_send_join_idx | ( | int | useridx, | |
int | oldchan | |||
) |
Definition at line 609 of file botmsg.c.
References botnetnick, chat_info::channel, dcc_t::chat, geticon, GLOBAL_CHANS, NET_JOINEDTHE, NET_LEFTTHE, dcc_t::nick, OBUF, send_tand_but(), simple_sprintf, tandout_but(), tands, and dcc_t::u.
00610 { 00611 int l; 00612 00613 if (tands > 0) { 00614 l = simple_sprintf(OBUF, "j %s %s %D %c%D %s\n", 00615 botnetnick, dcc[useridx].nick, 00616 dcc[useridx].u.chat->channel, geticon(useridx), 00617 dcc[useridx].sock, dcc[useridx].host); 00618 send_tand_but(-1, OBUF, -l); 00619 #ifndef NO_OLD_BOTNET 00620 tandout_but(-1, "join %s %s %d %c%d %s\n", botnetnick, 00621 dcc[useridx].nick, dcc[useridx].u.chat->channel, 00622 geticon(useridx), dcc[useridx].sock, dcc[useridx].host); 00623 tandout_but(-1, "chan %s %d %s %s %s.\n", 00624 botnetnick, dcc[useridx].u.chat->channel, 00625 dcc[useridx].nick, NET_JOINEDTHE, 00626 dcc[useridx].u.chat->channel ? "channel" : "party line"); 00627 if ((oldchan >= 0) && (oldchan < GLOBAL_CHANS)) { 00628 tandout_but(-1, "chan %s %d %s %s %s.\n", 00629 botnetnick, oldchan, 00630 dcc[useridx].nick, NET_LEFTTHE, 00631 oldchan ? "channel" : "party line"); 00632 } 00633 #endif 00634 } 00635 }
void botnet_send_join_party | ( | int | idx, | |
int | linking, | |||
int | useridx, | |||
int | oldchan | |||
) |
Definition at line 637 of file botmsg.c.
References b_numver, from, GLOBAL_CHANS, NEAT_BOTNET, NET_JOINEDTHE, NET_LEFTTHE, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_join().
00638 { 00639 int l; 00640 00641 if (tands > 0) { 00642 l = simple_sprintf(OBUF, "j %s%s %s %D %c%D %s\n", linking ? "!" : "", 00643 party[useridx].bot, party[useridx].nick, 00644 party[useridx].chan, party[useridx].flag, 00645 party[useridx].sock, 00646 party[useridx].from ? party[useridx].from : ""); 00647 send_tand_but(idx, OBUF, -l); 00648 #ifndef NO_OLD_BOTNET 00649 tandout_but(idx, "join %s %s %d %c%d %s\n", party[useridx].bot, 00650 party[useridx].nick, party[useridx].chan, 00651 party[useridx].flag, party[useridx].sock, 00652 party[useridx].from ? party[useridx].from : ""); 00653 if ((idx < 0) || (!linking && (b_numver(idx) >= NEAT_BOTNET))) { 00654 tandout_but(idx, "chan %s %d %s %s %s.\n", 00655 party[useridx].bot, party[useridx].chan, 00656 party[useridx].nick, NET_JOINEDTHE, 00657 party[useridx].chan ? "channel" : "party line"); 00658 } 00659 if ((oldchan >= 0) && (oldchan < GLOBAL_CHANS) && 00660 ((idx < 0) || (b_numver(idx) >= NEAT_BOTNET))) { 00661 tandout_but(idx, "chan %s %d %s %s %s.\n", 00662 party[useridx].bot, oldchan, party[useridx].nick, 00663 NET_LEFTTHE, party[useridx].chan ? "channel" : "party line"); 00664 } 00665 #endif 00666 } 00667 }
void botnet_send_link | ( | int | idx, | |
char * | who, | |||
char * | via, | |||
char * | bot | |||
) |
Definition at line 363 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_link(), and cmd_link().
00364 { 00365 int l; 00366 00367 #ifndef NO_OLD_BOTNET 00368 if (b_numver(idx) < NEAT_BOTNET) 00369 l = simple_sprintf(OBUF, "link %s %s %s\n", who, via, bot); 00370 else 00371 #endif 00372 l = simple_sprintf(OBUF, "l %s %s %s\n", who, via, bot); 00373 tputs(dcc[idx].sock, OBUF, l); 00374 }
void botnet_send_motd | ( | int | idx, | |
char * | from, | |||
char * | to | |||
) |
Definition at line 500 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_motd(), and cmd_motd().
00501 { 00502 int l; 00503 00504 #ifndef NO_OLD_BOTNET 00505 if (b_numver(idx) < NEAT_BOTNET) 00506 l = simple_sprintf(OBUF, "motd %s %s\n", from, to); 00507 else 00508 #endif 00509 l = simple_sprintf(OBUF, "m %s %s\n", from, to); 00510 tputs(dcc[idx].sock, OBUF, l); 00511 }
void botnet_send_nkch | ( | int | useridx, | |
char * | oldnick | |||
) |
Definition at line 713 of file botmsg.c.
References botnetnick, chat_info::channel, dcc_t::chat, geticon, NET_NICKCHANGE, dcc_t::nick, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
00714 { 00715 int l; 00716 00717 if (tands > 0) { 00718 l = simple_sprintf(OBUF, "nc %s %D %s\n", botnetnick, 00719 dcc[useridx].sock, dcc[useridx].nick); 00720 send_tand_but(-1, OBUF, -l); 00721 #ifndef NO_OLD_BOTNET 00722 tandout_but(-1, "part %s %s %d\n", botnetnick, 00723 dcc[useridx].nick, dcc[useridx].sock); 00724 tandout_but(-1, "join %s %s %d %c%d %s\n", botnetnick, 00725 dcc[useridx].nick, dcc[useridx].u.chat->channel, 00726 geticon(useridx), dcc[useridx].sock, dcc[useridx].host); 00727 tandout_but(-1, "chan %s %d %s: %s -> %s.\n", 00728 botnetnick, dcc[useridx].u.chat->channel, 00729 oldnick, NET_NICKCHANGE, dcc[useridx].nick); 00730 #endif 00731 } 00732 }
void botnet_send_nkch_part | ( | int | butidx, | |
int | useridx, | |||
char * | oldnick | |||
) |
Definition at line 734 of file botmsg.c.
References from, NET_NICKCHANGE, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_nickchange().
00735 { 00736 int l; 00737 00738 if (tands > 0) { 00739 l = simple_sprintf(OBUF, "nc %s %D %s\n", party[useridx].bot, 00740 party[useridx].sock, party[useridx].nick); 00741 send_tand_but(butidx, OBUF, -l); 00742 #ifndef NO_OLD_BOTNET 00743 tandout_but(butidx, "part %s %s %d\n", party[useridx].bot, 00744 party[useridx].nick, party[useridx].sock); 00745 tandout_but(butidx, "join %s %s %d %c%d %s\n", party[useridx].bot, 00746 party[useridx].nick, party[useridx].chan, 00747 party[useridx].flag, party[useridx].sock, 00748 party[useridx].from ? party[useridx].from : ""); 00749 tandout_but(butidx, "chan %s %d %s : %s -> %s.\n", 00750 party[useridx].bot, party[useridx].chan, 00751 NET_NICKCHANGE, oldnick, party[useridx].nick); 00752 #endif 00753 } 00754 }
void botnet_send_nlinked | ( | int | idx, | |
char * | bot, | |||
char * | next, | |||
char | flag, | |||
int | vernum | |||
) |
Definition at line 391 of file botmsg.c.
References NET_LINKEDTO, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_nlinked(), and bot_version().
00392 { 00393 int l; 00394 00395 if (tands > 0) { 00396 l = simple_sprintf(OBUF, "n %s %s %c%D\n", bot, next, flag, vernum); 00397 send_tand_but(idx, OBUF, l); 00398 #ifndef NO_OLD_BOTNET 00399 if (flag == '!') { 00400 flag = '-'; 00401 tandout_but(idx, "chat %s %s %s\n", next, NET_LINKEDTO, bot); 00402 } 00403 tandout_but(idx, "nlinked %s %s %c%d\n", bot, next, flag, vernum); 00404 #endif 00405 } 00406 }
void botnet_send_part_idx | ( | int | useridx, | |
char * | reason | |||
) |
Definition at line 669 of file botmsg.c.
References botnetnick, chat_info::channel, dcc_t::chat, dcc_t::nick, OBUF, send_tand_but(), simple_sprintf, tandout_but(), tands, and dcc_t::u.
00670 { 00671 int l = simple_sprintf(OBUF, "pt %s %s %D %s\n", botnetnick, 00672 dcc[useridx].nick, dcc[useridx].sock, 00673 reason ? reason : ""); 00674 00675 if (tands > 0) { 00676 send_tand_but(-1, OBUF, -l); 00677 #ifndef NO_OLD_BOTNET 00678 tandout_but(-1, "part %s %s %d\n", botnetnick, 00679 dcc[useridx].nick, dcc[useridx].sock); 00680 tandout_but(-1, "chan %s %d %s has left the %s%s%s.\n", 00681 botnetnick, dcc[useridx].u.chat->channel, 00682 dcc[useridx].nick, 00683 dcc[useridx].u.chat->channel ? "channel" : "party line", 00684 reason ? ": " : "", reason ? reason : ""); 00685 #endif 00686 } 00687 }
void botnet_send_part_party | ( | int | idx, | |
int | partyidx, | |||
char * | reason, | |||
int | silent | |||
) |
Definition at line 689 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
Referenced by bot_part().
00690 { 00691 int l; 00692 00693 if (tands > 0) { 00694 l = simple_sprintf(OBUF, "pt %s%s %s %D %s\n", 00695 silent ? "!" : "", party[partyidx].bot, 00696 party[partyidx].nick, party[partyidx].sock, 00697 reason ? reason : ""); 00698 send_tand_but(idx, OBUF, -l); 00699 #ifndef NO_OLD_BOTNET 00700 tandout_but(idx, "part %s %s %d\n", party[partyidx].bot, 00701 party[partyidx].nick, party[partyidx].sock); 00702 if (((idx < 0) || (b_numver(idx) >= NEAT_BOTNET)) && !silent) { 00703 tandout_but(idx, "chan %s %d %s has left the %s%s%s.\n", 00704 party[partyidx].bot, party[partyidx].chan, 00705 party[partyidx].nick, 00706 party[partyidx].chan ? "channel" : "party line", 00707 reason ? ": " : "", reason ? reason : ""); 00708 } 00709 #endif 00710 } 00711 }
void botnet_send_ping | ( | int | idx | ) |
Definition at line 272 of file botmsg.c.
References b_numver, NEAT_BOTNET, and tputs.
Referenced by check_botnet_pings().
00273 { 00274 #ifndef NO_OLD_BOTNET 00275 if (b_numver(idx) < NEAT_BOTNET) 00276 tputs(dcc[idx].sock, "ping\n", 5); 00277 else 00278 #endif 00279 tputs(dcc[idx].sock, "pi\n", 3); 00280 }
void botnet_send_pong | ( | int | idx | ) |
Definition at line 282 of file botmsg.c.
References b_numver, NEAT_BOTNET, and tputs.
Referenced by bot_ping().
00283 { 00284 #ifndef NO_OLD_BOTNET 00285 if (b_numver(idx) < NEAT_BOTNET) 00286 tputs(dcc[idx].sock, "pong\n", 5); 00287 else 00288 #endif 00289 tputs(dcc[idx].sock, "po\n", 3); 00290 }
void botnet_send_reject | ( | int | idx, | |
char * | fromp, | |||
char * | frombot, | |||
char * | top, | |||
char * | tobot, | |||
char * | reason | |||
) |
Definition at line 447 of file botmsg.c.
References b_numver, bot_flags, BOT_ISOLATE, from, NEAT_BOTNET, NOTENAMELEN, OBUF, simple_sprintf, tputs, and user.
Referenced by bot_nlinked(), bot_reject(), check_botnet_pings(), and cmd_boot().
00449 { 00450 int l; 00451 char to[NOTENAMELEN + 1], from[NOTENAMELEN + 1]; 00452 00453 if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) { 00454 if (tobot) { 00455 simple_sprintf(to, "%s@%s", top, tobot); 00456 top = to; 00457 } 00458 if (frombot) { 00459 simple_sprintf(from, "%s@%s", fromp, frombot); 00460 fromp = from; 00461 } 00462 if (!reason) 00463 reason = ""; 00464 #ifndef NO_OLD_BOTNET 00465 if (b_numver(idx) < NEAT_BOTNET) 00466 l = simple_sprintf(OBUF, "reject %s %s %s\n", fromp, top, reason); 00467 else 00468 #endif 00469 l = simple_sprintf(OBUF, "r %s %s %s\n", fromp, top, reason); 00470 tputs(dcc[idx].sock, OBUF, l); 00471 } 00472 }
void botnet_send_trace | ( | int | idx, | |
char * | to, | |||
char * | from, | |||
char * | buf | |||
) |
Definition at line 421 of file botmsg.c.
References b_numver, botnetnick, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_trace(), and cmd_trace().
00422 { 00423 int l; 00424 00425 #ifndef NO_OLD_BOTNET 00426 if (b_numver(idx) < NEAT_BOTNET) 00427 l = simple_sprintf(OBUF, "trace %s %s %s:%s\n", to, from, buf, botnetnick); 00428 else 00429 #endif 00430 l = simple_sprintf(OBUF, "t %s %s %s:%s\n", to, from, buf, botnetnick); 00431 tputs(dcc[idx].sock, OBUF, l); 00432 }
void botnet_send_traced | ( | int | idx, | |
char * | bot, | |||
char * | buf | |||
) |
Definition at line 408 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_trace(), and bot_traced().
00409 { 00410 int l; 00411 00412 #ifndef NO_OLD_BOTNET 00413 if (b_numver(idx) < NEAT_BOTNET) 00414 l = simple_sprintf(OBUF, "traced %s %s\n", bot, buf); 00415 else 00416 #endif 00417 l = simple_sprintf(OBUF, "td %s %s\n", bot, buf); 00418 tputs(dcc[idx].sock, OBUF, l); 00419 }
void botnet_send_unlink | ( | int | idx, | |
char * | who, | |||
char * | via, | |||
char * | bot, | |||
char * | reason | |||
) |
Definition at line 350 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_unlink(), and cmd_unlink().
00351 { 00352 int l; 00353 00354 #ifndef NO_OLD_BOTNET 00355 if (b_numver(idx) < NEAT_BOTNET) 00356 l = simple_sprintf(OBUF, "unlink %s %s %s %s\n", who, via, bot, reason); 00357 else 00358 #endif 00359 l = simple_sprintf(OBUF, "ul %s %s %s %s\n", who, via, bot, reason); 00360 tputs(dcc[idx].sock, OBUF, l); 00361 }
void botnet_send_unlinked | ( | int | idx, | |
char * | bot, | |||
char * | args | |||
) |
Definition at line 376 of file botmsg.c.
References b_numver, lastbot(), NEAT_BOTNET, OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
00377 { 00378 int l; 00379 00380 if (tands > 0) { 00381 l = simple_sprintf(OBUF, "un %s %s\n", bot, args ? args : ""); 00382 send_tand_but(idx, OBUF, l); 00383 #ifndef NO_OLD_BOTNET 00384 if ((idx >= 0) && (b_numver(idx) >= NEAT_BOTNET) && args && args[0]) 00385 tandout_but(idx, "chat %s %s\n", lastbot(bot), args); 00386 tandout_but(idx, "unlinked %s\n", bot); 00387 #endif 00388 } 00389 }
void botnet_send_update | ( | int | idx, | |
tand_t * | ptr | |||
) |
Definition at line 434 of file botmsg.c.
References tand_t_struct::bot, OBUF, send_tand_but(), tand_t_struct::share, simple_sprintf, tandout_but(), and tands.
Referenced by updatebot().
00435 { 00436 int l; 00437 00438 if (tands > 0) { 00439 l = simple_sprintf(OBUF, "u %s %c%D\n", ptr->bot, ptr->share, ptr->ver); 00440 send_tand_but(idx, OBUF, l); 00441 #ifndef NO_OLD_BOTNET 00442 tandout_but(idx, "update %s %c%d\n", ptr->bot, ptr->share, ptr->ver); 00443 #endif 00444 } 00445 }
void botnet_send_who | ( | int | idx, | |
char * | from, | |||
char * | to, | |||
int | chan | |||
) |
Definition at line 327 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
Referenced by bot_who(), and cmd_who().
00328 { 00329 int l; 00330 00331 #ifndef NO_OLD_BOTNET 00332 if (b_numver(idx) < NEAT_BOTNET) 00333 l = simple_sprintf(OBUF, "who %s %s %d\n", from, to, chan); 00334 else 00335 #endif 00336 l = simple_sprintf(OBUF, "w %s %s %D\n", from, to, chan); 00337 tputs(dcc[idx].sock, OBUF, l); 00338 }
void botnet_send_zapf | ( | int | idx, | |
char * | a, | |||
char * | b, | |||
char * | c | |||
) |
Definition at line 474 of file botmsg.c.
References b_numver, NEAT_BOTNET, OBUF, simple_sprintf, and tputs.
00475 { 00476 int l; 00477 00478 #ifndef NO_OLD_BOTNET 00479 if (b_numver(idx) < NEAT_BOTNET) 00480 l = simple_sprintf(OBUF, "zapf %s %s %s\n", a, b, c); 00481 else 00482 #endif 00483 l = simple_sprintf(OBUF, "z %s %s %s\n", a, b, c); 00484 tputs(dcc[idx].sock, OBUF, l); 00485 }
void botnet_send_zapf_broad | ( | int | idx, | |
char * | a, | |||
char * | b, | |||
char * | c | |||
) |
Definition at line 487 of file botmsg.c.
References OBUF, send_tand_but(), simple_sprintf, tandout_but(), and tands.
00488 { 00489 int l; 00490 00491 if (tands > 0) { 00492 l = simple_sprintf(OBUF, "zb %s %s%s%s\n", a, b ? b : "", b ? " " : "", c); 00493 send_tand_but(idx, OBUF, l); 00494 #ifndef NO_OLD_BOTNET 00495 tandout_but(idx, "zapf-broad %s\n", OBUF + 3); 00496 #endif 00497 } 00498 }
int simple_sprintf EGG_VARARGS_DEF | ( | char * | , | |
arg1 | ||||
) |
Definition at line 140 of file botmsg.c.
References char, EGG_VARARGS_START, int_to_base10, int_to_base64, and unsigned_int_to_base10().
00141 { 00142 char *buf, *format, *s; 00143 int c = 0, i; 00144 va_list va; 00145 00146 buf = EGG_VARARGS_START(char *, arg1, va); 00147 format = va_arg(va, char *); 00148 00149 while (*format && c < 1023) { 00150 if (*format == '%') { 00151 format++; 00152 switch (*format) { 00153 case 's': 00154 s = va_arg(va, char *); 00155 00156 break; 00157 case 'd': 00158 case 'i': 00159 i = va_arg(va, int); 00160 00161 s = int_to_base10(i); 00162 break; 00163 case 'D': 00164 i = va_arg(va, int); 00165 00166 s = int_to_base64((unsigned int) i); 00167 break; 00168 case 'u': 00169 i = va_arg(va, unsigned int); 00170 00171 s = unsigned_int_to_base10(i); 00172 break; 00173 case '%': 00174 buf[c++] = *format++; 00175 continue; 00176 case 'c': 00177 buf[c++] = (char) va_arg(va, int); 00178 00179 format++; 00180 continue; 00181 default: 00182 continue; 00183 } 00184 if (s) 00185 while (*s && c < 1023) 00186 buf[c++] = *s++; 00187 format++; 00188 } else 00189 buf[c++] = *format++; 00190 } 00191 va_end(va); 00192 buf[c] = 0; 00193 return c; 00194 }
void chanout_but EGG_VARARGS_DEF | ( | int | , | |
arg1 | ||||
) |
Definition at line 292 of file botmsg.c.
References b_numver, EGG_VARARGS_START, egg_vsnprintf, from, NEAT_BOTNET, OBUF, simple_sprintf, tbuf, and tputs.
00293 { 00294 int idx, l; 00295 char *from, *to, *tobot, *format; 00296 char tbuf[1024]; 00297 va_list va; 00298 00299 idx = EGG_VARARGS_START(int, arg1, va); 00300 from = va_arg(va, char *); 00301 to = va_arg(va, char *); 00302 tobot = va_arg(va, char *); 00303 format = va_arg(va, char *); 00304 00305 egg_vsnprintf(tbuf, 450, format, va); 00306 va_end(va); 00307 tbuf[sizeof(tbuf) - 1] = 0; 00308 00309 if (tobot) { 00310 #ifndef NO_OLD_BOTNET 00311 if (b_numver(idx) < NEAT_BOTNET) 00312 l = simple_sprintf(OBUF, "priv %s %s@%s %s\n", from, to, tobot, tbuf); 00313 else 00314 #endif 00315 l = simple_sprintf(OBUF, "p %s %s@%s %s\n", from, to, tobot, tbuf); 00316 } else { 00317 #ifndef NO_OLD_BOTNET 00318 if (b_numver(idx) < NEAT_BOTNET) 00319 l = simple_sprintf(OBUF, "priv %s %s %s\n", from, to, tbuf); 00320 else 00321 #endif 00322 l = simple_sprintf(OBUF, "p %s %s %s\n", from, to, tbuf); 00323 } 00324 tputs(dcc[idx].sock, OBUF, l); 00325 }
char* int_to_base10 | ( | int | val | ) |
Definition at line 95 of file botmsg.c.
00096 { 00097 static char buf_base10[17]; 00098 int p = 0; 00099 int i = 16; 00100 00101 buf_base10[16] = 0; 00102 if (!val) { 00103 buf_base10[15] = '0'; 00104 return buf_base10 + 15; 00105 } 00106 if (val < 0) { 00107 p = 1; 00108 val *= -1; 00109 } 00110 while (val) { 00111 i--; 00112 buf_base10[i] = '0' + (val % 10); 00113 val /= 10; 00114 } 00115 if (p) { 00116 i--; 00117 buf_base10[i] = '-'; 00118 } 00119 return buf_base10 + i; 00120 }
char* int_to_base64 | ( | unsigned int | val | ) |
Definition at line 77 of file botmsg.c.
References tobase64array.
00078 { 00079 static char buf_base64[12]; 00080 int i = 11; 00081 00082 buf_base64[11] = 0; 00083 if (!val) { 00084 buf_base64[10] = 'A'; 00085 return buf_base64 + 10; 00086 } 00087 while (val) { 00088 i--; 00089 buf_base64[i] = tobase64array[val & 0x3f]; 00090 val = val >> 6; 00091 } 00092 return buf_base64 + i; 00093 }
void send_tand_but | ( | int | x, | |
char * | buf, | |||
int | len | |||
) |
Definition at line 198 of file botmsg.c.
References b_numver, bot_flags, BOT_ISOLATE, DCC_BOT, dcc_total, NEAT_BOTNET, tputs, and user.
Referenced by botnet_send_act(), botnet_send_away(), botnet_send_bye(), botnet_send_chan(), botnet_send_chat(), botnet_send_idle(), botnet_send_infoq(), botnet_send_join_idx(), botnet_send_join_party(), botnet_send_nkch(), botnet_send_nkch_part(), botnet_send_nlinked(), botnet_send_part_idx(), botnet_send_part_party(), botnet_send_unlinked(), botnet_send_update(), and botnet_send_zapf_broad().
00199 { 00200 int i, iso = 0; 00201 00202 if (len < 0) { 00203 len = -len; 00204 iso = 1; 00205 } 00206 for (i = 0; i < dcc_total; i++) 00207 if ((dcc[i].type == &DCC_BOT) && (i != x) && 00208 (b_numver(i) >= NEAT_BOTNET) && 00209 (!iso || !(bot_flags(dcc[i].user) & BOT_ISOLATE))) 00210 tputs(dcc[i].sock, buf, len); 00211 }
char* unsigned_int_to_base10 | ( | unsigned int | val | ) |
Definition at line 122 of file botmsg.c.
Referenced by EGG_VARARGS_DEF().
00123 { 00124 static char buf_base10[16]; 00125 int i = 15; 00126 00127 buf_base10[15] = 0; 00128 if (!val) { 00129 buf_base10[14] = '0'; 00130 return buf_base10 + 14; 00131 } 00132 while (val) { 00133 i--; 00134 buf_base10[i] = '0' + (val % 10); 00135 val /= 10; 00136 } 00137 return buf_base10 + i; 00138 }
char botnetnick[] |
char OBUF[1024] [static] |
Definition at line 39 of file botmsg.c.
Referenced by botnet_send_act(), botnet_send_away(), botnet_send_chan(), botnet_send_chat(), botnet_send_filereject(), botnet_send_filereq(), botnet_send_filesend(), botnet_send_idle(), botnet_send_infoq(), botnet_send_join_idx(), botnet_send_join_party(), botnet_send_link(), botnet_send_motd(), botnet_send_nkch(), botnet_send_nkch_part(), botnet_send_nlinked(), botnet_send_part_idx(), botnet_send_part_party(), botnet_send_reject(), botnet_send_trace(), botnet_send_traced(), botnet_send_unlink(), botnet_send_unlinked(), botnet_send_update(), botnet_send_who(), botnet_send_zapf(), botnet_send_zapf_broad(), and EGG_VARARGS_DEF().
int tands |
Definition at line 43 of file botnet.c.
Referenced by addbot(), botnet_change(), botnet_send_act(), botnet_send_away(), botnet_send_bye(), botnet_send_chan(), botnet_send_chat(), botnet_send_idle(), botnet_send_join_idx(), botnet_send_join_party(), botnet_send_nkch(), botnet_send_nkch_part(), botnet_send_nlinked(), botnet_send_part_idx(), botnet_send_part_party(), botnet_send_unlinked(), botnet_send_update(), botnet_send_zapf_broad(), rembot(), tell_bots(), and tell_bottree().
char tobase64array[64] [static] |
{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '[', ']' }
Definition at line 68 of file botmsg.c.
Referenced by int_to_base64().