/* deal with msgs from people */ #include #include #include #include "eggdrop.h" extern int serv; extern char botuserhost[]; extern char newserver[]; extern int newserverport; extern int require_x; extern int use_info; extern char origbotname[]; extern int dcc_total; extern struct dcc_t dcc[]; extern char botname[]; extern char curchan[]; extern int isolate; extern char botuser[]; extern char dccdir[]; extern int periodic_save; /* generic command to gave an attribute to a user */ int cmd_pls_attr(idx,z,attr,attrname,who) int idx,z,attr; char *attrname,*who; { if (match_attr_handle(who,USER_TANDEM)) { if ((attr==USER_PARTY) && (strcasecmp(attrname,"party")==0)) { tprintf(z,"This only makes sense for humans.\n"); return 0; } } else { if ((attr==BOT_AUTO) || (attr==BOT_LEAF) || (attr==BOT_REJECT) || ((attr==BOT_SHARE) && (strcasecmp(attrname,"share")==0))) { tprintf(z,"This only makes sense for tandem-bots.\n"); return 0; } } if ((attr==USER_OP) && (match_attr_handle(who,USER_DEOP))) { tprintf(z,"(Removed deop.)\n"); change_attr(who,'-',USER_DEOP); } if ((attr==USER_DEOP) && (match_attr_handle(who,USER_OP))) { tprintf(z,"(Removed op.)\n"); change_attr(who,'-',USER_OP); } if ((attr==BOT_AUTO) && (match_attr_handle(who,BOT_REJECT))) { tprintf(z,"(Removed rejection.)\n"); change_attr(who,'-',BOT_REJECT); } if ((attr==BOT_REJECT) && (match_attr_handle(who,BOT_AUTO))) { tprintf(z,"(Removed auto-connect.)\n"); change_attr(who,'-',BOT_AUTO); } if ((match_attr_handle(who,attr)) || (match_attr(who,attr))) { tprintf(z,"Nothing changed.\n"); return 0; } if (change_attr(who,'+',attr)) { log(LOG_CMDS,"#%s# +%s %s",dcc[idx].nick,attrname,who); switch(attr) { case USER_DEOP: tprintf(z,"Now deopping %s.\n",who); break; case USER_TANDEM: tprintf(z,"%s is now a robot.\n",who); break; case USER_COMMON: tprintf(z,"%s marked as a common/public irc site.\n",who); break; default: tprintf(z,"Gave %s flag to %s.\n",attrname,who); } return 1; } else tprintf(z,"Failed.\n"); return 0; } /* generic command to remove an attribute from a user */ int cmd_mns_attr(idx,z,attr,attrname,who) int idx,z,attr; char *attrname,*who; { if (match_attr_handle(who,USER_TANDEM)) { if ((attr==USER_PARTY) && (strcasecmp(attrname,"party")==0)) { tprintf(z,"This only makes sense for humans.\n"); return 0; } } else { if ((attr==BOT_AUTO) || (attr==BOT_LEAF) || ((attr==BOT_SHARE) && (strcasecmp(attrname,"share")==0))) { tprintf(z,"This only makes sense for tandem-bots.\n"); return 0; } } if ((!match_attr_handle(who,attr)) && (!match_attr(who,attr))) { tprintf(z,"Nothing changed.\n"); return 0; } if (change_attr(who,'-',attr)) { log(LOG_CMDS,"#%s# -%s %s",dcc[idx].nick,attrname,who); switch(attr) { case USER_DEOP: tprintf(z,"No longer deopping %s.\n",who); break; case USER_TANDEM: tprintf(z,"%s is now a human.\n",who); break; default: tprintf(z,"Took %s flag from %s.\n",attrname,who); } return 1; } else tprintf(z,"Failed.\n"); return 0; } int cmd_talk(idx,z,msg) int idx,z; char *msg; { if (strcasecmp(msg,"talk")==0) { dcc[idx].u.chat->status|=STAT_TALK; tprintf(z,"/// OK\n"); } /* future commands go here */ } int cmd_who(idx,z,par) int idx,z; char *par; { int i; if (par[0]) { log(LOG_CMDS,"#%s# who %s",dcc[idx].nick,par); if (strcasecmp(par,origbotname)==0) tell_who(z); else { i=nextbot(par); if (i<0) { tprintf(z,"I don't think any such bot is linked in.\n"); tandout("who %s@%s %s\n",dcc[idx].nick,origbotname,par); } else tprintf(dcc[i].sock,"who %s@%s %s\n",dcc[idx].nick,origbotname, par); } } else { log(LOG_CMDS,"#%s# who",dcc[idx].nick); tell_who(z); } } int cmd_botinfo(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# botinfo",dcc[idx].nick); tandout("info? %s@%s\n",dcc[idx].nick,origbotname); } int cmd_whom(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# whom",dcc[idx].nick); if (!isolate) tandout("who? %s@%s\n",dcc[idx].nick,origbotname); answer_local_whom(z); } int cmd_me(idx,z,par) int idx,z; char *par; { int i; if (dcc[idx].u.chat->away!=NULL) not_away(idx,z); for (i=0; istatus&STAT_BLIND))) tprintf(dcc[i].sock,"* %s %s\n",dcc[idx].nick,par); if (!isolate) if (dcc[i].type==DCC_TANDEM) tprintf(dcc[i].sock,"act %s@%s %s\n",dcc[idx].nick,origbotname,par); } } int cmd_motd(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# motd",dcc[idx].nick); show_motd(idx); } int cmd_files(idx,z,par) int idx,z; char *par; { if (dccdir[0]==0) tprintf(z,"File transfer area deactivated.\n"); else { if ((!(dcc[idx].u.chat->status&STAT_MASTER)) && (require_x) && (!(dcc[idx].u.chat->status&STAT_XFER))) { tprintf(z,"You don't have access to the file area.\n"); } else { log(LOG_CMDS,"#%s# files",dcc[idx].nick); tprintf(z,"Entering file system...\n"); chatout("*** %s left the party line.\n",dcc[idx].nick); if (!isolate) tandout("chat %s %s left the party line.\n",origbotname, dcc[idx].nick); set_files(idx,z); dcc[idx].type=DCC_FILES; dcc[idx].u.file->chat->status|=STAT_CHAT; welcome_to_files(idx,z); } } } int cmd_note(idx,z,par) int idx,z; char *par; { char handle[20]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: note \n"); } else add_note(handle,dcc[idx].nick,par,z); } int cmd_away(idx,z,par) int idx,z; char *par; { if (strlen(par)>60) par[60]=0; set_away(idx,z,par); } int cmd_newpass(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# newpass...",dcc[idx].nick); if (strlen(par)>9) par[9]=0; change_pass_by_handle(dcc[idx].nick,par); tprintf(z,"Changed password to '%s'\n",par); } int cmd_bots(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# bots",dcc[idx].nick); tell_bots(z); } int cmd_bottree(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# bottree",dcc[idx].nick); tell_bottree(z); } int cmd_help(idx,z,par) int idx,z; char *par; { if (dcc[idx].u.chat->status&STAT_PARTY) { log(LOG_CMDS,"#%s# help",dcc[idx].nick); tellhelp(z,"help.party",1,0); return; } if (par[0]) { log(LOG_CMDS,"#%s# help %s",dcc[idx].nick,par); tellhelp(z,par,1,dcc[idx].u.chat->status&STAT_MASTER); } else { log(LOG_CMDS,"#%s# help",dcc[idx].nick); tellhelp(z,"help",1,dcc[idx].u.chat->status&STAT_MASTER); } } int cmd_act(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# act %s",dcc[idx].nick,par); mprintf(serv,"PRIVMSG %s :\001ACTION %s\001\n",curchan,par); } int cmd_msg(idx,z,par) int idx,z; char *par; { char nick[20]; split(nick,par); if (!nick[0]) { tprintf(z,"Usage: .msg \n"); } else { log(LOG_CMDS,"#%s# msg %s %s",dcc[idx].nick,nick,par); mprintf(serv,"PRIVMSG %s :%s\n",nick,par); } } int cmd_say(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# say %s",dcc[idx].nick,par); mprintf(serv,"PRIVMSG %s :%s\n",curchan,par); } int cmd_kickban(idx,z,par) int idx,z; char *par; { if (!me_op()) { tprintf(z,"I can't help you now because I'm not a channel op.\n"); return; } log(LOG_CMDS,"#%s# kickban %s",dcc[idx].nick,par); user_kickban(z,par); } int cmd_op(idx,z,par) int idx,z; char *par; { if (!me_op()) { tprintf(z,"I can't help you now because I'm not a channel op.\n"); return; } log(LOG_CMDS,"#%s# op %s",dcc[idx].nick,par); give_op(par,z); } int cmd_deop(idx,z,par) int idx,z; char *par; { if (!me_op()) { tprintf(z,"I can't help you now because I'm not a channel op.\n"); return; } log(LOG_CMDS,"#%s# deop %s",dcc[idx].nick,par); give_deop(par,z); } int cmd_kick(idx,z,par) int idx,z; char *par; { char who[512]; if (!me_op()) { tprintf(z,"I can't help you now because I'm not a channel op.\n"); return; } nsplit(who,par); tprintf(z,"Attempting to kick %s ...\n",who); if (par[0]) { log(LOG_CMDS,"#%s# kick %s (%s)",dcc[idx].nick,who,par); tprintf(serv,"KICK %s %s :%s\n",curchan,who,par); } else { log(LOG_CMDS,"#%s# kick %s",dcc[idx].nick,who); tprintf(serv,"KICK %s %s :requested\n",curchan,who); } } int cmd_invite(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# invite %s",dcc[idx].nick,par); tprintf(z,"Attempting to invite %s to the party line...\n",par); mprintf(serv,"NOTICE %s :%s invites you to join the party line.\n",par, dcc[idx].nick); mprintf(serv,"NOTICE %s :Type /DCC CHAT %s\n",par,botname); } int cmd_resetbans(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# resetbans",dcc[idx].nick); tprintf(z,"Resetting bans...\n"); resetbans(); } int cmd_pls_ban(idx,z,par) int idx,z; char *par; { char who[512],note[512],s[121]; if (!par[0]) { tprintf(z,"Usage: +ban [reason]\n"); return; } nsplit(who,par); if (!par[0]) strcpy(note,dcc[idx].nick); else { sprintf(note,"%s: %s",dcc[idx].nick,par); note[40]=0; } sprintf(s,"%s!%s",botname,botuserhost); if (wild_match(who,s)) { tprintf(z,"Duh... I think I'll ban myself today, Marge!\n"); log(LOG_CMDS,"#%s# attempted +ban %s",dcc[idx].nick,who); return; } log(LOG_CMDS,"#%s# +ban %s (%s)",dcc[idx].nick,who,note); tprintf(z,"New ban: %s (%s)\n",who,note); prog_ban(who,0L,note); if (me_op()) add_mode('+','b',who); recheck_channel(); } int cmd_mns_ban(idx,z,par) int idx,z; char *par; { int i=unprog_ban(par); if (i>0) { log(LOG_CMDS,"#%s# -ban %s",dcc[idx].nick,par); tprintf(z,"Removed ban: %s\n",par); if (me_op()) add_mode('-','b',par); } else { /* try -ban by numbers */ if (atoi(par)>0) { if (kill_chanban(z,0-i,atoi(par))) log(LOG_CMDS,"#%s# -ban %s",dcc[idx].nick,par); } else if (kill_chanban_name(z,par)) log(LOG_CMDS,"#%s# -ban %s",dcc[idx].nick,par); } } int cmd_bans(idx,z,par) int idx,z; char *par; { if (strcasecmp(par,"all")==0) { log(LOG_CMDS,"#%s# bans all",dcc[idx].nick); tell_bans(z,1); } else { log(LOG_CMDS,"#%s# bans",dcc[idx].nick); tell_bans(z,0); } } int cmd_channel(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# channel",dcc[idx].nick); tell_verbose_chan_info(z); } int cmd_addlog(idx,z,par) int idx,z; char *par; { tprintf(z,"Placed entry in the log file.\n"); log(LOG_MISC,"%s: %s",dcc[idx].nick,par); } int cmd_servers(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# servers",dcc[idx].nick); tell_servers(z); } int cmd_whois(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# whois %s",dcc[idx].nick,par); tell_user_ident(z,par,dcc[idx].u.chat->status&STAT_MASTER); } int cmd_match(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# match %s",dcc[idx].nick,par); tell_users_match(z,par,dcc[idx].u.chat->status&STAT_MASTER); } int cmd_status(idx,z,par) int idx,z; char *par; { if (strcasecmp(par,"all")==0) { log(LOG_CMDS,"#%s# status all",dcc[idx].nick); tell_verbose_status(z,1); tell_mem_status_dcc(z); tprintf(z,"\n"); tell_settings(z); } else { log(LOG_CMDS,"#%s# status",dcc[idx].nick); tell_verbose_status(z,1); tell_mem_status_dcc(z); } } int cmd_dccstat(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# dccstat",dcc[idx].nick); tell_dcc(z); } int cmd_pls_ignore(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# +ignore %s",dcc[idx].nick,par); tprintf(z,"Now ignoring: %s\n",par); prog_ignore(par,0L); } int cmd_mns_ignore(idx,z,par) int idx,z; char *par; { if (unprog_ignore(par)) { log(LOG_CMDS,"#%s# -ignore %s",dcc[idx].nick,par); tprintf(z,"No longer ignoring: %s\n",par); } else tprintf(z,"Can't find that ignore.\n"); } int cmd_ignores(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# ignores",dcc[idx].nick); tell_ignores(z); } int cmd_boot(idx,z,par) int idx,z; char *par; { int i,files=0,ok=0; char who[512]; nsplit(who,par); for (i=0; istatus|=STAT_BLIND; j=1; if (dcc[i].u.chat->status&STAT_MASTER) tprintf(dcc[i].sock,"*** %s just blinded you!\n",dcc[idx].nick); } if (!j) tprintf(z,"Who? No such person in dcc chat.\n"); else log(LOG_CMDS,"#%s# +blind %s",dcc[idx].nick,par); } int cmd_mns_blind(idx,z,par) int idx,z; char *par; { int i,j=0; for (i=0; istatus&STAT_BLIND) { tprintf(z,"%s has now been un-blinded.\n",dcc[i].nick); dcc[i].u.chat->status&=~STAT_BLIND; j=1; if (dcc[i].u.chat->status&STAT_MASTER) tprintf(dcc[i].sock,"*** %s just un-blinded you.\n",dcc[idx].nick); } else { j=1; tprintf(z,"They weren't blinded in the first place.\n"); } } if (!j) tprintf(z,"Who? No such person on the party line.\n"); else log(LOG_CMDS,"#%s# -blind %s",dcc[idx].nick,par); } char *maskname(); int cmd_console(idx,z,par) int idx,z; char *par; { char nick[512]; int i,ok=0; split(nick,par); if ((nick[0]) && (dcc[idx].u.chat->status&STAT_MASTER)) { for (i=0; icon_flags=logmodes(par); tprintf(z,"Set console of %s to: %s (%s)\n",dcc[i].nick,par, maskname(dcc[i].u.chat->con_flags)); tprintf(dcc[i].sock,"%s set your console to: %s (%s)\n",dcc[idx].nick, par,maskname(dcc[i].u.chat->con_flags)); } if (!ok) tprintf(z,"No such user on the party line!\n"); else log(LOG_CMDS,"#%s# console %s %s",dcc[idx].nick,nick,par); } else { dcc[idx].u.chat->con_flags=logmodes(par); if (!(dcc[idx].u.chat->status&STAT_MASTER)) dcc[idx].u.chat->con_flags&=~(LOG_MISC|LOG_CMDS); tprintf(z,"Set your console to: %s (%s)\n",par, maskname(dcc[idx].u.chat->con_flags)); log(LOG_CMDS,"#%s# console %s",dcc[idx].nick,par); } } #ifndef TCL int cmd_set(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# set %s",dcc[idx].nick,par); prog_set(par,z); } #endif int cmd_pls_op(idx,z,par) int idx,z; char *par; { int i; if (cmd_pls_attr(idx,z,USER_OP,"op",par)) { recheck_channel(); for (i=0; istatus&=~STAT_PARTY; } } int cmd_pls_xfer(idx,z,par) int idx,z; char *par; { int i; if (cmd_pls_attr(idx,z,USER_XFER,"xfer",par)) { for (i=0; istatus|=STAT_XFER; } } int cmd_pls_deop(idx,z,par) int idx,z; char *par; { if (cmd_pls_attr(idx,z,USER_DEOP,"deop",par)) recheck_channel(); } int cmd_pls_friend(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_FRIEND,"friend",par); } int cmd_pls_tandem(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_TANDEM,"tandem",par); } int cmd_pls_party(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_PARTY,"party",par); } int cmd_pls_share(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,BOT_SHARE,"share",par); } int cmd_pls_auto(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,BOT_AUTO,"auto",par); } int cmd_pls_leaf(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,BOT_LEAF,"leaf",par); } int cmd_pls_reject(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,BOT_REJECT,"reject",par); } int cmd_pls_master(idx,z,par) int idx,z; char *par; { int i; if (cmd_pls_attr(idx,z,USER_MASTER,"master",par)) { for (i=0; istatus|=STAT_MASTER; } } } int cmd_pls_kick(idx,z,par) int idx,z; char *par; { if (cmd_pls_attr(idx,z,USER_KICK,"kick",par)) recheck_channel(); } int cmd_pls_common(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_COMMON,"common",par); } int cmd_mns_op(idx,z,par) int idx,z; char *par; { int i; if (cmd_mns_attr(idx,z,USER_OP,"op",par)) { for (i=0; istatus|=STAT_PARTY; } } int cmd_mns_xfer(idx,z,par) int idx,z; char *par; { int i; if (cmd_mns_attr(idx,z,USER_XFER,"xfer",par)) { for (i=0; istatus&=~STAT_XFER; } } int cmd_mns_deop(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_DEOP,"deop",par); } int cmd_mns_friend(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_FRIEND,"friend",par); } int cmd_mns_tandem(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_TANDEM,"tandem",par); } int cmd_mns_party(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_PARTY,"party",par); } int cmd_mns_share(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,BOT_SHARE,"share",par); } int cmd_mns_auto(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,BOT_AUTO,"auto",par); } int cmd_mns_leaf(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,BOT_LEAF,"leaf",par); } int cmd_mns_reject(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,BOT_REJECT,"reject",par); } int cmd_mns_master(idx,z,par) int idx,z; char *par; { int i; if (cmd_mns_attr(idx,z,USER_MASTER,"master",par)) { for (i=0; istatus&=~STAT_MASTER; } } } int cmd_mns_kick(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_KICK,"kick",par); } int cmd_mns_common(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_COMMON,"common",par); } int cmd_adduser(idx,z,par) int idx,z; char *par; { if (is_user(par)) { tprintf(z,"Someone already exists by that name.\n"); return; } if ((par==NULL) || (!par[0])) { tprintf(z,"Usage: adduser \n"); return; } log(LOG_CMDS,"#%s# adduser %s",dcc[idx].nick,par); add_chan_user(par,z); } int cmd_pls_user(idx,z,par) int idx,z; char *par; { char handle[121]; nsplit(handle,par); if (!par[0]) { tprintf(z,"Format: +user \n"); return; } if (is_user(handle)) { tprintf(z,"Someone already exists by that name.\n"); return; } log(LOG_CMDS,"#%s# +user %s %s",dcc[idx].nick,handle,par); adduser(handle,par,"nopass",0); tprintf(z,"Added %s (%s) with no password or flags.\n",handle,par); } int cmd_pls_bot(idx,z,par) int idx,z; char *par; { char handle[121]; nsplit(handle,par); if (!par[0]) { tprintf(z,"Format: +bot \n"); return; } if (is_user(handle)) { tprintf(z,"Someone already exists by that name.\n"); return; } log(LOG_CMDS,"#%s# +bot %s %s",dcc[idx].nick,handle,par); adduser(handle,"none","nopass",USER_TANDEM); set_handle_info(handle,par); tprintf(z,"Added bot '%s' with address '%s' and no password.\n", handle,par); } int cmd_mns_user(idx,z,par) int idx,z; char *par; { if (deluser(par)) { log(LOG_CMDS,"#%s# -user %s",dcc[idx].nick,par); tprintf(z,"Deleted %s.\n",par); } else tprintf(z,"Failed.\n"); } int cmd_handle(idx,z,par) int idx,z; char *par; { char hand[121]; int i; split(hand,par); if (!hand[0]) { tprintf(z,"Format: handle \n"); return; } if (strlen(par)>9) par[9]=0; if (is_user(par)) { tprintf(z,"Already a user %s.\n",par); return; } if (change_handle(hand,par)){ log(LOG_CMDS,"#%s# handle %s %s",dcc[idx].nick,hand,par); tprintf(z,"Changed.\n"); for (i=0; i %s\n",dcc[i].nick,par); tandout("chat %s Nick change: %s -> %s\n",origbotname,dcc[i].nick,par); strcpy(dcc[i].nick,par); } } else tprintf(z,"Failed.\n"); } int cmd_nick(idx,z,par) int idx,z; char *par; { if (!par[0]) { tprintf(z,"Format: nick \n"); return; } if (strlen(par)>9) par[9]=0; if (is_user(par)) { tprintf(z,"Somebody is already using %s.\n",par); return; } if (change_handle(dcc[idx].nick,par)) { log(LOG_CMDS,"#%s# nick %s",dcc[idx].nick,par); tprintf(z,"Okay, changed.\n"); chatout("*** Nick change: %s -> %s\n",dcc[idx].nick,par); tandout("chat %s Nick change: %s -> %s\n",origbotname,dcc[idx].nick,par); strcpy(dcc[idx].nick,par); } else tprintf(z,"Failed.\n"); } int cmd_pls_host(idx,z,par) int idx,z; char *par; { char handle[121]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: +host \n"); return; } else { log(LOG_CMDS,"#%s# +host %s %s",dcc[idx].nick,handle,par); addhost_by_handle(handle,par); tprintf(z,"Added '%s' to %s\n",par,handle); } } int cmd_mns_host(idx,z,par) int idx,z; char *par; { char handle[121]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: -host \n"); return; } if (delhost_by_handle(handle,par)) { log(LOG_CMDS,"#%s# -host %s %s",dcc[idx].nick,handle,par); tprintf(z,"Removed '%s' from %s\n",par,handle); } else tprintf(z,"Failed.\n"); } int cmd_chpass(idx,z,par) int idx,z; char *par; { char handle[121]; if (!par[0]) { tprintf(z,"Format: chpass [password]\n"); return; } split(handle,par); if (!handle[0]) { log(LOG_CMDS,"#%s# chpass %s nopass",dcc[idx].nick,par); change_pass_by_handle(par,"nopass"); tprintf(z,"Removed password.\n"); return; } log(LOG_CMDS,"#%s# chpass %s %s",dcc[idx].nick,handle,par); tprintf(z,"Changed password.\n"); change_pass_by_handle(handle,par); } int cmd_chaddr(idx,z,par) int idx,z; char *par; { char handle[121]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: chaddr \n"); return; } if (!match_attr_handle(handle,USER_TANDEM)) { tprintf(z,"Useful only for tandem bots.\n"); return 0; } log(LOG_CMDS,"#%s# chaddr %s %s",dcc[idx].nick,handle,par); tprintf(z,"Changed bot's address.\n"); set_handle_info(handle,par); } int cmd_comment(idx,z,par) int idx,z; char *par; { char handle[121]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: comment \n"); return; } log(LOG_CMDS,"#%s# comment %s %s",dcc[idx].nick,handle,par); tprintf(z,"Changed comment.\n"); set_handle_comment(handle,par); } int cmd_email(idx,z,par) int idx,z; char *par; { char handle[121]; split(handle,par); if (!handle[0]) { tprintf(z,"Format: email \n"); return; } log(LOG_CMDS,"#%s# email %s %s",dcc[idx].nick,handle,par); tprintf(z,"Changed email.\n"); set_handle_email(handle,par); } int cmd_dump(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# dump %s",dcc[idx].nick,par); mprintf(serv,"%s\n",par); } int cmd_reset(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# reset",dcc[idx].nick); tprintf(z,"Resetting channel info...\n"); reset_chan_info(); } int cmd_rehash(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# rehash",dcc[idx].nick); tprintf(z,"Rehashing...\n"); rehash(); } int cmd_die(idx,z,par) int idx,z; char *par; { char s[121]; log(LOG_CMDS,"#%s# die",dcc[idx].nick); chatout("*** BOT SHUTDOWN (authorized by %s)\n",dcc[idx].nick); tandout("chat %s BOT SHUTDOWN (authorized by %s)\n",origbotname, dcc[idx].nick); tandout("bye\n"); tprintf(serv,"QUIT :Dead by request of %s\n",dcc[idx].nick); if (periodic_save) write_userfile(); sleep(1); /* give the server time to understand */ sprintf(s,"DEAD BY REQUEST OF %s!%s",dcc[idx].nick,dcc[idx].host); fatal(s,0); } int cmd_jump(idx,z,par) int idx,z; char *par; { char other[121]; if (par[0]) { nsplit(other,par); if (!par[0]) strcpy(par,"6667"); log(LOG_CMDS,"#%s# jump %s %s",dcc[idx].nick,other,par); strcpy(newserver,other); newserverport=atoi(par); } else log(LOG_CMDS,"#%s# jump",dcc[idx].nick); tprintf(z,"Jumping servers...\n"); tprintf(serv,"QUIT :Jumping servers\n"); sleep(1); close(serv); shutdown(serv,2); serv=(-1); } int cmd_debug(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# debug",dcc[idx].nick); debug_mem_to_dcc(z); } int cmd_edit(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# edit %s",dcc[idx].nick,par); enter_edit(idx,z,par); } int cmd_info(idx,z,par) int idx,z; char *par; { char handle[121],s[121]; if (!use_info) { tprintf(z,"Info storage is turned off.\n"); return; } split(handle,par); if (!handle[0]) { if (match_attr_handle(par,USER_TANDEM)) { tprintf(z,"Useful only for users.\n"); return; } log(LOG_CMDS,"#%s# info %s",dcc[idx].nick,par); get_handle_info(par,s); if (s[0]) tprintf(z,"Info: %s\n",s); else tprintf(z,"No info for %s.\n",par); } else { if (match_attr_handle(handle,USER_TANDEM)) { tprintf(z,"Useful only for users.\n"); return; } log(LOG_CMDS,"#%s# info %s %s",dcc[idx].nick,handle,par); set_handle_info(handle,par); tprintf(z,"New info for %s: %s\n",handle,par); } } int cmd_mns_info(idx,z,par) int idx,z; char *par; { char xx[2]; if (!use_info) { tprintf(z,"Info storage is turned off.\n"); return; } if (match_attr_handle(par,USER_TANDEM)) { tprintf(z,"Useful only for users.\n"); return; } log(LOG_CMDS,"#%s# -info %s",dcc[idx].nick,par); xx[0]=0; set_handle_info(par,xx); tprintf(z,"Wiped info for %s.\n",par); } int cmd_simul(idx,z,par) int idx,z; char *par; { char nick[121]; int i,ok=0; split(nick,par); for (i=0; iu.chat=ci; chatout("*** %s left the party line.\n",dcc[idx].nick); tandout("chat %s %s left the party line.\n",origbotname,dcc[idx].nick); fork_exec(par,idx); } int cmd_link(idx,z,par) int idx,z; char *par; { char s[512]; int i; log(LOG_CMDS,"#%s# link %s",dcc[idx].nick,par); if (strchr(par,' ')==NULL) tandem_link(z,par); else { split(s,par); i=nextbot(s); if (i<0) { tprintf(z,"No such bot online.\n"); return; } tprintf(dcc[i].sock,"link %s@%s %s %s\n",dcc[idx].nick,origbotname,s,par); } } int cmd_unlink(idx,z,par) int idx,z; char *par; { char s[512]; int i; log(LOG_CMDS,"#%s# unlink %s",dcc[idx].nick,par); if (strchr(par,' ')==NULL) tandem_unlink(z,par); else { split(s,par); i=nextbot(s); if (i<0) { tprintf(z,"No such bot online.\n"); return; } tprintf(dcc[i].sock,"unlink %s@%s %s %s\n",dcc[idx].nick,origbotname,s, par); } } int cmd_relay(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# relay %s",dcc[idx].nick,par); tandem_relay(idx,z,par); } int cmd_save(idx,z,par) int idx,z; char *par; { log(LOG_CMDS,"#%s# save",dcc[idx].nick); write_userfile(); } #ifndef TCL int cmd_define(idx,z,par) int idx,z; char *par; { char var[121]; nsplit(var,par); log(LOG_CMDS,"#%s# define %s %s",dcc[idx].nick,var,par); define(z,var,par); } #endif int cmd_trace(idx,z,par) int idx,z; char *par; { int i; if (!par[0]) { tprintf(z,"Usage: .trace \n"); return; } if (strcasecmp(par,origbotname)==0) { tprintf(z,"That's me! Hiya! :)\n"); return; } i=nextbot(par); if (i<0) { tprintf(z,"Unreachable bot.\n"); return; } log(LOG_CMDS,"#%s# trace %s",dcc[idx].nick,par); tprintf(dcc[i].sock,"trace %s@%s %s %s\n",dcc[idx].nick,origbotname, par,origbotname); } int cmd_topic(idx,z,par) int idx,z; char *par; { if (!curchan[0]) { tprintf(z,"I'm not currently on any channel.\n"); return; } if (!me_op()) { tprintf(z,"I'm not a channel op.\n"); return; } mprintf(serv,"TOPIC %s :%s\n",curchan,par); tprintf(z,"Changing topic...\n"); log(LOG_CMDS,"#%s# topic %s",dcc[idx].nick,par); } int cmd_binds(idx,z,par) int idx,z; char *par; { #ifdef TCL tell_binds(z); log(LOG_CMDS,"#%s# binds",dcc[idx].nick); #else tprintf(z,"Not compiled with Tcl.\n"); #endif } int cmd_banner(idx,z,par) int idx,z; char *par; { char s[540]; int i; sprintf(s,"### %c%c%cBOTWIDE MESSAGE FROM %s:\n",7,7,7,dcc[idx].nick); for (i=0; i