/* tandcmd.c -- handles: commands that comes across the botnet userfile transfer and update commands from sharebots dprintf'ized, 10nov95 */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include "eggdrop.h" #include "tandem.h" #include "users.h" #include "proto.h" extern tand_t tand[]; extern int tands; extern char origbotname[]; extern int dcc_total; extern struct dcc_t dcc[]; extern int isolate; extern int noshare; extern int passive; extern int share_users; extern char motdfile[]; extern struct userrec *userlist; extern char ver[]; extern char os[]; extern char botchan[]; /* static buffer for goofy bot stuff */ char TBUF[1024]; void fake_alert(idx) int idx; { tprintf(dcc[idx].sock,"chat %s NOTICE: Fake message rejected.\n", origbotname); } /* chan */ void tand_chan(idx,par) int idx; char *par; { char *from=TBUF,*s=TBUF+512,*p; int i,chan; nsplit(from,par); chan=atoi(par); nsplit(NULL,par); p=strchr(from,'@'); if (p==NULL) { sprintf(s,"*** (%s) %s",from,par); p=from; } else { sprintf(s,"<%s> %s",from,par); p++; } i=nextbot(p); if (i!=idx) { fake_alert(idx); return; } if (!isolate) { chanout(chan,"%s\n",s); #ifdef TCL if (strchr(from,'@')!=NULL) check_tcl_chat(from,chan,par); #endif } tandout_but(idx,"chan %s %d %s\n",from,chan,par); } /* chat -- only from bots */ void tand_chat(idx,par) int idx; char *par; { char *from=TBUF; int i; nsplit(from,par); if (strchr(from,'@')!=NULL) { fake_alert(idx); return; } /* make sure the bot is valid */ i=nextbot(from); if (i!=idx) { fake_alert(idx); return; } if (!isolate) chatout("*** (%s) %s\n",from,par); tandout_but(idx,"chat %s %s\n",from,par); } void tand_act(idx,par) int idx; char *par; { /* act is outdated */ } /* actchan */ void tand_actchan(idx,par) int idx; char *par; { char *from=TBUF,*p; int i,chan; nsplit(from,par); p=strchr(from,'@'); if (p==NULL) { /* how can a bot do an action? */ fake_alert(idx); return; } p++; i=nextbot(p); if (i!=idx) { fake_alert(idx); return; } chan=atoi(par); nsplit(NULL,par); if (!isolate) chanout(chan,"* %s %s\n",from,par); tandout_but(idx,"actchan %s %d %s\n",from,chan,par); } /* priv */ void tand_priv(idx,par) int idx; char *par; { char *from=TBUF,*p,*to=TBUF+600,*tobot=TBUF+512; int i; nsplit(from,par); nsplit(tobot,par); tobot[40]=0; splitc(to,tobot,'@'); p=strchr(from,'@'); if (p!=NULL) p++; else p=from; i=nextbot(p); if ((i!=idx) || (!to[0])) { fake_alert(idx); return; } if (strcasecmp(tobot,origbotname)==0) { /* for me! */ if (p==from) add_note(to,from,par,-2,0); else { i=add_note(to,from,par,-1,0); if (i==0) /* failed */ tprintf(dcc[idx].sock,"priv %s %s No such user %s.\n",origbotname, from,to); else if (i==2) /* stored */ tprintf(dcc[idx].sock,"priv %s %s Not online; note stored.\n", origbotname,from); else /* success! */ tprintf(dcc[idx].sock,"priv %s %s Note sent to %s.\n",origbotname, from,to); } } else { /* pass it on */ i=nextbot(tobot); if (i<0) tandout_but(idx,"priv %s %s@%s %s\n",from,to,tobot,par); else tprintf(dcc[i].sock,"priv %s %s@%s %s\n",from,to,tobot,par); } } void tand_bye(idx,par) int idx; char *par; { log(LOG_TAND,"Disconnected from: %s",dcc[idx].nick); tandout_but(idx,"chat %s Disconnected from: %s\n",origbotname, dcc[idx].nick); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); cancel_user_xfer(idx); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); chatout("*** Disconnected from: %s\n",dcc[idx].nick); tprintf(dcc[idx].sock,"*bye\n"); close(dcc[idx].sock); lostdcc(idx); } /* who */ void tand_who(idx,par) int idx; char *par; { char *p; char *from=TBUF,*to=TBUF+512; int i; nsplit(from,par); p=strchr(from,'@'); if (p==NULL) { sprintf(to,"%s@%s",from,dcc[idx].nick); strcpy(from,to); } nsplit(to,par); if (strcasecmp(to,origbotname)==0) to[0]=0; /* (for me) */ if (to[0]) { /* pass it on */ i=nextbot(to); if (i<0) tandout_but(idx,"who %s %s %s\n",from,to,par); else tprintf(dcc[i].sock,"who %s %s %s\n",from,to,par); } else { tell_tandem_who(dcc[idx].sock,from,atoi(par)); } } void tand_version(idx,par) int idx; char *par; { strcpy(dcc[idx].u.tand->version,par); if ((share_users) && (get_attr_handle(dcc[idx].nick)&BOT_SHARE)) { if (passive) { if (dcc[idx].u.tand->status&STAT_CALLED) { if (can_resync(dcc[idx].nick)) tprintf(dcc[idx].sock,"resync?\n"); else tprintf(dcc[idx].sock,"userfile?\n"); dcc[idx].u.tand->status|=STAT_OFFERED; } } else { if (can_resync(dcc[idx].nick)) tprintf(dcc[idx].sock,"resync?\n"); else tprintf(dcc[idx].sock,"userfile?\n"); dcc[idx].u.tand->status|=STAT_OFFERED; } } } /* who? -> whom */ void tand_whoq(idx,par) int idx; char *par; { char *to=TBUF; nsplit(to,par); answer_whom(dcc[idx].sock,to,atoi(par)); tandout_but(idx,"who? %s %d\n",to,atoi(par)); } /* info? -> send priv */ void tand_infoq(idx,par) int idx; char *par; { #ifdef TCL tprintf(dcc[idx].sock,"priv %s %s %s +Tcl (%s)\n",origbotname,par,ver, botchan); #else tprintf(dcc[idx].sock,"priv %s %s %s (%s)\n",origbotname,par,ver,botchan); #endif tandout_but(idx,"info? %s\n",par); } /* whom */ void tand_whom(idx,par) int idx; char *par; { char *to=TBUF,*tobot,*nick=TBUF+40,*bot=TBUF+80,*ss=TBUF+120,plus=' '; int i,sock; nsplit(to,par); tobot=strchr(to,'@'); if (tobot==NULL) { fake_alert(idx); return; } tobot++; to[39]=0; nsplit(nick,par); nick[12]=0; nsplit(bot,par); bot[10]=0; i=nextbot(bot); if (i!=idx) { fake_alert(idx); return; } if (strcasecmp(tobot,origbotname)==0) { sock=(-1); splitc(ss,to,':'); if (ss[0]) sock=atoi(ss); if (nick[0]=='+') { plus='+'; strcpy(nick,&nick[1]); } if (nick[0]=='-') nick[0]=' '; tobot=strchr(to,'@'); *tobot=0; /* splice down to nick now */ for (i=0; istatus&=~STAT_PINGED; } /* link */ void tand_link_cmd(idx,par) int idx; char *par; { char *from=TBUF,*bot=TBUF+512,*rfrom=TBUF+41; int i; nsplit(from,par); nsplit(bot,par); from[40]=0; if (strcasecmp(bot,origbotname)==0) { strcpy(rfrom,from); splitc(NULL,rfrom,':'); log(LOG_CMDS,"#%s# link %s",rfrom,par); if (tandem_link(from,-2,par)) tprintf(dcc[idx].sock,"priv %s %s Attempting link to %s ...\n", origbotname,from,par); else tprintf(dcc[idx].sock,"priv %s %s Can't link there.\n",origbotname, from); } else { i=nextbot(bot); if (i<0) tandout_but(idx,"link %s %s %s\n",from,bot,par); else tprintf(dcc[i].sock,"link %s %s %s\n",from,bot,par); } } /* unlink */ void tand_unlink_cmd(idx,par) int idx; char *par; { char *from=TBUF,*bot=TBUF+512,*rfrom=TBUF+41; int i; char *p; nsplit(from,par); nsplit(bot,par); from[40]=0; if (strcasecmp(bot,origbotname)==0) { strcpy(rfrom,from); splitc(NULL,rfrom,':'); log(LOG_CMDS,"#%s# unlink %s",rfrom,par); if (tandem_unlink(-2,par)) { p=strchr(from,'@'); if (p!=NULL) { /* idx will change after unlink -- get new idx */ i=nextbot(p+1); if (i>=0) tprintf(dcc[i].sock,"priv %s %s Unlinked %s.\n",origbotname, from,par); } } else { tandout("unlinked %s\n",par); /* just to clear trash from link lists */ p=strchr(from,'@'); if (p!=NULL) { /* ditto above, about idx */ i=nextbot(p+1); if (i>=0) tprintf(dcc[i].sock,"priv %s %s Can't unlink %s.\n", origbotname,from,par); } } } else { i=nextbot(bot); if (i<0) tandout_but(idx,"unlink %s %s %s\n",from,bot,par); else tprintf(dcc[i].sock,"unlink %s %s %s\n",from,bot,par); } } void tand_ufno(idx,par) int idx; char *par; { log(LOG_TAND,"User file rejected by %s: %s",dcc[idx].nick,par); dcc[idx].u.tand->status&=~STAT_OFFERED; if (!(dcc[idx].u.tand->status&STAT_GETTING)) dcc[idx].u.tand->status&=~STAT_SHARE; } void tand_ufyes(idx,par) int idx; char *par; { if (dcc[idx].u.tand->status&STAT_OFFERED) { dcc[idx].u.tand->status&=~STAT_OFFERED; dcc[idx].u.tand->status|=STAT_SHARE; dcc[idx].u.tand->status|=STAT_SENDING; start_sending_users(idx); log(LOG_TAND,"Sending user file to %s",dcc[idx].nick); } } void tand_userfileq(idx,par) int idx; char *par; { int ok=1,i; flush_tbuf(dcc[idx].nick); if (!share_users) tprintf(dcc[idx].sock,"uf-no Not sharing userfile.\n"); else if (!passive) tprintf(dcc[idx].sock,"uf-no Aggressive mode active.\n"); else if (!(get_attr_handle(dcc[idx].nick) & BOT_SHARE)) tprintf(dcc[idx].sock,"uf-no You are not +s for me.\n"); else { for (i=0; istatus&STAT_SHARE) && (dcc[i].u.tand->status&STAT_GETTING)) ok=0; if (!ok) tprintf(dcc[idx].sock,"uf-no Already downloading a userfile.\n"); else { tprintf(dcc[idx].sock,"uf-yes\n"); dcc[idx].u.tand->status|=STAT_SHARE; clear_userlist(dcc[idx].u.tand->user); /* copy just the tandem-bots into the new userlist (wanna keep those) */ dcc[idx].u.tand->user=dup_userlist(1); dcc[idx].u.tand->status|=STAT_GETTING; log(LOG_TAND,"Downloading user file from %s",dcc[idx].nick); } } } void tand_resyncq(idx,par) int idx; char *par; { if (!share_users) tprintf(dcc[idx].sock,"resync-no Not sharing userfile.\n"); else if (!(get_attr_handle(dcc[idx].nick) & BOT_SHARE)) tprintf(dcc[idx].sock,"resync-no You are not +s for me.\n"); else if (can_resync(dcc[idx].nick)) { tprintf(dcc[idx].sock,"resync!\n"); dump_resync(dcc[idx].sock,dcc[idx].nick); dcc[idx].u.tand->status&=~STAT_OFFERED; dcc[idx].u.tand->status|=STAT_SHARE; log(LOG_TAND,"Resync'd user file with %s",dcc[idx].nick); } else if (passive) { tprintf(dcc[idx].sock,"resync!\n"); dcc[idx].u.tand->status&=~STAT_OFFERED; dcc[idx].u.tand->status|=STAT_SHARE; log(LOG_TAND,"Resyncing user file from %s",dcc[idx].nick); } else tprintf(dcc[idx].sock,"resync-no No resync buffer.\n"); } void tand_resync(idx,par) int idx; char *par; { if (dcc[idx].u.tand->status&STAT_OFFERED) { if (can_resync(dcc[idx].nick)) { dump_resync(dcc[idx].sock,dcc[idx].nick); dcc[idx].u.tand->status&=~STAT_OFFERED; dcc[idx].u.tand->status|=STAT_SHARE; log(LOG_TAND,"Resync'd user file with %s",dcc[idx].nick); } } } void tand_resync_no(idx,par) int idx; char *par; { log(LOG_TAND,"Resync refused by %s: %s",dcc[idx].nick,par); flush_tbuf(dcc[idx].nick); tprintf(dcc[idx].sock,"userfile?\n"); } #define CHKSEND if (!(dcc[idx].u.tand->status&STAT_SENDING)) return #define CHKGET if (!(dcc[idx].u.tand->status&STAT_GETTING)) return #define CHKSHARE if (!(dcc[idx].u.tand->status&STAT_SHARE)) return void tand_ackuser(idx,par) int idx; char *par; { CHKSEND; if (strcasecmp(par,dcc[idx].u.tand->cursend)==0) { if (send_next_user(idx)) log(LOG_TAND,"Finished sending user list to %s.",dcc[idx].nick); } else { log(LOG_TAND,"* Desync sending user list to %s.",dcc[idx].nick); log(LOG_TAND,"* (Re-sending user '%s'.)",dcc[idx].u.tand->cursend); resend_user(idx); } } void tand_end_userlist(idx,par) int idx; char *par; { CHKGET; log(LOG_TAND,"Finished receiving user list from %s.",dcc[idx].nick); dcc[idx].u.tand->status&=~STAT_GETTING; use_new_buf(idx); write_userfile(); noshare=0; } void tand_user(idx,par) int idx; char *par; { CHKGET; store_new_user(idx,par); } void tand_email(idx,par) int idx; char *par; { CHKGET; set_handle_email(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_dccdir(idx,par) int idx; char *par; { CHKGET; set_handle_dccdir(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_comment(idx,par) int idx; char *par; { CHKGET; set_handle_comment(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_info(idx,par) int idx; char *par; { CHKGET; set_handle_info(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_xtra(idx,par) int idx; char *par; { CHKGET; set_handle_xtra(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_laston(idx,par) int idx; char *par; { CHKGET; set_handle_laston2(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,atol(par)); } void tand_host(idx,par) int idx; char *par; { CHKGET; addhost_by_handle2(dcc[idx].u.tand->user,dcc[idx].u.tand->cursend,par); } void tand_end_user(idx,par) int idx; char *par; { CHKGET; tprintf(dcc[idx].sock,"ackuser %s\n",dcc[idx].u.tand->cursend); noshare=0; } void tand_chpass(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chpass %s\n",par); noshare=1; nsplit(hand,par); change_pass_by_handle(hand,par); noshare=0; log(LOG_CMDS,"%s: newpass %s",dcc[idx].nick,hand); } void tand_chhand(idx,par) int idx; char *par; { char *hand=TBUF; int i; CHKSHARE; shareout_but(idx,"chhand %s\n",par); noshare=1; nsplit(hand,par); change_handle(hand,par); noshare=0; log(LOG_CMDS,"%s: handle %s->%s",dcc[idx].nick,hand,par); for (i=0; ichannel>=0)) chanout2(dcc[i].u.chat->channel,"Nick change: %s -> %s\n", dcc[i].nick,par); strcpy(dcc[i].nick,par); } } void tand_chattr(idx,par) int idx; char *par; { char *hand=TBUF,*s=TBUF+512; int oatr; CHKSHARE; shareout_but(idx,"chattr %s\n",par); noshare=1; nsplit(hand,par); /* don't let tandem flags be altered */ oatr=(get_attr_handle(hand) & USER_BOT); set_attr_handle(hand,(atoi(par) & ~USER_BOT)|oatr); noshare=0; flags2str(get_attr_handle(hand),s); log(LOG_CMDS,"%s: chattr %s %s",dcc[idx].nick,hand,s); } void tand_newuser(idx,par) int idx; char *par; { char *etc=TBUF,*etc2=TBUF+41,*etc3=TBUF+121; CHKSHARE; shareout_but(idx,"newuser %s\n",par); noshare=1; nsplit(etc,par); etc[40]=0; nsplit(etc2,par); etc2[80]=0; nsplit(etc3,par); userlist=adduser(userlist,etc,etc2,etc3,atoi(par)); noshare=0; log(LOG_CMDS,"%s: newuser %s",dcc[idx].nick,etc); } void tand_killuser(idx,par) int idx; char *par; { CHKSHARE; shareout_but(idx,"killuser %s\n",par); log(LOG_CMDS,"%s: killuser %s",dcc[idx].nick,par); noshare=1; deluser(par); noshare=0; } void tand_pls_host(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"+host %s\n",par); noshare=1; nsplit(hand,par); addhost_by_handle(hand,par); noshare=0; log(LOG_CMDS,"%s: +host %s %s",dcc[idx].nick,hand,par); } void tand_mns_host(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"-host %s\n",par); noshare=1; nsplit(hand,par); delhost_by_handle(hand,par); noshare=0; log(LOG_CMDS,"%s: -host %s %s",dcc[idx].nick,hand,par); } void tand_chemail(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chemail %s\n",par); noshare=1; nsplit(hand,par); set_handle_email(userlist,hand,par); noshare=0; log(LOG_CMDS,"%s: change email %s",dcc[idx].nick,hand); } void tand_chdccdir(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chdccdir %s\n",par); noshare=1; nsplit(hand,par); set_handle_dccdir(userlist,hand,par); noshare=0; } void tand_chcomment(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chcomment %s\n",par); noshare=1; nsplit(hand,par); set_handle_comment(userlist,hand,par); noshare=0; log(LOG_CMDS,"%s: change comment %s",dcc[idx].nick,hand); } void tand_chinfo(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chinfo %s\n",par); noshare=1; nsplit(hand,par); set_handle_info(userlist,hand,par); noshare=0; log(LOG_CMDS,"%s: change info %s",dcc[idx].nick,hand); } void tand_chxtra(idx,par) int idx; char *par; { char *hand=TBUF; CHKSHARE; shareout_but(idx,"chxtra %s\n",par); noshare=1; nsplit(hand,par); set_handle_xtra(userlist,hand,par); noshare=0; log(LOG_CMDS,"%s: change xtra %s",dcc[idx].nick,hand); } void tand_mns_ban(idx,par) int idx; char *par; { CHKSHARE; shareout_but(idx,"-ban %s\n",par); log(LOG_CMDS,"%s: cancel ban %s",dcc[idx].nick,par); noshare=1; unprog_ban(par); noshare=0; } void tand_mns_ignore(idx,par) int idx; char *par; { CHKSHARE; shareout_but(idx,"-ignore %s\n",par); log(LOG_CMDS,"%s: cancel ignore %s",dcc[idx].nick,par); noshare=1; unprog_ignore(par); noshare=0; } void tand_pls_ban(idx,par) int idx; char *par; { time_t now=time(NULL); char *ban=TBUF,*tm=TBUF+512; CHKSHARE; shareout_but(idx,"+ban %s\n",par); noshare=1; nsplit(ban,par); nsplit(tm,par); log(LOG_CMDS,"%s: ban %s (%s)",dcc[idx].nick,ban,par); if (atol(tm)==0) prog_ban(ban,0,par); else prog_ban(ban,now-atol(tm),par); noshare=0; } void tand_pls_ignore(idx,par) int idx; char *par; { time_t now=time(NULL); char *ign=TBUF; CHKSHARE; shareout_but(idx,"+ignore %s\n",par); noshare=1; nsplit(ign,par); log(LOG_CMDS,"%s: ignore %s",dcc[idx].nick,ign); if (atol(par)==0) prog_ignore(ign,0); else prog_ignore(ign,now-atoi(par)); noshare=0; } void tand_nlinked(idx,par) int idx; char *par; { char *newbot=TBUF,*next=TBUF+512; nsplit(newbot,par); nsplit(next,par); if (strlen(newbot)>9) newbot[9]=0; if (strlen(next)>9) next[9]=0; if (!next[0]) { log(LOG_TAND,"Invalid eggnet protocol from %s (zapfing)",dcc[idx].nick); chatout("*** Disconnected %s (invalid bot)\n",dcc[idx].nick); tandout_but(idx,"chat %s Disconnected %s (invalid bot)\n",origbotname, dcc[idx].nick); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); cancel_user_xfer(idx); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); tprintf(dcc[idx].sock,"error invalid eggnet protocol for 'nlinked'\n"); tprintf(dcc[idx].sock,"bye\n"); close(dcc[idx].sock); lostdcc(idx); } else if ((in_chain(newbot)) || (strcasecmp(newbot,origbotname)==0)) { /* loop! */ log(LOG_TAND,"Detected loop: disconnecting %s (mutual: %s)",dcc[idx].nick, newbot); chatout("*** Loop (%s): disconnected %s\n",newbot,dcc[idx].nick); tandout_but(idx,"chat %s Loop (%s): disconnected %s\n",origbotname,newbot, dcc[idx].nick); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); cancel_user_xfer(idx); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); tprintf(dcc[idx].sock,"bye\n"); close(dcc[idx].sock); lostdcc(idx); } else { int atr=get_attr_handle(dcc[idx].nick); addbot(newbot,dcc[idx].nick); got_tand_next(newbot,next); tandout_but(idx,"nlinked %s %s %s\n",newbot,next,par); #ifdef TCL check_tcl_link(newbot,par); #endif if (atr & BOT_LEAF) { tprintf(dcc[idx].sock,"reject %s %s\n",origbotname,newbot); log(LOG_TAND,"Rejecting connection to %s by leaf %s",newbot, dcc[idx].nick); } if (get_attr_handle(newbot) & BOT_REJECT) { tprintf(dcc[idx].sock,"reject %s %s\n",origbotname,newbot); log(LOG_TAND,"Rejecting bot %s from %s",newbot,dcc[idx].nick); } } } void tand_linked(idx,par) int idx; char *par; { log(LOG_TAND,"Older bot detected (unsupported)"); chatout("*** Disconnected %s (outdated)\n",dcc[idx].nick); tandout_but(idx,"chat %s Disconnected %s (outdated)\n",origbotname, dcc[idx].nick); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); cancel_user_xfer(idx); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); close(dcc[idx].sock); lostdcc(idx); } void tand_unlinked(idx,par) int idx; char *par; { rembot(par,dcc[idx].nick); unvia(idx,par); tandout_but(idx,"unlinked %s\n",par); } void tand_trace(idx,par) int idx; char *par; { char *from=TBUF,*dest=TBUF+512; int i; /* trace */ nsplit(from,par); nsplit(dest,par); if (strcasecmp(dest,origbotname)==0) { tprintf(dcc[idx].sock,"traced %s %s:%s\n",from,par,origbotname); } else { i=nextbot(dest); if (i<0) tandout_but(idx,"trace %s %s %s:%s\n",from,dest,par,origbotname); else tprintf(dcc[i].sock,"trace %s %s %s:%s\n",from,dest,par,origbotname); } } void tand_traced(idx,par) int idx; char *par; { char *to=TBUF,*ss=TBUF+512,*p; int i,sock; /* traced */ nsplit(to,par); p=strchr(to,'@'); if (p==NULL) p=to; else p++; if (strcasecmp(p,origbotname)==0) { splitc(ss,to,':'); if (ss[0]) sock=atoi(ss); else sock=(-1); for (i=0; i %s\n",par); } else { i=nextbot(p); if (i<0) tandout_but(idx,"traced %s %s\n",to,par); else tprintf(dcc[i].sock,"traced %s %s\n",to,par); } } /* reject */ void tand_reject(idx,par) int idx; char *par; { char *from=TBUF,*who=TBUF+81,*destbot=TBUF+41; int i; nsplit(from,par); from[40]=0; if (strchr(par,'@')==NULL) { i=nextbot(par); if (i<0) { tprintf(dcc[idx].sock,"priv %s %s Can't reject %s (doesn't exist)\n", origbotname,from,par); } else if (strcasecmp(dcc[i].nick,par)==0) { /* i'm the connection to the rejected bot */ log(LOG_TAND,"%s rejected %s",from,dcc[i].nick); tprintf(dcc[i].sock,"bye\n"); tandout_but(i,"unlinked %s\n",dcc[i].nick); tandout_but(i,"chat %s Disconnected %s (rejected by %s)\n",origbotname, dcc[i].nick,from); chatout("*** Disconnected %s (rejected by %s)\n",dcc[i].nick,from); cancel_user_xfer(i); rembot(dcc[i].nick,dcc[i].nick); unvia(i,dcc[i].nick); close(dcc[i].sock); lostdcc(i); } else { if (i<0) tandout_but(idx,"reject %s %s\n",from,par); else tprintf(dcc[i].sock,"reject %s %s\n",from,par); } } else { /* rejecting user */ nsplit(destbot,par); destbot[40]=0; splitc(who,destbot,'@'); if (strcasecmp(destbot,origbotname)==0) { /* kick someone here! */ int ok=0; #ifdef SHAREBOT_BOOTS if (!(dcc[idx].u.tand->status&STAT_SHARE)) { add_note(from,origbotname,"Remote boots are not allowed.",-1,0); return; } #endif #ifdef REMOTE_BOOTS for (i=0; (istatus|=STAT_LEAF; /* set capitalization the way they want it */ noshare=1; change_handle(dcc[idx].nick,par); noshare=0; strcpy(dcc[idx].nick,par); } void tand_handshake(idx,par) int idx; char *par; { change_pass_by_handle(dcc[idx].nick,par); if ((dcc[idx].u.tand->status&STAT_SHARE) && (!(dcc[idx].u.tand->status&STAT_GETTING)) && (!(dcc[idx].u.tand->status&STAT_SENDING))) { noshare=1; change_pass_by_handle(origbotname,par); noshare=0; } } void tand_trying(idx,par) int idx; char *par; { tandout_but(idx,"trying %s\n",par); /* currently ignore */ } void tand_end_trying(idx,par) int idx; char *par; { tandout_but(idx,"*trying %s\n",par); /* currently ignore */ } /* possibly op another bot */ void tand_op(idx,par) int idx; char *par; { if (get_attr_handle(dcc[idx].nick) & USER_OP) { if (!me_op()) { tprintf(dcc[idx].sock,"op-no I'm not chop either.\n"); return; } if (!ischanmember(par)) { tprintf(dcc[idx].sock,"op-no %s is not on the channel.\n",par); return; } if (member_op(par)) { tprintf(dcc[idx].sock,"op-no %s is already a chop.\n",par); return; } add_mode('+','o',par); log(LOG_CMDS,"%s: op %s",dcc[idx].nick,par); } else tprintf(dcc[idx].sock,"op-no You are not +o for me.\n"); } void tand_opno(idx,par) int idx; char *par; { log(LOG_TAND,"%s won't op me: %s",dcc[idx].nick,par); } /* used to send a direct msg from Tcl on one bot to Tcl on another */ /* zapf */ void tand_zapf(idx,par) int idx; char *par; { char *from=TBUF,*to=TBUF+512; int i; nsplit(from,par); nsplit(to,par); i=nextbot(from); if (i!=idx) { fake_alert(idx); return; } if (strcasecmp(to,origbotname)==0) { /* for me! */ #ifdef TCL char opcode[512]; nsplit(opcode,par); check_tcl_tand(from,opcode,par); #endif return; } i=nextbot(to); if (i<0) tandout_but(idx,"zapf %s %s %s\n",from,to,par); else tprintf(dcc[i].sock,"zapf %s %s %s\n",from,to,par); } /* used to send a global msg from Tcl on one bot to every other bot */ /* zapf-broad */ void tand_zapfbroad(idx,par) int idx; char *par; { char *from=TBUF,*opcode=TBUF+512; int i; nsplit(from,par); nsplit(opcode,par); i=nextbot(from); if (i!=idx) { fake_alert(idx); return; } #ifdef TCL check_tcl_tand(from,opcode,par); #endif tandout_but(idx,"zapf-broad %s %s %s\n",from,opcode,par); } /* show motd to someone */ void tand_motd(idx,par) int idx; char *par; { FILE *vv; char *s=TBUF,*who=TBUF+512; int i; nsplit(who,par); if ((!par[0]) || (strcasecmp(par,origbotname)==0)) { log(LOG_CMDS,"#%s# motd",who); vv=fopen(motdfile,"r"); if (vv!=NULL) { tprintf(dcc[idx].sock,"priv %s %s --- MOTD file:\n",origbotname,who); while (!feof(vv)) { fgets(s,120,vv); if (!feof(vv)) { if (s[strlen(s)-1]=='\n') s[strlen(s)-1]=0; if (!s[0]) strcpy(s," "); help_subst(s,who,0,0); if (s[0]) tprintf(dcc[idx].sock,"priv %s %s %s\n",origbotname,who,s); } } fclose(vv); } else tprintf(dcc[idx].sock,"priv %s %s No MOTD file. :(\n",origbotname, who); } else { /* pass it on */ i=nextbot(par); if (i<0) tandout_but(idx,"motd %s %s\n",who,par); else tprintf(dcc[i].sock,"motd %s %s\n",who,par); } } /* assoc */ void tand_assoc(idx,par) int idx; char *par; { char *s=TBUF; nsplit(s,par); if (par[0]=='0') { kill_assoc(atoi(s)); tandout_but(idx,"assoc %s 0\n",s); } else if (get_assoc(par)!=atoi(s)) { /* new one i didn't know about -- pass it on */ add_assoc(par,atoi(s)); tandout_but(idx,"assoc %s %s\n",s,par); } }