/* functions for dealing with a tandem bot */ #if HAVE_CONFIG_H #include #endif #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[]; void tand_chan(idx,z,par) int idx,z; char *par; { char from[40],s[512]; int i,chan; nsplit(from,par); chan=atoi(par); nsplit(NULL,par); if (strchr(from,'@')==NULL) sprintf(s,"*** (%s) %s",from,par); else sprintf(s,"<%s> %s",from,par); if (!isolate) for (i=0; ichannel==chan) tprintf(dcc[i].sock,"%s\n",s); tandout_but(idx,"chan %s %d %s\n",from,chan,par); } void tand_chat(idx,z,par) int idx,z; char *par; { char nk[40],from[40],s[512]; int i,frombot=0; nsplit(from,par); if (strchr(from,'@')==NULL) { /* notice from a bot */ if ((strcasecmp(from,origbotname)==0) || (!in_chain(from))) { /* from me?! -or- from nonexistant bot?! */ /* don't pass it on -- instead, warn others */ tprintf(z,"chat %s WARNING: FAKE BOT NOTICES\n",origbotname); return; } sprintf(s,"*** (%s) %s",from,par); frombot=1; } else sprintf(s,"<%s> %s",from,par); /* make sure the bot is valid */ splitc(nk,from,'@'); if ((strcasecmp(from,origbotname)==0) || (!in_chain(from))) { tprintf(z,"chat %s WARNING: FAKE BOT NOTICES\n",origbotname); return; } if (!isolate) for (i=0; ichannel>=0)) || (dcc[i].u.chat->channel==0))) tprintf(dcc[i].sock,"%s\n",s); if (nk[0]) tandout_but(idx,"chat %s@%s %s\n",nk,from,par); else tandout_but(idx,"chat %s %s\n",from,par); } void tand_act(idx,z,par) int idx,z; char *par; { char nk[40],from[40]; int i; nsplit(from,par); splitc(nk,from,'@'); if ((!nk[0]) || (strcasecmp(from,origbotname)==0) || (!in_chain(from))) { tprintf(z,"chat %s WARNING: FAKE BOT NOTICES\n",origbotname); return; } if (!isolate) for (i=0; ichannel>=0)) tprintf(dcc[i].sock,"* %s@%s %s\n",nk,from,par); tandout_but(idx,"act %s@%s %s\n",nk,from,par); } void tand_actchan(idx,z,par) int idx,z; char *par; { char nk[40],from[40]; int i,chan; nsplit(from,par); splitc(nk,from,'@'); if ((!nk[0]) || (strcasecmp(from,origbotname)==0) || (!in_chain(from))) { tprintf(z,"chat %s WARNING: FAKE BOT NOTICES\n",origbotname); return; } chan=atoi(par); nsplit(NULL,par); if (!isolate) for (i=0; ichannel==chan)) tprintf(dcc[i].sock,"* %s@%s %s\n",nk,from,par); tandout_but(idx,"actchan %s@%s %d %s\n",nk,from,chan,par); } void tand_priv(idx,z,par) int idx,z; char *par; { char from[40],frombot[40],nk[40],to[40],tobot[40]; int i; nsplit(from,par); nsplit(tobot,par); splitc(to,tobot,'@'); strcpy(frombot,from); splitc(nk,frombot,'@'); if ((!to[0]) || (strcasecmp(frombot,origbotname)==0) || (!in_chain(frombot))) { tprintf(z,"chat %s WARNING: FAKE BOT NOTICES\n",origbotname); return; } if (!to[0]) { strcpy(to,tobot); tobot[0]=0; } if (strcasecmp(tobot,origbotname)==0) { /* for me! */ if (strchr(from,'@')==NULL) add_note(to,from,par,-2,0); else { i=add_note(to,from,par,-1,0); if (i==0) /* failed */ tprintf(z,"priv %s %s No such user %s.\n",origbotname,from,to); else if (i==2) /* stored */ tprintf(z,"priv %s %s Not online; note stored.\n",origbotname,from); else /* success! */ tprintf(z,"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,z,par) int idx,z; 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(z,"*bye\n"); close(z); shutdown(z,2); lostdcc(idx); } void tand_who(idx,z,par) int idx,z; char *par; { char *p; char from[40],new[40],to[40]; int i,chan; nsplit(from,par); p=strchr(from,'@'); if (p==NULL) { sprintf(new,"%s@%s",from,dcc[idx].nick); strcpy(from,new); } 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(z,from,atoi(par)); } } void tand_version(idx,z,par) int idx,z; 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(z,"resync?\n"); else tprintf(z,"userfile?\n"); dcc[idx].u.tand->status|=STAT_OFFERED; } } else { if (can_resync(dcc[idx].nick)) tprintf(z,"resync?\n"); else tprintf(z,"userfile?\n"); dcc[idx].u.tand->status|=STAT_OFFERED; } } } void tand_whoq(idx,z,par) int idx,z; char *par; { char to[81]; /* who? -> whom */ nsplit(to,par); answer_whom(z,to,atoi(par)); tandout_but(idx,"who? %s %d\n",to,atoi(par)); } void tand_infoq(idx,z,par) int idx,z; char *par; { /* info? -> send priv */ #ifdef TCL tprintf(z,"priv %s %s %s +Tcl (%s)\n",origbotname,par,ver,botchan); #else tprintf(z,"priv %s %s %s (%s)\n",origbotname,par,ver,botchan); #endif tandout_but(idx,"info? %s\n",par); } void tand_whom(idx,z,par) int idx,z; char *par; { char to[40],tobot[40],nick[40],bot[40],ss[40],plus=' '; int i,sock; nsplit(tobot,par); splitc(to,tobot,'@'); if (strcasecmp(tobot,origbotname)==0) { nsplit(nick,par); nsplit(bot,par); sock=(-1); splitc(ss,to,':'); if (ss[0]) sock=atoi(ss); if (nick[0]=='+') { plus='+'; strcpy(nick,&nick[1]); } if (nick[0]=='-') nick[0]=' '; for (i=0; istatus&=~STAT_PINGED; } void tand_link_cmd(idx,z,par) int idx,z; char *par; { char from[40],bot[40],rfrom[40]; int i; /* link */ nsplit(from,par); nsplit(bot,par); if (strcasecmp(bot,origbotname)==0) { strcpy(rfrom,from); splitc(NULL,rfrom,':'); log(LOG_CMDS,"#%s# link %s",from,par); if (tandem_link(-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); } } void tand_unlink_cmd(idx,z,par) int idx,z; char *par; { char from[40],bot[40],rfrom[40]; int i; nsplit(from,par); nsplit(bot,par); if (strcasecmp(bot,origbotname)==0) { strcpy(rfrom,from); splitc(NULL,rfrom,':'); log(LOG_CMDS,"#%s# unlink %s",rfrom,par); if (tandem_unlink(-2,par)) { if (strchr(from,'@')!=NULL) tprintf(dcc[idx].sock,"priv %s %s Unlinked %s.\n",origbotname,from, par); } else { tandout("unlinked %s\n",par); /* just to clear trash from link lists */ if (strchr(from,'@')!=NULL) tprintf(dcc[idx].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,z,par) int idx,z; 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,z,par) int idx,z; 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(z,idx); log(LOG_TAND,"Sending user file to %s",dcc[idx].nick); } } void tand_userfileq(idx,z,par) int idx,z; char *par; { int ok=1,i; flush_tbuf(dcc[idx].nick); if (!share_users) tprintf(z,"uf-no Not sharing userfile.\n"); else if (!passive) tprintf(z,"uf-no Aggressive mode active.\n"); else if (!(get_attr_handle(dcc[idx].nick) & BOT_SHARE)) tprintf(z,"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(z,"uf-no Already downloading a userfile.\n"); else { tprintf(z,"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,z,par) int idx,z; char *par; { if (!share_users) tprintf(z,"resync-no Not sharing userfile.\n"); else if (!(get_attr_handle(dcc[idx].nick) & BOT_SHARE)) tprintf(z,"resync-no You are not +s for me.\n"); else if (can_resync(dcc[idx].nick)) { tprintf(z,"resync!\n"); dump_resync(z,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(z,"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(z,"resync-no No resync buffer.\n"); } void tand_resync(idx,z,par) int idx,z; char *par; { if (dcc[idx].u.tand->status&STAT_OFFERED) { if (can_resync(dcc[idx].nick)) { dump_resync(z,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,z,par) int idx,z; char *par; { log(LOG_TAND,"Resync refused by %s: %s",dcc[idx].nick,par); flush_tbuf(dcc[idx].nick); tprintf(z,"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,z,par) int idx,z; char *par; { CHKSEND; if (strcasecmp(par,cursend(idx))==0) { if (send_next_user(z,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'.)",cursend(idx)); resend_user(z,idx); } } void tand_end_userlist(idx,z,par) int idx,z; 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,z,par) int idx,z; char *par; { CHKGET; store_new_user(idx,par); } void tand_email(idx,z,par) int idx,z; char *par; { CHKGET; set_handle_email(dcc[idx].u.tand->user,cursend(idx),par); } void tand_dccdir(idx,z,par) int idx,z; char *par; { CHKGET; set_handle_dccdir(dcc[idx].u.tand->user,cursend(idx),par); } void tand_comment(idx,z,par) int idx,z; char *par; { CHKGET; set_handle_comment(dcc[idx].u.tand->user,cursend(idx),par); } void tand_info(idx,z,par) int idx,z; char *par; { CHKGET; set_handle_info(dcc[idx].u.tand->user,cursend(idx),par); } void tand_laston(idx,z,par) int idx,z; char *par; { CHKGET; set_handle_laston2(dcc[idx].u.tand->user,cursend(idx),atol(par)); } void tand_host(idx,z,par) int idx,z; char *par; { CHKGET; addhost_by_handle2(dcc[idx].u.tand->user,cursend(idx),par); } void tand_end_user(idx,z,par) int idx,z; char *par; { CHKGET; tprintf(z,"ackuser %s\n",cursend(idx)); noshare=0; dcc[idx].host[0]=0; } void tand_chpass(idx,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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)) { chanout(dcc[i].u.chat->channel,"*** Nick change: %s -> %s\n", dcc[i].nick,par); tandout("chan %s %d Nick change: %s -> %s\n",origbotname, dcc[i].u.chat->channel,dcc[i].nick,par); } strcpy(dcc[i].nick,par); } } void tand_chattr(idx,z,par) int idx,z; char *par; { char hand[40],s[21]; 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_TANDEM); set_attr_handle(hand,(atoi(par) & ~USER_TANDEM)|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,z,par) int idx,z; char *par; { char etc[40],etc2[40],etc3[40]; CHKSHARE; shareout_but(idx,"newuser %s\n",par); noshare=1; nsplit(etc,par); nsplit(etc2,par); 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,z,par) int idx,z; 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,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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,z,par) int idx,z; char *par; { char hand[40]; 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_mns_ban(idx,z,par) int idx,z; 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,z,par) int idx,z; 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,z,par) int idx,z; char *par; { time_t now=time(NULL); char ban[121],tm[40]; 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,z,par) int idx,z; char *par; { time_t now=time(NULL); char ign[121]; 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,z,par) int idx,z; char *par; { char newbot[20],next[20]; 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(z,"error invalid eggnet protocol for 'nlinked'\n"); tprintf(z,"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(z,"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); 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 (atr & 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,z,par) int idx,z; char *par; { if ((in_chain(par)) || (strcasecmp(par,origbotname)==0)) { /* loop! */ log(LOG_TAND,"Detected loop: disconnecting %s (mutual: %s)",dcc[idx].nick, par); chatout("*** Loop (%s): disconnected %s\n",par,dcc[idx].nick); tandout_but(idx,"chat %s Loop (%s): disconnected %s\n",origbotname, par,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); shutdown(dcc[idx].sock,2); lostdcc(idx); } else { if (strlen(par)>9) par[9]=0; log(LOG_MISC,"NOTICE: ancient-style bot link: %s",par); addbot(par,dcc[idx].nick); tandout_but(idx,"linked %s\n",par); tprintf(dcc[idx].sock,"trace *@%s %s %s\n",origbotname,par,origbotname); if (get_attr_handle(dcc[idx].nick) & BOT_LEAF) { tprintf(dcc[idx].sock,"reject %s %s\n",origbotname,par); log(LOG_TAND,"Rejecting connection to %s by leaf %s",par,dcc[idx].nick); } } } void tand_unlinked(idx,z,par) int idx,z; char *par; { rembot(par,dcc[idx].nick); unvia(idx,par); tandout_but(idx,"unlinked %s\n",par); } void tand_trace(idx,z,par) int idx,z; char *par; { char from[40],dest[40]; int i; /* trace */ nsplit(from,par); nsplit(dest,par); if (strcasecmp(dest,origbotname)==0) { tprintf(z,"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,z,par) int idx,z; char *par; { char *p,tobot[40],to[40],bot[40],ss[40]; int i,sock; /* traced */ nsplit(tobot,par); splitc(to,tobot,'@'); if (strcasecmp(tobot,origbotname)==0) { splitc(ss,to,':'); if (ss[0]) sock=atoi(ss); else sock=(-1); for (i=0; i %s\n",par); } else { i=nextbot(tobot); if (i<0) tandout_but(idx,"traced %s@%s %s\n",to,tobot,par); else tprintf(dcc[i].sock,"traced %s@%s %s\n",to,tobot,par); } } void tand_reject(idx,z,par) int idx,z; char *par; { char from[40],who[40],destbot[81]; int i; /* reject */ nsplit(from,par); if (strchr(par,'@')==NULL) { i=nextbot(par); if (i<0) { tprintf(z,"priv %s %s You can't reject that cos it doesn't exist.\n", origbotname,from); } 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); shutdown(dcc[i].sock,2); 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); splitc(who,destbot,'@'); if (strcasecmp(destbot,origbotname)==0) { /* kick someone here! */ #ifdef REMOTE_BOOTS int ok=0; for (i=0; (ichannel>=0) { chanout_but(i,dcc[i].u.chat->channel, "*** %s booted %s from the party line: %s\n", from,dcc[i].nick,par); if (!isolate) tandout("chan %s %d %s booted %s from the party line: %s\n", origbotname,dcc[i].u.chat->channel,from,dcc[i].nick, par); } log(LOG_CMDS,"#%s# boot %s (%s)",from,dcc[i].nick,par); if (dcc[i].sock!=STDOUT) { close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); } else { tprintf(STDOUT,"\n### SIMULATION RESET\n\n"); dcc_chatter(i); } } #else tprintf(z,"priv %s %s Remote boots are not allowed.\n",origbotname,from); #endif } else { i=nextbot(destbot); if (i<0) tandout_but(idx,"reject %s %s@%s %s\n",from,who,destbot,par); else tprintf(dcc[i].sock,"reject %s %s@%s %s\n",from,who,destbot,par); } } } void tand_thisbot(idx,z,par) int idx,z; char *par; { if (strcasecmp(par,dcc[idx].nick)!=0) { log(LOG_TAND,"Wrong bot: wanted %s, got %s",dcc[idx].nick,par); tprintf(z,"bye\n"); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); tandout_but(idx,"chat %s Disconnected %s (imposter)\n",origbotname, dcc[idx].nick); chatout("*** Disconnected %s (imposter)\n",dcc[idx].nick); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); close(dcc[idx].sock); shutdown(dcc[idx].sock,2); lostdcc(idx); return; } if (get_attr_handle(par) & BOT_REJECT) { log(LOG_TAND,"Rejecting bot %s",par); tprintf(z,"bye\n"); tandout_but(idx,"unlinked %s\n",dcc[idx].nick); tandout_but(idx,"chat %s Disconnected %s (rejected)\n",origbotname, dcc[idx].nick); chatout("*** Disconnected %s (rejected)\n",dcc[idx].nick); rembot(dcc[idx].nick,dcc[idx].nick); unvia(idx,dcc[idx].nick); close(dcc[idx].sock); shutdown(dcc[idx].sock,2); lostdcc(idx); return; } if (get_attr_handle(par) & BOT_LEAF) dcc[idx].u.tand->status|=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,z,par) int idx,z; 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,z,par) int idx,z; char *par; { tandout_but(idx,"trying %s\n",par); /* currently ignore */ } void tand_end_trying(idx,z,par) int idx,z; char *par; { tandout_but(idx,"*trying %s\n",par); /* currently ignore */ } /* possibly op another bot */ void tand_op(idx,z,par) int idx,z; char *par; { if (get_attr_handle(dcc[idx].nick) & USER_OP) { if (!me_op()) { tprintf(z,"op-no I'm not chop either.\n"); return; } if (!ischanmember(par)) { tprintf(z,"op-no %s is not on the channel.\n",par); return; } if (member_op(par)) { tprintf(z,"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(z,"op-no You are not +o for me.\n"); } void tand_opno(idx,z,par) int idx,z; char *par; { log(LOG_TAND,"%s won't op me: %s",dcc[idx].nick,par); } /* zapf <[code] [param]> */ void tand_zapf(idx,z,par) int idx,z; char *par; { char from[41],to[41]; int i; nsplit(from,par); nsplit(to,par); 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); } /* zapf-broad <[code] [param]> */ void tand_zapfbroad(idx,z,par) int idx,z; char *par; { char from[41],opcode[512]; nsplit(from,par); nsplit(opcode,par); #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,z,par) int idx,z; char *par; { FILE *vv; char s[121],who[81]; 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(z,"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(z,"priv %s %s %s\n",origbotname,who,s); } } fclose(vv); } else tprintf(z,"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); } }