/* 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; extern struct userrec *userlist; extern char helpbot[]; extern int helpsock; char *ismember(); struct userrec *adduser(); /* 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; { int atr=get_attr_handle(who); if (atr & USER_TANDEM) { if ((attr==USER_PARTY) || (attr==USER_COMMON) || (attr==USER_MASTER)) { 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)) { tprintf(z,"This only makes sense for tandem-bots.\n"); return 0; } } if ((attr==USER_OP) && (atr & USER_DEOP)) { tprintf(z,"(Removed deop.)\n"); change_attr(who,'-',USER_DEOP); } if ((attr==USER_DEOP) && (atr & USER_OP)) { tprintf(z,"(Removed op.)\n"); change_attr(who,'-',USER_OP); } if ((attr==BOT_AUTO) && (atr & BOT_REJECT)) { tprintf(z,"(Removed rejection.)\n"); change_attr(who,'-',BOT_REJECT); } if ((attr==BOT_REJECT) && (atr & BOT_AUTO)) { tprintf(z,"(Removed auto-connect.)\n"); change_attr(who,'-',BOT_AUTO); } if (atr & 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; { int atr=get_attr_handle(who); if (atr & USER_TANDEM) { if ((attr==USER_PARTY) && (attr==USER_COMMON) || (attr==USER_MASTER)) { 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)) { tprintf(z,"This only makes sense for tandem-bots.\n"); return 0; } } if (!(atr & 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]) { if (dcc[idx].u.chat->channel<0) { tprintf(z,"You have chat turned off.\n"); return; } log(LOG_CMDS,"#%s# who %s",dcc[idx].nick,par); if (strcasecmp(par,origbotname)==0) tell_who(z,dcc[idx].u.chat->channel); 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 %d\n",dcc[idx].nick,origbotname,par, dcc[idx].u.chat->channel); } else tprintf(dcc[i].sock,"who %s@%s %s %d\n",dcc[idx].nick,origbotname, par,dcc[idx].u.chat->channel); } } else { log(LOG_CMDS,"#%s# who",dcc[idx].nick); if (dcc[idx].u.chat->channel<0) tell_who(z,0); else tell_who(z,dcc[idx].u.chat->channel); } } 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; { if (dcc[idx].u.chat->channel<0) { tprintf(z,"You have chat turned off.\n"); return; } log(LOG_CMDS,"#%s# whom %s",dcc[idx].nick,par); if (!par[0]) { if (!isolate) tandout("who? %s@%s %d\n",dcc[idx].nick,origbotname, dcc[idx].u.chat->channel); answer_local_whom(z,dcc[idx].u.chat->channel); } else if (par[0]=='*') { if (!isolate) tandout("who? %s@%s -1\n",dcc[idx].nick,origbotname); answer_local_whom(z,-1); } else { int chan=atoi(par); if ((chan<0) || (chan>99999)) { tprintf(z,"Channel # out of range: must be 0-99999\n"); return; } if (!isolate) tandout("who? %s@%s %d\n",dcc[idx].nick,origbotname,chan); answer_local_whom(z,chan); } } int cmd_me(idx,z,par) int idx,z; char *par; { int i; if (dcc[idx].u.chat->channel<0) { tprintf(z,"You have chat turned off.\n"); return; } if (dcc[idx].u.chat->away!=NULL) not_away(idx,z); for (i=0; ichannel>=0)) tprintf(dcc[i].sock,"* %s %s\n",dcc[idx].nick,par); if (!isolate) if (dcc[i].type==DCC_TANDEM) tprintf(dcc[i].sock,"actchan %s@%s %d %s\n",dcc[idx].nick,origbotname, dcc[idx].u.chat->channel,par); } } int cmd_motd(idx,z,par) int idx,z; char *par; { int i; if (par[0]) { log(LOG_CMDS,"#%s# motd %s",dcc[idx].nick,par); if (strcasecmp(par,origbotname)==0) show_motd(idx); else { i=nextbot(par); if (i<0) tprintf(z,"That bot isn't connected.\n"); else tprintf(dcc[i].sock,"motd %s@%s %s\n",dcc[idx].nick,origbotname, par); } } else { 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"); if (dcc[idx].u.chat->channel>=0) { chanout(dcc[idx].u.chat->channel,"*** %s left the party line.\n", dcc[idx].nick); if (!isolate) tandout("chan %s %d %s left the party line.\n", origbotname,dcc[idx].u.chat->channel, 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); if (!curchan[0]) { tprintf(z,"I'm not on a channel right now!\n"); return; } if (!me_op()) { tprintf(z,"I'm not chop, so I can't invite anyone.\n"); return; } if (ismember(par)!=NULL) { tprintf(z,"%s is already on the channel!\n",par); return; } mprintf(serv,"INVITE %s %s\n",par,curchan); tprintf(z,"Inviting %s to %s.\n",par,curchan); } 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 %s",dcc[idx].nick,par); tell_bans(z,0,par); } } 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; ichannel>=0) { chanout_but(i,dcc[idx].u.chat->channel, "*** %s booted %s from the party line%s%s\n", dcc[idx].nick,dcc[i].nick,par[0]?": ":".",par); if (!isolate) tandout("chan %s %d %s booted %s from the party line%s%s\n", origbotname,dcc[idx].u.chat->channel,dcc[idx].nick, dcc[i].nick,par[0]?": ":".",par); } } log(LOG_CMDS,"#%s# boot %s %s",dcc[idx].nick,who,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(STDOUT); } } if (!ok) tprintf(z,"Who? No such person on the party line.\n"); } 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_pls_flag1(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_FLAG1,FLAG1NAME,par); } int cmd_pls_flag2(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_FLAG2,FLAG2NAME,par); } int cmd_pls_flag3(idx,z,par) int idx,z; char *par; { cmd_pls_attr(idx,z,USER_FLAG3,FLAG3NAME,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_mns_flag1(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_FLAG1,FLAG1NAME,par); } int cmd_mns_flag2(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_FLAG2,FLAG2NAME,par); } int cmd_mns_flag3(idx,z,par) int idx,z; char *par; { cmd_mns_attr(idx,z,USER_FLAG3,FLAG3NAME,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); userlist=adduser(userlist,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); userlist=adduser(userlist,handle,"none","nopass",USER_TANDEM); set_handle_info(userlist,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,j; split(hand,par); if (!hand[0]) { tprintf(z,"Format: handle \n"); return; } if (strlen(par)>9) par[9]=0; for (i=0; i=127) || (par[i]=='@')) par[i]='?'; if (par[0]=='*') { tprintf(z,"Bizarre quantum forces prevent nicknames from starting with *\n"); return; } 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; 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[idx].u.chat->channel,dcc[i].nick,par); } for (j=0; j\n"); return; } if (strlen(par)>9) par[9]=0; for (i=0; i=127) || (par[i]=='@')) par[i]='?'; if (par[0]=='*') { tprintf(z,"Bizarre quantum forces prevent nicknames from starting with *\n"); return; } 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"); if (dcc[idx].u.chat->channel>=0) { chanout(dcc[idx].u.chat->channel,"*** Nick change: %s -> %s\n", dcc[idx].nick,par); tandout("chan %s %d Nick change: %s -> %s\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick,par); } for (i=0; i \n"); return; } if (!is_user(handle)) { tprintf(z,"No such user.\n"); return; } 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 (!is_user(handle)) { tprintf(z,"No such user.\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]) { if (!is_user(par)) { tprintf(z,"No such user.\n"); return; } log(LOG_CMDS,"#%s# chpass %s nopass",dcc[idx].nick,par); change_pass_by_handle(par,"nopass"); tprintf(z,"Removed password.\n"); return; } if (!is_user(handle)) { tprintf(z,"No such user.\n"); return; } log(LOG_CMDS,"#%s# chpass %s [something]",dcc[idx].nick,handle); 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 (!(get_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(userlist,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); if (!is_user(handle)) { tprintf(z,"No such user!\n"); return; } tprintf(z,"Changed comment.\n"); set_handle_comment(userlist,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(userlist,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 %s",dcc[idx].nick,par); if (par[0]) { chatout("*** BOT SHUTDOWN (%s: %s)\n",dcc[idx].nick,par); tandout("chat %s BOT SHUTDOWN (%s: %s)\n",origbotname,dcc[idx].nick,par); tprintf(serv,"QUIT :%s: %s\n",dcc[idx].nick,par); } else { chatout("*** BOT SHUTDOWN (authorized by %s)\n",dcc[idx].nick); tandout("chat %s BOT SHUTDOWN (authorized by %s)\n",origbotname, dcc[idx].nick); tprintf(serv,"QUIT :Dead by request of %s\n",dcc[idx].nick); } if (helpbot[0]) tprintf(helpsock,"QUIT :fuck you\n"); tandout("bye\n"); if (periodic_save) write_userfile(); sleep(1); /* give the server time to understand */ sprintf(s,"DIE BY %s!%s (%s)",dcc[idx].nick,dcc[idx].host,par[0]?par: "request"); 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; { #ifdef EXT_EDITOR struct chat_info *ci; char s[161]; log(LOG_CMDS,"#%s# edit %s",dcc[idx].nick,par); if (dcc[idx].u.chat->channel>=0) { chanout(dcc[idx].u.chat->channel,"*** %s left the party line.\n", dcc[idx].nick); tandout("chan %s %d %s left the party line.\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick); } ci=dcc[idx].u.chat; dcc[idx].type=DCC_FORK; set_fork(idx); dcc[idx].u.fork->u.chat=ci; sprintf(s,"%s %s",EXT_EDITOR,par); fork_exec(s,idx); #else log(LOG_CMDS,"#%s# edit %s",dcc[idx].nick,par); enter_edit(idx,z,par); #endif } 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 (get_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 (get_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(userlist,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 (get_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(userlist,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; ichannel>=0) { chanout(dcc[idx].u.chat->channel,"*** %s left the party line.\n", dcc[idx].nick); tandout("chan %s %d %s left the party line.\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick); } ci=dcc[idx].u.chat; dcc[idx].type=DCC_FORK; set_fork(idx); dcc[idx].u.fork->u.chat=ci; 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 [changes]\n"); return; } nsplit(hand,par); if (!is_user(hand)) { tprintf(z,"No such user!\n"); return; } if (par[0]) { /* make changes */ for (i=0; i\n"); tprintf(z," notes erase <# or ALL>\n"); return; } nsplit(fcn,par); if (strcasecmp(fcn,"index")==0) notes_read(dcc[idx].nick,"",-1,z); else if (strcasecmp(fcn,"read")==0) { if (strcasecmp(par,"all")==0) notes_read(dcc[idx].nick,"",0,z); else notes_read(dcc[idx].nick,"",atoi(par),z); } else if (strcasecmp(fcn,"erase")==0) { if (strcasecmp(par,"all")==0) notes_del(dcc[idx].nick,"",0,z); else notes_del(dcc[idx].nick,"",atoi(par),z); } else tprintf(z,"Function must be one of INDEX, READ, or ERASE.\n"); log(LOG_CMDS,"#%s# notes %s %s",dcc[idx].nick,fcn,par); } int cmd_chat(idx,z,par) int idx,z; char *par; { int newchan,oldchan; if (strcasecmp(par,"off")==0) { /* turn chat off */ if (dcc[idx].u.chat->channel<0) tprintf(z,"You weren't in chat anyway!\n"); else { tprintf(z,"Leaving chat mode...\n"); chanout(dcc[idx].u.chat->channel,"*** %s left the party line.\n", dcc[idx].nick); tandout("chan %s %d %s left the party line.\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick); } dcc[idx].u.chat->channel=(-1); } else { newchan=atoi(par); if ((newchan<0) || (newchan>99999)) { tprintf(z,"Channel # out of range: must be between 0 and 99999.\n"); return; } /* if coming back from being off the party line, make sure they're not away */ if ((dcc[idx].u.chat->channel<0) && (dcc[idx].u.chat->away!=NULL)) not_away(idx,z); if (dcc[idx].u.chat->channel==newchan) { if (newchan==0) tprintf(z,"You're already on the party line!\n"); else tprintf(z,"You're already on channel %d!\n",newchan); } else { oldchan=dcc[idx].u.chat->channel; if (oldchan==0) { chanout(0,"*** %s left the party line.\n",dcc[idx].nick); tandout("chan %s %d %s left the party line.\n",origbotname,0, dcc[idx].nick); } else if (oldchan>0) { chanout(oldchan,"*** %s left the channel.\n",dcc[idx].nick); tandout("chan %s %d %s left the channel.\n",origbotname,oldchan, dcc[idx].nick); } dcc[idx].u.chat->channel=newchan; if (newchan==0) { tprintf(z,"Entering the party line...\n"); chanout(0,"*** %s joined the party line.\n",dcc[idx].nick); tandout("chan %s %d %s joined the party line.\n",origbotname,0, dcc[idx].nick); } else { tprintf(z,"Joining channel %d...\n",newchan); chanout(newchan,"*** %s joined the channel.\n",dcc[idx].nick); tandout("chan %s %d %s joined the channel.\n",origbotname,newchan, dcc[idx].nick); } } } }