| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588 |
- /*
- * cmds.c -- handles:
- * commands from a user via dcc
- * (split in 2, this portion contains no-irc commands)
- *
- * dprintf'ized, 3nov1995
- *
- * $Id: cmds.c,v 1.34 2000/01/17 16:14:45 per Exp $
- */
- /*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000 Eggheads
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- #include "main.h"
- #include "tandem.h"
- #include "modules.h"
- #include <ctype.h>
- extern struct chanset_t *chanset;
- extern struct dcc_t *dcc;
- extern struct userrec *userlist;
- extern tcl_timer_t *timer, *utimer;
- extern int dcc_total, remote_boots, backgrd, make_userfile, do_restart;
- extern int conmask, require_p, must_be_owner;
- extern Tcl_Interp *interp;
- extern char botnetnick[], origbotname[], ver[];
- extern char network[], owner[], spaces[];
- extern time_t now, online_since;
- /* add hostmask to a bot's record if possible */
- static int add_bot_hostmask(int idx, char *nick)
- {
- struct chanset_t *chan;
- memberlist *m;
- char s[UHOSTLEN];
- for (chan = chanset; chan; chan = chan->next) {
- if (channel_active(chan)) {
- m = ismember(chan, nick);
- if (m) {
- struct userrec *u;
- simple_sprintf(s, "%s!%s", m->nick, m->userhost);
- u = get_user_by_host(s);
- if (u) {
- dprintf(idx, "(Can't add userhost for %s because it matches %s)\n",
- nick, u->handle);
- return 0;
- }
- simple_sprintf(s, "*!%s", m->userhost);
- dprintf(idx, "(Added hostmask for %s from %s)\n", nick, chan->name);
- addhost_by_handle(nick, s);
- return 1;
- }
- }
- }
- return 0;
- }
- static void tell_who(struct userrec *u, int idx, int chan)
- {
- int i, k, ok = 0, atr = u ? u->flags : 0, len;
- char s[1024]; /* temp fix - 1.4 has a better one */
- if (chan == 0)
- dprintf(idx, "Party line members: (* = owner, + = master, @ = op)\n");
- else {
- simple_sprintf(s, "assoc %d", chan);
- if ((Tcl_Eval(interp, s) != TCL_OK) || !interp->result[0])
- dprintf(idx,
- "People on channel %s%d: (* = owner, + = master, @ = op)\n",
- (chan < 100000) ? "" : "*", chan % 100000);
- else
- dprintf(idx,
- "People on channel '%s' (%s%d): (* = owner, + = master, @ = op)\n",
- interp->result, (chan < 100000) ? "" : "*", chan % 100000);
- }
- for (i = 0; i < dcc_total; i++)
- if (dcc[i].type == &DCC_CHAT)
- if (dcc[i].u.chat->channel == chan) {
- spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
- if (atr & USER_OWNER) {
- sprintf(s, " [%.2lu] %c%s%s %s",
- dcc[i].sock, (geticon(i) == '-' ? ' ' : geticon(i)),
- dcc[i].nick, spaces, dcc[i].host);
- } else {
- sprintf(s, " %c%s%s %s",
- (geticon(i) == '-' ? ' ' : geticon(i)),
- dcc[i].nick, spaces, dcc[i].host);
- }
- spaces[len] = ' ';
- if (atr & USER_MASTER) {
- if (dcc[i].u.chat->con_flags)
- sprintf(&s[strlen(s)], " (con:%s)",
- masktype(dcc[i].u.chat->con_flags));
- }
- if (now - dcc[i].timeval > 300) {
- unsigned long days, hrs, mins;
- days = (now - dcc[i].timeval) / 86400;
- hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
- mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
- if (days > 0)
- sprintf(&s[strlen(s)], " (idle %lud%luh)", days, hrs);
- else if (hrs > 0)
- sprintf(&s[strlen(s)], " (idle %luh%lum)", hrs, mins);
- else
- sprintf(&s[strlen(s)], " (idle %lum)", mins);
- }
- dprintf(idx, "%s\n", s);
- if (dcc[i].u.chat->away != NULL)
- dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
- }
- for (i = 0; i < dcc_total; i++)
- if (dcc[i].type == &DCC_BOT) {
- if (!ok) {
- ok = 1;
- dprintf(idx, "Bots connected:\n");
- }
- strcpy(s, ctime(&dcc[i].timeval));
- strcpy(s, &s[1]);
- s[9] = 0;
- strcpy(s, &s[7]);
- s[2] = ' ';
- strcpy(&s[7], &s[10]);
- s[12] = 0;
- spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
- if (atr & USER_OWNER) {
- dprintf(idx, " [%.2lu] %s%c%s%s (%s) %s\n",
- dcc[i].sock, dcc[i].status & STAT_CALLED ? "<-" : "->",
- dcc[i].status & STAT_SHARE ? '+' : ' ',
- dcc[i].nick, spaces, s, dcc[i].u.bot->version);
- } else {
- dprintf(idx, " %s%c%s%s (%s) %s\n",
- dcc[i].status & STAT_CALLED ? "<-" : "->",
- dcc[i].status & STAT_SHARE ? '+' : ' ',
- dcc[i].nick, spaces, s, dcc[i].u.bot->version);
- }
- spaces[len] = ' ';
- }
- ok = 0;
- for (i = 0; i < dcc_total; i++) {
- if ((dcc[i].type == &DCC_CHAT) && (dcc[i].u.chat->channel != chan)) {
- if (!ok) {
- ok = 1;
- dprintf(idx, "Other people on the bot:\n");
- }
- spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
- if (atr & USER_OWNER) {
- sprintf(s, " [%.2lu] %c%s%s ",
- dcc[i].sock,
- (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
- spaces);
- } else {
- sprintf(s, " %c%s%s ",
- (geticon(i) == '-' ? ' ' : geticon(i)), dcc[i].nick,
- spaces);
- }
- spaces[len] = ' ';
- if (atr & USER_MASTER) {
- if (dcc[i].u.chat->channel < 0)
- strcat(s, "(-OFF-) ");
- else if (dcc[i].u.chat->channel == 0)
- strcat(s, "(party) ");
- else
- sprintf(&s[strlen(s)], "(%5d) ", dcc[i].u.chat->channel);
- }
- strcat(s, dcc[i].host);
- if (atr & USER_MASTER) {
- if (dcc[i].u.chat->con_flags)
- sprintf(&s[strlen(s)], " (con:%s)",
- masktype(dcc[i].u.chat->con_flags));
- }
- if (now - dcc[i].timeval > 300) {
- k = (now - dcc[i].timeval) / 60;
- if (k < 60)
- sprintf(&s[strlen(s)], " (idle %dm)", k);
- else
- sprintf(&s[strlen(s)], " (idle %dh%dm)", k / 60, k % 60);
- }
- dprintf(idx, "%s\n", s);
- if (dcc[i].u.chat->away != NULL)
- dprintf(idx, " AWAY: %s\n", dcc[i].u.chat->away);
- }
- if ((atr & USER_MASTER) && (dcc[i].type->flags & DCT_SHOWWHO) &&
- (dcc[i].type != &DCC_CHAT)) {
- if (!ok) {
- ok = 1;
- dprintf(idx, "Other people on the bot:\n");
- }
- spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0;
- if (atr & USER_OWNER) {
- sprintf(s, " [%.2lu] %c%s%s (files) %s",
- dcc[i].sock, dcc[i].status & STAT_CHAT ? '+' : ' ',
- dcc[i].nick, spaces, dcc[i].host);
- } else {
- sprintf(s, " %c%s%s (files) %s",
- dcc[i].status & STAT_CHAT ? '+' : ' ',
- dcc[i].nick, spaces, dcc[i].host);
- }
- spaces[len] = ' ';
- dprintf(idx, "%s\n", s);
- }
- }
- }
- static void cmd_botinfo(struct userrec *u, int idx, char *par)
- {
- char s[512], s2[32];
- struct chanset_t *chan;
- time_t now2;
- int hr, min;
- Context;
- chan = chanset;
- now2 = now - online_since;
- s2[0] = 0;
- if (now2 > 86400) {
- int days = now2 / 86400;
- /* days */
- sprintf(s2, "%d day", days);
- if (days >= 2)
- strcat(s2, "s");
- strcat(s2, ", ");
- now2 -= days * 86400;
- }
- hr = (time_t) ((int) now2 / 3600);
- now2 -= (hr * 3600);
- min = (time_t) ((int) now2 / 60);
- sprintf(&s2[strlen(s2)], "%02d:%02d", (int) hr, (int) min);
- putlog(LOG_CMDS, "*", "#%s# botinfo", dcc[idx].nick);
- simple_sprintf(s, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
- botnet_send_infoq(-1, s);
- s[0] = 0;
- if (module_find("server", 0, 0)) {
- while (chan != NULL) {
- if (!channel_secret(chan)) {
- if ((strlen(s) + strlen(chan->name) + strlen(network)
- + strlen(botnetnick) + strlen(ver) + 1) >= 490) {
- strcat(s,"++ ");
- break; /* yeesh! */
- }
- strcat(s, chan->name);
- strcat(s, ", ");
- }
- chan = chan->next;
- }
- if (s[0]) {
- s[strlen(s) - 2] = 0;
- dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
- ver, network, s, s2);
- } else
- dprintf(idx, "*** [%s] %s <%s> (%s) [UP %s]\n", botnetnick,
- ver, network, BOT_NOCHANNELS, s2);
- } else
- dprintf(idx, "*** [%s] %s <NO_IRC> [UP %s]\n", botnetnick, ver, s2);
- }
- static void cmd_whom(struct userrec *u, int idx, char *par)
- {
- if (par[0] == '*') {
- putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
- answer_local_whom(idx, -1);
- return;
- } else if (dcc[idx].u.chat->channel < 0) {
- dprintf(idx, "You have chat turned off.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# whom %s", dcc[idx].nick, par);
- if (!par[0]) {
- answer_local_whom(idx, dcc[idx].u.chat->channel);
- } else {
- int chan = -1;
- if ((par[0] < '0') || (par[0] > '9')) {
- Tcl_SetVar(interp, "chan", par, 0);
- if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) == TCL_OK) &&
- interp->result[0]) {
- chan = atoi(interp->result);
- }
- if (chan <= 0) {
- dprintf(idx, "No such channel.\n");
- return;
- }
- } else
- chan = atoi(par);
- if ((chan < 0) || (chan > 99999)) {
- dprintf(idx, "Channel # out of range: must be 0-99999\n");
- return;
- }
- answer_local_whom(idx, chan);
- }
- }
- static void cmd_me(struct userrec *u, int idx, char *par)
- {
- int i;
- if (dcc[idx].u.chat->channel < 0) {
- dprintf(idx, "You have chat turned off.\n");
- return;
- }
- if (!par[0]) {
- dprintf(idx, "Usage: me <action>\n");
- return;
- }
- if (dcc[idx].u.chat->away != NULL)
- not_away(idx);
- for (i = 0; i < dcc_total; i++)
- if ((dcc[i].type->flags & DCT_CHAT) &&
- (dcc[i].u.chat->channel == dcc[idx].u.chat->channel) &&
- ((i != idx) || (dcc[i].status & STAT_ECHO)))
- dprintf(i, "* %s %s\n", dcc[idx].nick, par);
- botnet_send_act(idx, botnetnick, dcc[idx].nick,
- dcc[idx].u.chat->channel, par);
- check_tcl_act(dcc[idx].nick, dcc[idx].u.chat->channel, par);
- }
- static void cmd_motd(struct userrec *u, int idx, char *par)
- {
- int i;
- if (par[0]) {
- putlog(LOG_CMDS, "*", "#%s# motd %s", dcc[idx].nick, par);
- if (!strcasecmp(par, botnetnick))
- show_motd(idx);
- else {
- i = nextbot(par);
- if (i < 0)
- dprintf(idx, "That bot isn't connected.\n");
- else {
- char x[40];
- simple_sprintf(x, "%s%d:%s@%s",
- (u->flags & USER_HIGHLITE) ?
- ((dcc[idx].status & STAT_TELNET) ? "#" : "!") : "",
- dcc[idx].sock, dcc[idx].nick, botnetnick);
- botnet_send_motd(i, x, par);
- }
- }
- } else {
- putlog(LOG_CMDS, "*", "#%s# motd", dcc[idx].nick);
- show_motd(idx);
- }
- }
- static void cmd_away(struct userrec *u, int idx, char *par)
- {
- if (strlen(par) > 60)
- par[60] = 0;
- set_away(idx, par);
- }
- static void cmd_back(struct userrec *u, int idx, char *par)
- {
- not_away(idx);
- }
- static void cmd_newpass(struct userrec *u, int idx, char *par)
- {
- char *new;
- if (!par[0]) {
- dprintf(idx, "Usage: newpass <newpassword>\n");
- return;
- }
- new = newsplit(&par);
- if (strlen(new) > 16)
- new[16] = 0;
- if (strlen(new) < 6) {
- dprintf(idx, "Please use at least 6 characters.\n");
- return;
- }
- set_user(&USERENTRY_PASS, u, new);
- putlog(LOG_CMDS, "*", "#%s# newpass...", dcc[idx].nick);
- dprintf(idx, "Changed password to '%s'\n", new);
- }
- static void cmd_bots(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# bots", dcc[idx].nick);
- tell_bots(idx);
- }
- static void cmd_bottree(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# bottree", dcc[idx].nick);
- tell_bottree(idx, 0);
- }
- static void cmd_vbottree(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# vbottree", dcc[idx].nick);
- tell_bottree(idx, 1);
- }
- static void cmd_rehelp(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# rehelp", dcc[idx].nick);
- dprintf(idx, "Reload help cache...\n");
- reload_help_data();
- }
- static void cmd_help(struct userrec *u, int idx, char *par)
- {
- struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
- get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
- if (par[0]) {
- putlog(LOG_CMDS, "*", "#%s# help %s", dcc[idx].nick, par);
- if (!strcmp(par, "all"))
- tellallhelp(idx, "all", &fr);
- else if (strchr(par, '*') || strchr(par, '?')) {
- char *p = par;
- /* Check if the search pattern only consists of '*' and/or '?'
- * If it does, show help for "all" instead of listing all help
- * entries. */
- for (p = par; *p && ((*p == '*') || (*p == '?')); p++);
- if (*p)
- tellwildhelp(idx, par, &fr);
- else
- tellallhelp(idx, "all", &fr);
- } else
- tellhelp(idx, par, &fr, 0);
- } else {
- putlog(LOG_CMDS, "*", "#%s# help", dcc[idx].nick);
- if (glob_op(fr) || glob_botmast(fr) || chan_op(fr))
- tellhelp(idx, "help", &fr, 0);
- else
- tellhelp(idx, "helpparty", &fr, 0);
- }
- }
- static void cmd_addlog(struct userrec *u, int idx, char *par)
- {
- if (!par[0]) {
- dprintf(idx, "Usage: addlog <message>\n");
- return;
- }
- dprintf(idx, "Placed entry in the log file.\n");
- putlog(LOG_MISC, "*", "%s: %s", dcc[idx].nick, par);
- }
- static void cmd_who(struct userrec *u, int idx, char *par)
- {
- int i;
- if (par[0]) {
- if (dcc[idx].u.chat->channel < 0) {
- dprintf(idx, "You have chat turned off.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# who %s", dcc[idx].nick, par);
- if (!strcasecmp(par, botnetnick))
- tell_who(u, idx, dcc[idx].u.chat->channel);
- else {
- i = nextbot(par);
- if (i < 0) {
- dprintf(idx, "That bot isn't connected.\n");
- } else if (dcc[idx].u.chat->channel > 99999)
- dprintf(idx, "You are on a local channel\n");
- else {
- char s[40];
- simple_sprintf(s, "%d:%s@%s", dcc[idx].sock,
- dcc[idx].nick, botnetnick);
- botnet_send_who(i, s, par, dcc[idx].u.chat->channel);
- }
- }
- } else {
- putlog(LOG_CMDS, "*", "#%s# who", dcc[idx].nick);
- if (dcc[idx].u.chat->channel < 0)
- tell_who(u, idx, 0);
- else
- tell_who(u, idx, dcc[idx].u.chat->channel);
- }
- }
- static void cmd_whois(struct userrec *u, int idx, char *par)
- {
- if (!par[0]) {
- dprintf(idx, "Usage: whois <handle>\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# whois %s", dcc[idx].nick, par);
- tell_user_ident(idx, par, u ? (u->flags & USER_MASTER) : 0);
- }
- static void cmd_match(struct userrec *u, int idx, char *par)
- {
- int start = 1, limit = 20;
- char *s, *s1, *chname;
- if (!par[0]) {
- dprintf(idx, "Usage: match <nick/host> [[skip] count]\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# match %s", dcc[idx].nick, par);
- s = newsplit(&par);
- if (strchr(CHANMETA, par[0]) != NULL)
- chname = newsplit(&par);
- else
- chname = "";
- if (atoi(par) > 0) {
- s1 = newsplit(&par);
- if (atoi(par) > 0) {
- start = atoi(s1);
- limit = atoi(par);
- } else
- limit = atoi(s1);
- }
- tell_users_match(idx, s, start, limit, u ? (u->flags & USER_MASTER) : 0,
- chname);
- }
- static void cmd_uptime(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# uptime", dcc[idx].nick);
- tell_verbose_uptime(idx);
- }
- static void cmd_status(struct userrec *u, int idx, char *par)
- {
- int atr = u ? u->flags : 0;
- if (!strcasecmp(par, "all")) {
- if (!(atr & USER_MASTER)) {
- dprintf(idx, "You do not have Bot Master privileges.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# status all", dcc[idx].nick);
- tell_verbose_status(idx);
- tell_mem_status_dcc(idx);
- dprintf(idx, "\n");
- tell_settings(idx);
- do_module_report(idx, 1, NULL);
- } else {
- putlog(LOG_CMDS, "*", "#%s# status", dcc[idx].nick);
- tell_verbose_status(idx);
- tell_mem_status_dcc(idx);
- do_module_report(idx, 0, NULL);
- }
- }
- static void cmd_dccstat(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# dccstat", dcc[idx].nick);
- tell_dcc(idx);
- }
- static void cmd_boot(struct userrec *u, int idx, char *par)
- {
- int i, files = 0, ok = 0;
- char *who;
- struct userrec *u2;
- if (!par[0]) {
- dprintf(idx, "Usage: boot nick[@bot]\n");
- return;
- }
- who = newsplit(&par);
- if (strchr(who, '@') != NULL) {
- char whonick[512];
- splitc(whonick, who, '@');
- whonick[20] = 0;
- if (!strcasecmp(who, botnetnick)) {
- cmd_boot(u, idx, whonick);
- return;
- }
- if (remote_boots > 0) {
- i = nextbot(who);
- if (i < 0) {
- dprintf(idx, "No such bot connected.\n");
- return;
- }
- botnet_send_reject(i, dcc[idx].nick, botnetnick, whonick,
- who, par[0] ? par : dcc[idx].nick);
- putlog(LOG_BOTS, "*", "#%s# boot %s@%s (%s)", dcc[idx].nick, whonick,
- who, par[0] ? par : dcc[idx].nick);
- } else
- dprintf(idx, "Remote boots are disabled here.\n");
- return;
- }
- for (i = 0; i < dcc_total; i++)
- if (!strcasecmp(dcc[i].nick, who) && !ok &&
- (dcc[i].type->flags & DCT_CANBOOT)) {
- u2 = get_user_by_handle(userlist, dcc[i].nick);
- if (u2 && (u2->flags & USER_OWNER) &&
- strcasecmp(dcc[idx].nick, who)) {
- dprintf(idx, "Can't boot the bot owner.\n");
- return;
- }
- if (u2 && (u2->flags & USER_MASTER) &&
- !(u && (u->flags & USER_MASTER))) {
- dprintf(idx, "Can't boot a bot master.\n");
- return;
- }
- files = (dcc[i].type->flags & DCT_FILES);
- if (files)
- dprintf(idx, "Booted %s from the file section.\n", dcc[i].nick);
- else
- dprintf(idx, "Booted %s from the bot.\n", dcc[i].nick);
- putlog(LOG_CMDS, "*", "#%s# boot %s %s", dcc[idx].nick, who, par);
- do_boot(i, dcc[idx].nick, par);
- ok = 1;
- }
- if (!ok)
- dprintf(idx, "Who? No such person on the party line.\n");
- }
- static void cmd_console(struct userrec *u, int idx, char *par)
- {
- char *nick, s[2], s1[512];
- int dest = 0, i, ok = 0, pls, md;
- struct flag_record fr =
- {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
- module_entry *me;
- if (!par[0]) {
- dprintf(idx, "Your console is %s: %s (%s)\n",
- dcc[idx].u.chat->con_chan,
- masktype(dcc[idx].u.chat->con_flags),
- maskname(dcc[idx].u.chat->con_flags));
- return;
- }
- get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
- strcpy(s1, par);
- nick = newsplit(&par);
- /* don't remove '+' as someone couldn't have '+' in CHANMETA cause
- * he doesn't use br0ken IRCnet ++rtc */
- if (nick[0] && !strchr(CHANMETA "+-*", nick[0]) && glob_master(fr)) {
- for (i = 0; i < dcc_total; i++)
- if (!strcasecmp(nick, dcc[i].nick) &&
- (dcc[i].type == &DCC_CHAT) && (!ok)) {
- ok = 1;
- dest = i;
- }
- if (!ok) {
- dprintf(idx, "No such user on the party line!\n");
- return;
- }
- nick[0] = 0;
- } else
- dest = idx;
- if (!nick[0])
- nick = newsplit(&par);
- /* ugly hack for modeless channels -- rtc */
- if ((nick [0] == '+' && findchan(nick)) ||
- (nick [0] != '+' && strchr(CHANMETA "*", nick[0]))) {
- if (strcmp(nick, "*") && !findchan(nick)) {
- dprintf(idx, "Invalid console channel: %s\n", nick);
- return;
- }
- get_user_flagrec(u, &fr, nick);
- if (!chan_op(fr) && !(glob_op(fr) && !chan_deop(fr))) {
- dprintf(idx, "You don't have op or master access to channel %s\n",
- nick);
- return;
- }
- strncpy(dcc[dest].u.chat->con_chan, nick, 80);
- dcc[dest].u.chat->con_chan[80] = 0;
- nick[0] = 0;
- if ((dest == idx) && !glob_master(fr) && !chan_master(fr))
- /* consoling to another channel for self */
- dcc[dest].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_WALL);
- }
- if (!nick[0])
- nick = newsplit(&par);
- pls = 1;
- if (nick[0]) {
- if ((nick[0] != '+') && (nick[0] != '-'))
- dcc[dest].u.chat->con_flags = 0;
- for (; *nick; nick++) {
- if (*nick == '+')
- pls = 1;
- else if (*nick == '-')
- pls = 0;
- else {
- s[0] = *nick;
- s[1] = 0;
- md = logmodes(s);
- if ((dest == idx) && !glob_master(fr) && pls) {
- if (chan_master(fr))
- md &= ~(LOG_FILES | LOG_LEV1 | LOG_LEV2 | LOG_LEV3 |
- LOG_LEV4 | LOG_LEV5 | LOG_LEV6 | LOG_LEV7 |
- LOG_LEV8 | LOG_DEBUG);
- else
- md &= ~(LOG_MISC | LOG_CMDS | LOG_FILES | LOG_LEV1 |
- LOG_LEV2 | LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
- LOG_LEV6 | LOG_LEV7 | LOG_LEV8 | LOG_WALL |
- LOG_DEBUG);
- }
- if (!glob_owner(fr) && pls)
- md &= ~(LOG_RAW | LOG_SRVOUT | LOG_BOTNET | LOG_BOTSHARE);
- if (!glob_botmast(fr) && pls)
- md &= ~LOG_BOTS;
- if (pls)
- dcc[dest].u.chat->con_flags |= md;
- else
- dcc[dest].u.chat->con_flags &= ~md;
- }
- }
- }
- putlog(LOG_CMDS, "*", "#%s# console %s", dcc[idx].nick, s1);
- if (dest == idx) {
- dprintf(idx, "Set your console to %s: %s (%s)\n",
- dcc[idx].u.chat->con_chan,
- masktype(dcc[idx].u.chat->con_flags),
- maskname(dcc[idx].u.chat->con_flags));
- } else {
- dprintf(idx, "Set console of %s to %s: %s (%s)\n", dcc[dest].nick,
- dcc[dest].u.chat->con_chan,
- masktype(dcc[dest].u.chat->con_flags),
- maskname(dcc[dest].u.chat->con_flags));
- dprintf(dest, "%s set your console to %s: %s (%s)\n", dcc[idx].nick,
- dcc[dest].u.chat->con_chan,
- masktype(dcc[dest].u.chat->con_flags),
- maskname(dcc[dest].u.chat->con_flags));
- }
- /* new style autosave -- drummer,07/25/1999*/
- if ((me = module_find("console", 1, 1))) {
- Function *func = me->funcs;
- (func[CONSOLE_DOSTORE]) (dest);
- }
- }
- static void cmd_pls_bot(struct userrec *u, int idx, char *par)
- {
- char *handle, *addr, *p, *q, *host;
- struct userrec *u1;
- struct bot_addr *bi;
- if (!par[0])
- dprintf(idx, "Usage: +bot <handle> <address[:telnet-port[/relay-port]]> [host]\n");
- else {
- handle = newsplit(&par);
- addr = newsplit(&par);
- if (strlen(handle) > HANDLEN)
- handle[HANDLEN] = 0; /* max len = XX .. for the moment :) */
- if (get_user_by_handle(userlist, handle))
- dprintf(idx, "Someone already exists by that name.\n");
- else if (strchr(BADHANDCHARS, handle[0]) != NULL)
- dprintf(idx, "You can't start a botnick with '%c'.\n", handle[0]);
- else {
- if (strlen(addr) > 60)
- addr[60] = 0;
- putlog(LOG_CMDS, "*", "#%s# +bot %s %s", dcc[idx].nick, handle, addr);
- userlist = adduser(userlist, handle, "none", "-", USER_BOT);
- u1 = get_user_by_handle(userlist, handle);
- bi = user_malloc(sizeof(struct bot_addr));
- q = strchr(addr, ':');
- if (!q) {
- bi->address = user_malloc(strlen(addr) + 1);
- strcpy(bi->address, addr);
- bi->telnet_port = 3333;
- bi->relay_port = 3333;
- } else {
- bi->address = user_malloc(q - addr + 1);
- strncpy(bi->address, addr, q - addr);
- bi->address[q - addr] = 0;
- p = q + 1;
- bi->telnet_port = atoi(p);
- q = strchr(p, '/');
- if (!q) {
- bi->relay_port = bi->telnet_port;
- } else {
- bi->relay_port = atoi(q + 1);
- }
- }
- set_user(&USERENTRY_BOTADDR, u1, bi);
- dprintf(idx, "Added bot '%s' with address '%s' and no password.\n",
- handle, addr);
- host = newsplit(&par);
- if (host[0]) {
- addhost_by_handle(handle, host);
- } else if (!add_bot_hostmask(idx, handle))
- dprintf(idx, "You'll want to add a hostmask if this bot will ever %s",
- "be on any channels that I'm on.\n");
- }
- }
- }
- static void cmd_chnick(struct userrec *u, int idx, char *par)
- {
- char hand[HANDLEN + 1], newhand[HANDLEN + 1];
- int i, atr = u ? u->flags : 0, atr2;
- struct userrec *u2;
- strncpy(hand, newsplit(&par), sizeof(hand));
- hand[HANDLEN] = 0;
- strncpy(newhand, newsplit(&par), sizeof(newhand));
- newhand[HANDLEN] = 0;
- if (!hand[0] || !newhand[0]) {
- dprintf(idx, "Usage: chnick <oldnick> <newnick>\n");
- return;
- }
- for (i = 0; i < strlen(newhand); i++)
- if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
- newhand[i] = '?';
- if (strchr(BADHANDCHARS, newhand[0]) != NULL)
- dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with %c\n",
- newhand[0]);
- else if (get_user_by_handle(userlist, newhand) &&
- strcasecmp(hand, newhand))
- dprintf(idx, "Somebody is already using %s.\n", newhand);
- else {
- u2 = get_user_by_handle(userlist, hand);
- atr2 = u2 ? u2->flags : 0;
- if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
- !(atr2 & USER_BOT))
- dprintf(idx, "You can't change nick for non-bots.\n");
- else if ((bot_flags(u2) & BOT_SHARE) && !(atr & USER_OWNER))
- dprintf(idx, "You can't change shared bot's nick.\n");
- else if ((atr2 & USER_OWNER) && !(atr & USER_OWNER) &&
- strcasecmp(dcc[idx].nick, hand))
- dprintf(idx, "Can't change the bot owner's handle.\n");
- else if (isowner(hand) && strcasecmp(dcc[idx].nick, hand))
- dprintf(idx, "Can't change the permanent bot owner's handle.\n");
- else if (!strcasecmp(newhand, botnetnick) && (!(atr2 & USER_BOT) ||
- nextbot(hand) != -1))
- dprintf(idx, "Hey! That's MY name!\n");
- else if (change_handle(u2, newhand)) {
- putlog(LOG_CMDS, "*", "#%s# chnick %s %s", dcc[idx].nick,
- hand, newhand);
- dprintf(idx, "Changed.\n");
- } else
- dprintf(idx, "Failed.\n");
- }
- }
- static void cmd_nick(struct userrec *u, int idx, char *par)
- {
- char oldnick[HANDLEN + 1], newnick[HANDLEN + 1];
- int i;
- strncpy(newnick, newsplit(&par), HANDLEN);
- newnick[HANDLEN] = 0;
- if (!newnick[0]) {
- dprintf(idx, "Usage: nick <new-handle>\n");
- return;
- }
- for (i = 0; i < strlen(newnick); i++)
- if ((newnick[i] <= 32) || (newnick[i] >= 127) || (newnick[i] == '@'))
- newnick[i] = '?';
- if (strchr(BADHANDCHARS, newnick[0]) != NULL) {
- dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with '%c'\n",
- newnick[0]);
- } else if (get_user_by_handle(userlist, newnick) &&
- strcasecmp(dcc[idx].nick, newnick)) {
- dprintf(idx, "Somebody is already using %s.\n", newnick);
- } else if (!strcasecmp(newnick, botnetnick)) {
- dprintf(idx, "Hey! That's MY name!\n");
- } else {
- strncpy(oldnick, dcc[idx].nick, HANDLEN);
- oldnick[HANDLEN] = 0;
- if (change_handle(u, newnick)) {
- putlog(LOG_CMDS, "*", "#%s# nick %s", oldnick, newnick);
- dprintf(idx, "Okay, changed.\n");
- } else
- dprintf(idx, "Failed.\n");
- }
- }
- static void cmd_chpass(struct userrec *u, int idx, char *par)
- {
- char *handle, *new;
- int atr = u ? u->flags : 0, l;
- if (!par[0])
- dprintf(idx, "Usage: chpass <handle> [password]\n");
- else {
- handle = newsplit(&par);
- u = get_user_by_handle(userlist, handle);
- if (!u)
- dprintf(idx, "No such user.\n");
- else if ((atr & USER_BOTMAST) && !(atr & USER_MASTER) &&
- !(u->flags & USER_BOT))
- dprintf(idx, "You can't change password for non-bots.\n");
- else if ((bot_flags(u) & BOT_SHARE) && !(atr & USER_OWNER))
- dprintf(idx, "You can't change shared bot's password.\n");
- else if ((u->flags & USER_OWNER) && !(atr & USER_OWNER) &&
- strcasecmp(handle, dcc[idx].nick))
- dprintf(idx, "Can't change the bot owner's password.\n");
- else if (isowner(handle) && strcasecmp(dcc[idx].nick, handle))
- dprintf(idx, "Can't change the permanent bot owner's password.\n");
- else if (!par[0]) {
- putlog(LOG_CMDS, "*", "#%s# chpass %s [nothing]", dcc[idx].nick,
- handle);
- set_user(&USERENTRY_PASS, u, NULL);
- dprintf(idx, "Removed password.\n");
- } else {
- l = strlen(new = newsplit(&par));
- if (l > 16)
- new[16] = 0;
- if (l < 6)
- dprintf(idx, "Please use at least 6 characters.\n");
- else {
- set_user(&USERENTRY_PASS, u, new);
- putlog(LOG_CMDS, "*", "#%s# chpass %s [something]", dcc[idx].nick,
- handle);
- dprintf(idx, "Changed password.\n");
- }
- }
- }
- }
- static void cmd_chaddr(struct userrec *u, int idx, char *par)
- {
- char *handle, *addr, *p, *q;
- struct bot_addr *bi;
- struct userrec *u1;
- if (!par[0]) {
- dprintf(idx, "Usage: chaddr <botname> <address:botport#/userport#>\n");
- return;
- }
- handle = newsplit(&par);
- addr = newsplit(&par);
- if (strlen(addr) > UHOSTMAX)
- addr[UHOSTMAX] = 0;
- u1 = get_user_by_handle(userlist, handle);
- if (!u1 || !(u1->flags & USER_BOT)) {
- dprintf(idx, "Useful only for tandem bots.\n");
- return;
- }
- if ((bot_flags(u1) & BOT_SHARE) && (!u || !u->flags & USER_OWNER)) {
- dprintf(idx, "You can't change shared bot's address.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# chaddr %s %s", dcc[idx].nick, handle, addr);
- dprintf(idx, "Changed bot's address.\n");
- bi = user_malloc(sizeof(struct bot_addr));
- q = strchr(addr, ':');
- if (!q) {
- bi->address = user_malloc(strlen(addr) + 1);
- strcpy(bi->address, addr);
- bi->telnet_port = 3333;
- bi->relay_port = 3333;
- } else {
- bi->address = user_malloc(q - addr + 1);
- strncpy(bi->address, addr, q - addr);
- bi->address[q - addr] = 0;
- p = q + 1;
- bi->telnet_port = atoi(p);
- q = strchr(p, '/');
- if (!q) {
- bi->relay_port = bi->telnet_port;
- } else {
- bi->relay_port = atoi(q + 1);
- }
- }
- set_user(&USERENTRY_BOTADDR, u1, bi);
- }
- static void cmd_comment(struct userrec *u, int idx, char *par)
- {
- char *handle;
- struct userrec *u1;
- if (!par[0]) {
- dprintf(idx, "Usage: comment <handle> <newcomment>\n");
- return;
- }
- handle = newsplit(&par);
- u1 = get_user_by_handle(userlist, handle);
- if (!u1) {
- dprintf(idx, "No such user!\n");
- return;
- }
- if ((u1->flags & USER_OWNER) && !(u && (u->flags & USER_OWNER)) &&
- strcasecmp(handle, dcc[idx].nick)) {
- dprintf(idx, "Can't change comment on the bot owner.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# comment %s %s", dcc[idx].nick, handle, par);
- if (!strcasecmp(par, "none")) {
- dprintf(idx, "Okay, comment blanked.\n");
- set_user(&USERENTRY_COMMENT, u1, NULL);
- return;
- }
- dprintf(idx, "Changed comment.\n");
- set_user(&USERENTRY_COMMENT, u1, par);
- }
- static void cmd_restart(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# restart", dcc[idx].nick);
- if (!backgrd) {
- dprintf(idx, "You can not .restart a bot when running -n (due to tcl)\n");
- return;
- }
- dprintf(idx, "Restarting.\n");
- if (make_userfile) {
- putlog(LOG_MISC, "*",
- "Uh, guess you don't need to create a new userfile.");
- make_userfile = 0;
- }
- write_userfile(-1);
- putlog(LOG_MISC, "*", "Restarting ...");
- wipe_timers(interp, &utimer);
- wipe_timers(interp, &timer);
- do_restart = idx;
- }
- static void cmd_rehash(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# rehash", dcc[idx].nick);
- dprintf(idx, "Rehashing.\n");
- if (make_userfile) {
- putlog(LOG_MISC, "*",
- "Uh, guess you don't need to create a new userfile.");
- make_userfile = 0;
- }
- write_userfile(-1);
- putlog(LOG_MISC, "*", "Rehashing ...");
- do_restart = -2;
- }
- static void cmd_reload(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# reload", dcc[idx].nick);
- dprintf(idx, "Reloading user file...\n");
- reload();
- }
- /* this get replaced in server.so with a version that handles the server */
- void cmd_die(struct userrec *u, int idx, char *par)
- {
- char s[1024];
- putlog(LOG_CMDS, "*", "#%s# die %s", dcc[idx].nick, par);
- if (par[0]) {
- simple_sprintf(s, "BOT SHUTDOWN (%s: %s)", dcc[idx].nick, par);
- } else {
- simple_sprintf(s, "BOT SHUTDOWN (authorized by %s)", dcc[idx].nick);
- }
- chatout("*** %s\n", s);
- botnet_send_chat(-1, botnetnick, s);
- botnet_send_bye();
- write_userfile(-1);
- simple_sprintf(s, "DIE BY %s!%s (%s)", dcc[idx].nick,
- dcc[idx].host, par[0] ? par : "request");
- fatal(s, 0);
- }
- static void cmd_debug(struct userrec *u, int idx, char *par)
- {
- if (!strcasecmp(par, "help")) {
- putlog(LOG_CMDS, "*", "#%s# debug help", dcc[idx].nick);
- debug_help(idx);
- } else {
- putlog(LOG_CMDS, "*", "#%s# debug", dcc[idx].nick);
- debug_mem_to_dcc(idx);
- }
- }
- static void cmd_simul(struct userrec *u, int idx, char *par)
- {
- char *nick;
- int i, ok = 0;
- nick = newsplit(&par);
- if (!par[0]) {
- dprintf(idx, "Usage: simul <nick> <text>\n");
- return;
- }
- if (isowner(nick)) {
- dprintf(idx, "Unable to '.simul' permanent owners.\n");
- return;
- }
- for (i = 0; i < dcc_total; i++)
- if (!strcasecmp(nick, dcc[i].nick) && !ok &&
- (dcc[i].type->flags & DCT_SIMUL)) {
- putlog(LOG_CMDS, "*", "#%s# simul %s %s", dcc[idx].nick, nick, par);
- if (dcc[i].type && dcc[i].type->activity) {
- dcc[i].type->activity(i, par, strlen(par));
- ok = 1;
- }
- }
- if (!ok)
- dprintf(idx, "No such user on the party line.\n");
- }
- static void cmd_link(struct userrec *u, int idx, char *par)
- {
- char *s;
- int i;
- if (!par[0]) {
- dprintf(idx, "Usage: link [some-bot] <new-bot>\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# link %s", dcc[idx].nick, par);
- s = newsplit(&par);
- if (!par[0] || !strcasecmp(par, botnetnick))
- botlink(dcc[idx].nick, idx, s);
- else {
- char x[40];
- i = nextbot(s);
- if (i < 0) {
- dprintf(idx, "No such bot online.\n");
- return;
- }
- simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
- botnet_send_link(i, x, s, par);
- }
- }
- static void cmd_unlink(struct userrec *u, int idx, char *par)
- {
- int i;
- char *bot;
- if (!par[0]) {
- dprintf(idx, "Usage: unlink <bot> [reason]\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# unlink %s", dcc[idx].nick, par);
- bot = newsplit(&par);
- i = nextbot(bot);
- if (i < 0) {
- botunlink(idx, bot, par);
- return;
- }
- /* if we're directly connected to that bot, just do it
- * (is nike gunna sue?) */
- if (!strcasecmp(dcc[i].nick, bot))
- botunlink(idx, bot, par);
- else {
- char x[40];
- simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
- botnet_send_unlink(i, x, lastbot(bot), bot, par);
- }
- }
- static void cmd_relay(struct userrec *u, int idx, char *par)
- {
- if (!par[0]) {
- dprintf(idx, "Usage: relay <bot>\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# relay %s", dcc[idx].nick, par);
- tandem_relay(idx, par, 0);
- }
- static void cmd_save(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# save", dcc[idx].nick);
- dprintf(idx, "Saving user file...\n");
- write_userfile(-1);
- }
- static void cmd_backup(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# backup", dcc[idx].nick);
- dprintf(idx, "Backing up the user file...\n");
- backup_userfile();
- }
- static void cmd_trace(struct userrec *u, int idx, char *par)
- {
- int i;
- char x[NOTENAMELEN + 11], y[11];
- if (!par[0]) {
- dprintf(idx, "Usage: trace <botname>\n");
- return;
- }
- if (!strcasecmp(par, botnetnick)) {
- dprintf(idx, "That's me! Hiya! :)\n");
- return;
- }
- i = nextbot(par);
- if (i < 0) {
- dprintf(idx, "Unreachable bot.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# trace %s", dcc[idx].nick, par);
- simple_sprintf(x, "%d:%s@%s", dcc[idx].sock, dcc[idx].nick, botnetnick);
- simple_sprintf(y, ":%d", now);
- botnet_send_trace(i, x, par, y);
- }
- static void cmd_binds(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# binds %s", dcc[idx].nick, par);
- tell_binds(idx, par);
- }
- static void cmd_banner(struct userrec *u, int idx, char *par)
- {
- char s[1024];
- int i;
- if (!par[0]) {
- dprintf(idx, "Usage: banner <message>\n");
- return;
- }
- simple_sprintf(s, "\007\007### Botwide:[%s] %s\n", dcc[idx].nick, par);
- for (i = 0; i < dcc_total; i++)
- if (dcc[i].type->flags & DCT_MASTER)
- dprintf(i, "%s", s);
- }
- /* after messing with someone's user flags, make sure the dcc-chat flags
- * are set correctly */
- int check_dcc_attrs(struct userrec *u, int oatr)
- {
- int i, stat;
- char *p, *q, s[121];
- /* if it matches someone in the owner list, make sure he/she has +n */
- if (!u)
- return 0;
- /* make sure default owners are +n */
- if (owner[0]) {
- q = owner;
- p = strchr(q, ',');
- while (p) {
- strncpy(s, q, p - q);
- s[p - q] = 0;
- rmspace(s);
- if (!strcasecmp(u->handle, s))
- u->flags = sanity_check(u->flags | USER_OWNER);
- q = p + 1;
- p = strchr(q, ',');
- }
- strcpy(s, q);
- rmspace(s);
- if (!strcasecmp(u->handle, s))
- u->flags = sanity_check(u->flags | USER_OWNER);
- }
- for (i = 0; i < dcc_total; i++) {
- if ((dcc[i].type->flags & DCT_MASTER) &&
- (!strcasecmp(u->handle, dcc[i].nick))) {
- stat = dcc[i].status;
- if ((dcc[i].type == &DCC_CHAT) &&
- ((u->flags & (USER_OP | USER_MASTER | USER_OWNER |
- USER_BOTMAST))
- != (oatr & (USER_OP | USER_MASTER | USER_OWNER |
- USER_BOTMAST)))) {
- botnet_send_join_idx(i, -1);
- }
- if ((oatr & USER_MASTER) && !(u->flags & USER_MASTER)) {
- struct flag_record fr =
- {FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
- dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS | LOG_RAW |
- LOG_FILES | LOG_LEV1 | LOG_LEV2 |
- LOG_LEV3 | LOG_LEV4 | LOG_LEV5 |
- LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
- LOG_WALL | LOG_DEBUG);
- get_user_flagrec(u, &fr, NULL);
- if (!chan_master(fr))
- dcc[i].u.chat->con_flags |= (LOG_MISC | LOG_CMDS);
- dprintf(i, "*** POOF! ***\n");
- dprintf(i, "You are no longer a master on this bot.\n");
- }
- if (!(oatr & USER_MASTER) && (u->flags & USER_MASTER)) {
- dcc[i].u.chat->con_flags |= conmask;
- dprintf(i, "*** POOF! ***\n");
- dprintf(i, "You are now a master on this bot.\n");
- }
- if (!(oatr & USER_BOTMAST) && (u->flags & USER_BOTMAST)) {
- dprintf(i, "### POOF! ###\n");
- dprintf(i, "You are now a botnet master on this bot.\n");
- }
- if ((oatr & USER_BOTMAST) && !(u->flags & USER_BOTMAST)) {
- dprintf(i, "### POOF! ###\n");
- dprintf(i, "You are no longer a botnet master on this bot.\n");
- }
- if (!(oatr & USER_OWNER) && (u->flags & USER_OWNER)) {
- dprintf(i, "@@@ POOF! @@@\n");
- dprintf(i, "You are now an OWNER of this bot.\n");
- }
- if ((oatr & USER_OWNER) && !(u->flags & USER_OWNER)) {
- dprintf(i, "@@@ POOF! @@@\n");
- dprintf(i, "You are no longer an owner of this bot.\n");
- }
- if ((stat & STAT_PARTY) && (u->flags & USER_OP))
- stat &= ~STAT_PARTY;
- if (!(stat & STAT_PARTY) && !(u->flags & USER_OP) &&
- !(u->flags & USER_MASTER))
- stat |= STAT_PARTY;
- if ((stat & STAT_CHAT) && !(u->flags & USER_PARTY) &&
- !(u->flags & USER_MASTER) &&
- (!(u->flags & USER_OP) || require_p))
- stat &= ~STAT_CHAT;
- if ((dcc[i].type->flags & DCT_FILES) && !(stat & STAT_CHAT) &&
- ((u->flags & USER_MASTER) || (u->flags & USER_PARTY) ||
- ((u->flags & USER_OP) && !require_p)))
- stat |= STAT_CHAT;
- dcc[i].status = stat;
- /* check if they no longer have access to wherever they are */
- /* DON'T kick someone off the party line just cuz they lost +p
- * (pinvite script removes +p after 5 mins automatically) */
- if ((dcc[i].type->flags & DCT_FILES) && !(u->flags & USER_XFER) &&
- !(u->flags & USER_MASTER)) {
- dprintf(i, "-+- POOF! -+-\n");
- dprintf(i, "You no longer have file area access.\n\n");
- putlog(LOG_MISC, "*", "DCC user [%s]%s removed from file system",
- dcc[i].nick, dcc[i].host);
- if (dcc[i].status & STAT_CHAT) {
- struct chat_info *ci;
- ci = dcc[i].u.file->chat;
- nfree(dcc[i].u.file);
- dcc[i].u.chat = ci;
- dcc[i].status &= (~STAT_CHAT);
- dcc[i].type = &DCC_CHAT;
- if (dcc[i].u.chat->channel >= 0) {
- chanout_but(-1, dcc[i].u.chat->channel,
- "*** %s has returned.\n", dcc[i].nick);
- Context;
- if (dcc[i].u.chat->channel < 100000)
- botnet_send_join_idx(i, -1);
- }
- } else {
- killsock(dcc[i].sock);
- lostdcc(i);
- }
- }
- }
- if ((dcc[i].type == &DCC_BOT) && !strcasecmp(u->handle, dcc[i].nick)) {
- if ((dcc[i].status & STAT_LEAF) && !(u->flags & BOT_LEAF))
- dcc[i].status &= ~(STAT_LEAF | STAT_WARNED);
- if (!(dcc[i].status & STAT_LEAF) && (u->flags & BOT_LEAF))
- dcc[i].status |= STAT_LEAF;
- }
- }
- return u->flags;
- }
- int check_dcc_chanattrs(struct userrec *u, char *chname, int chflags,
- int ochatr)
- {
- int i, found = 0, atr = u ? u->flags : 0;
- struct chanset_t *chan;
- if (!u)
- return 0;
- chan = chanset;
- for (i = 0; i < dcc_total; i++) {
- if ((dcc[i].type->flags & DCT_MASTER) &&
- !strcasecmp(u->handle, dcc[i].nick)) {
- if ((dcc[i].type == &DCC_CHAT) &&
- ((chflags & (USER_OP | USER_MASTER | USER_OWNER))
- != (ochatr & (USER_OP | USER_MASTER | USER_OWNER))))
- botnet_send_join_idx(i, -1);
- if ((ochatr & USER_MASTER) && !(chflags & USER_MASTER)) {
- if (!(atr & USER_MASTER))
- dcc[i].u.chat->con_flags &= ~(LOG_MISC | LOG_CMDS);
- dprintf(i, "*** POOF! ***\n");
- dprintf(i, "You are no longer a master on %s.\n", chname);
- }
- if (!(ochatr & USER_MASTER) && (chflags & USER_MASTER)) {
- dcc[i].u.chat->con_flags |= conmask;
- if (!(atr & USER_MASTER))
- dcc[i].u.chat->con_flags &=
- ~(LOG_LEV1 | LOG_LEV2 | LOG_LEV3 | LOG_LEV4 |
- LOG_LEV5 | LOG_LEV6 | LOG_LEV7 | LOG_LEV8 |
- LOG_RAW | LOG_DEBUG | LOG_WALL | LOG_FILES | LOG_SRVOUT);
- dprintf(i, "*** POOF! ***\n");
- dprintf(i, "You are now a master on %s.\n", chname);
- }
- if (!(ochatr & USER_OWNER) && (chflags & USER_OWNER)) {
- dprintf(i, "@@@ POOF! @@@\n");
- dprintf(i, "You are now an OWNER of %s.\n", chname);
- }
- if ((ochatr & USER_OWNER) && !(chflags & USER_OWNER)) {
- dprintf(i, "@@@ POOF! @@@\n");
- dprintf(i, "You are no longer an owner of %s.\n", chname);
- }
- if (((ochatr & (USER_OP | USER_MASTER | USER_OWNER)) &&
- (!(chflags & (USER_OP | USER_MASTER | USER_OWNER)))) ||
- ((chflags & (USER_OP | USER_MASTER | USER_OWNER)) &&
- (!(ochatr & (USER_OP | USER_MASTER | USER_OWNER))))) {
- struct flag_record fr =
- {FR_CHAN, 0, 0, 0, 0, 0};
- while (chan && !found) {
- get_user_flagrec(u, &fr, chan->name);
- if (fr.chan & (USER_OP | USER_MASTER | USER_OWNER))
- found = 1;
- else
- chan = chan->next;
- }
- if (!chan)
- chan = chanset;
- if (chan)
- strcpy(dcc[i].u.chat->con_chan, chan->name);
- else
- strcpy(dcc[i].u.chat->con_chan, "*");
- }
- }
- }
- return chflags;
- }
- static void cmd_chattr(struct userrec *u, int idx, char *par)
- {
- char *hand, *arg = NULL, *tmpchg = NULL, *chg = NULL, work[1024];
- struct chanset_t *chan = NULL;
- struct userrec *u2;
- struct flag_record pls = {0, 0, 0, 0, 0, 0},
- mns = {0, 0, 0, 0, 0, 0},
- user = {0, 0, 0, 0, 0, 0};
- module_entry *me;
- int fl = -1, of = 0, ocf = 0;
- if (!par[0]) {
- dprintf(idx, "Usage: chattr <handle> [changes] [channel]\n");
- return;
- }
- hand = newsplit(&par);
- u2 = get_user_by_handle(userlist, hand);
- if (!u2) {
- dprintf(idx, "No such user!\n");
- return;
- }
- /* Parse args */
- if (par[0]) {
- arg = newsplit(&par);
- if (par[0]) {
- /* .chattr <handle> <changes> <channel> */
- chg = arg;
- arg = newsplit(&par);
- chan = findchan(arg);
- } else {
- chan = findchan(arg);
- /* ugly hack for modeless channels -- rtc */
- if (!(arg[0] == '+' && chan) &&
- !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
- /* .chattr <handle> <changes> */
- chg = arg;
- chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
- arg = NULL;
- }
- /* .chattr <handle> <channel>: nothing to do... */
- }
- }
- /* arg: pointer to channel name, NULL if none specified
- * chan: pointer to channel structure, NULL if none found or none specified
- * chg: pointer to changes, NULL if none specified
- */
- Assert(!(!arg && chan));
- if (arg && !chan) {
- dprintf(idx, "No channel record for %s.\n", arg);
- return;
- }
- if (chg) {
- if (!arg && strpbrk(chg, "&|")) {
- /* .chattr <handle> *[&|]*: use console channel if found... */
- if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
- arg = NULL;
- else
- chan = findchan(arg);
- if (arg && !chan) {
- dprintf (idx, "Invalid console channel %s.\n", arg);
- return;
- }
- } else if (arg && !strpbrk(chg, "&|")) {
- Context;
- tmpchg = nmalloc(strlen(chg) + 2);
- strcpy (tmpchg, "|");
- strcat (tmpchg, chg);
- chg = tmpchg;
- }
- }
- par = arg;
- user.match = FR_GLOBAL;
- if (chan)
- user.match |= FR_CHAN;
- get_user_flagrec(u, &user, chan ? chan->name : 0);
- if (!chan && !glob_botmast(user)) {
- dprintf(idx, "You do not have Bot Master privileges.\n");
- if (tmpchg)
- nfree(tmpchg);
- return;
- }
- if (chan && !glob_master(user) && !chan_master(user)) {
- dprintf(idx, "You do not have channel master privileges for channel %s\n",
- par);
- if (tmpchg)
- nfree(tmpchg);
- return;
- }
- user.match &= fl;
- if (chg) {
- pls.match = user.match;
- break_down_flags(chg, &pls, &mns);
- /* no-one can change these flags on-the-fly */
- pls.global &= ~(USER_BOT);
- mns.global &= ~(USER_BOT);
- if (chan) {
- pls.chan &= ~(BOT_SHARE);
- mns.chan &= ~(BOT_SHARE);
- }
- if (!glob_owner(user)) {
- pls.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
- mns.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
- if (chan) {
- pls.chan &= ~USER_OWNER;
- mns.chan &= ~USER_OWNER;
- }
- if (!glob_master(user)) {
- pls.global &= USER_PARTY | USER_XFER;
- mns.global &= USER_PARTY | USER_XFER;
- if (!glob_botmast(user)) {
- pls.global = 0;
- mns.global = 0;
- }
- }
- }
- if (chan && !chan_owner(user) && !glob_owner(user)) {
- pls.chan &= ~USER_MASTER;
- mns.chan &= ~USER_MASTER;
- if (!chan_master(user) && !glob_master(user)) {
- pls.chan = 0;
- mns.chan = 0;
- }
- }
- get_user_flagrec(u2, &user, par);
- if (user.match & FR_GLOBAL) {
- of = user.global;
- user.global = sanity_check((user.global |pls.global) &~mns.global);
- user.udef_global = (user.udef_global | pls.udef_global)
- & ~mns.udef_global;
- }
- if (chan) {
- ocf = user.chan;
- user.chan = chan_sanity_check((user.chan | pls.chan) & ~mns.chan,
- user.global);
- user.udef_chan = (user.udef_chan | pls.udef_chan) & ~mns.udef_chan;
- }
- set_user_flagrec(u2, &user, par);
- }
- if (chan)
- putlog(LOG_CMDS, "*", "#%s# (%s) chattr %s %s",
- dcc[idx].nick, chan ? chan->name : "*", hand, chg ? chg : "");
- else
- putlog(LOG_CMDS, "*", "#%s# chattr %s %s", dcc[idx].nick, hand,
- chg ? chg : "");
- /* get current flags and display them */
- if (user.match & FR_GLOBAL) {
- user.match = FR_GLOBAL;
- if (chg)
- check_dcc_attrs(u2, of);
- get_user_flagrec(u2, &user, NULL);
- build_flags(work, &user, NULL);
- if (work[0] != '-')
- dprintf(idx, "Global flags for %s are now +%s\n", hand, work);
- else
- dprintf(idx, "No global flags for %s.\n", hand);
- }
- if (chan) {
- user.match = FR_CHAN;
- get_user_flagrec(u2, &user, par);
- user.chan &= ~BOT_SHARE;
- if (chg)
- check_dcc_chanattrs(u2, chan->name, user.chan, ocf);
- build_flags(work, &user, NULL);
- if (work[0] != '-')
- dprintf(idx, "Channel flags for %s on %s are now +%s\n", hand,
- chan->name, work);
- else
- dprintf(idx, "No flags for %s on %s.\n", hand, chan->name);
- if (chg && (me = module_find("irc", 0, 0))) {
- Function *func = me->funcs;
- if (chan)
- (func[IRC_RECHECK_CHANNEL]) (chan, 0);
- }
- }
- if (tmpchg)
- nfree(tmpchg);
- }
- static void cmd_botattr(struct userrec *u, int idx, char *par)
- {
- char *hand, *chg = NULL, *arg = NULL, *tmpchg = NULL, work[1024];
- struct chanset_t *chan = NULL;
- struct userrec *u2;
- struct flag_record pls =
- {0, 0, 0, 0, 0, 0}, mns =
- {0, 0, 0, 0, 0, 0}, user =
- {0, 0, 0, 0, 0, 0};
- int idx2;
- if (!par[0]) {
- dprintf(idx, "Usage: botattr <handle> [changes] [channel]\n");
- return;
- }
- hand = newsplit(&par);
- u2 = get_user_by_handle(userlist, hand);
- if (!u2 || !(u2->flags & USER_BOT)) {
- dprintf(idx, "No such bot!\n");
- return;
- }
- for (idx2 = 0; idx2 < dcc_total; idx2++)
- if ((dcc[idx2].type != &DCC_RELAY) && !strcasecmp(dcc[idx2].nick, hand))
- break;
- if (idx2 != dcc_total) {
- dprintf(idx, "You may not change the attributes of a directly linked bot.\n");
- return;
- }
- /* Parse args */
- if (par[0]) {
- arg = newsplit(&par);
- if (par[0]) {
- /* .botattr <handle> <changes> <channel> */
- chg = arg;
- arg = newsplit(&par);
- chan = findchan(arg);
- } else {
- chan = findchan(arg);
- /* ugly hack for modeless channels -- rtc */
- if (!(arg[0] == '+' && chan) &&
- !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
- /* .botattr <handle> <changes> */
- chg = arg;
- chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
- arg = NULL;
- }
- /* .botattr <handle> <channel>: nothing to do... */
- }
- }
- /* arg: pointer to channel name, NULL if none specified
- * chan: pointer to channel structure, NULL if none found or none specified
- * chg: pointer to changes, NULL if none specified
- */
- Assert(!(!arg && chan));
- if (arg && !chan) {
- dprintf(idx, "No channel record for %s.\n", arg);
- return;
- }
- if (chg) {
- if (!arg && strpbrk(chg, "&|")) {
- /* botattr <handle> *[&|]*: use console channel if found... */
- if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
- arg = NULL;
- else
- chan = findchan(arg);
- if (arg && !chan) {
- dprintf (idx, "Invalid console channel %s.\n", arg);
- return;
- }
- } else if (arg && !strpbrk(chg, "&|")) {
- Context;
- tmpchg = nmalloc(strlen(chg) + 2);
- strcpy (tmpchg, "|");
- strcat (tmpchg, chg);
- chg = tmpchg;
- }
- }
- par = arg;
-
- user.match = FR_GLOBAL;
- get_user_flagrec(u, &user, chan ? chan->name : 0);
- if (!glob_botmast(user)) {
- dprintf(idx, "You do not have Bot Master privileges.\n");
- if (tmpchg)
- nfree(tmpchg);
- return;
- }
- if (chg) {
- user.match = FR_BOT | (chan ? FR_CHAN : 0);
- pls.match = user.match;
- break_down_flags(chg, &pls, &mns);
- /* no-one can change these flags on-the-fly */
- pls.global &=~BOT_BOT;
- mns.global &=~BOT_BOT;
- if (chan && glob_owner(user)) {
- pls.chan &= BOT_SHARE;
- mns.chan &= BOT_SHARE;
- } else {
- pls.chan = 0;
- mns.chan = 0;
- }
- if (!glob_owner(user)) {
- pls.bot &= ~(BOT_SHARE | BOT_GLOBAL);
- mns.bot &= ~(BOT_SHARE | BOT_GLOBAL);
- }
- user.match = FR_BOT | (chan ? FR_CHAN : 0);
- get_user_flagrec(u2, &user, par);
- user.bot = (user.bot | pls.bot) & ~mns.bot;
- if ((user.bot & BOT_SHARE) == BOT_SHARE)
- user.bot &= ~BOT_SHARE;
- if (chan)
- user.chan = (user.chan | pls.chan) & ~mns.chan;
- set_user_flagrec(u2, &user, par);
- }
- if (chan)
- putlog(LOG_CMDS, "*", "#%s# (%s) botattr %s %s",
- dcc[idx].nick, chan->name, hand, chg ? chg : "");
- else
- putlog(LOG_CMDS, "*", "#%s# botattr %s %s", dcc[idx].nick, hand,
- chg ? chg : "");
- /* get current flags and display them */
- if (!chan || pls.bot || mns.bot) {
- user.match = FR_BOT;
- get_user_flagrec(u2, &user, NULL);
- build_flags(work, &user, NULL);
- if (work[0] != '-')
- dprintf(idx, "Bot flags for %s are now +%s\n", hand, work);
- else
- dprintf(idx, "No bot flags for %s.\n", hand);
- }
- if (chan) {
- user.match = FR_CHAN;
- get_user_flagrec(u2, &user, par);
- user.chan &= BOT_SHARE;
- build_flags(work, &user, NULL);
- if (work[0] != '-')
- dprintf(idx, "Bot flags for %s on %s are now +%s\n", hand,
- chan->name, work);
- else
- dprintf(idx, "No bot flags for %s on %s.\n", hand, chan->name);
- }
- if (tmpchg)
- nfree(tmpchg);
- }
- static void cmd_chat(struct userrec *u, int idx, char *par)
- {
- char *arg;
- int newchan, oldchan;
- module_entry *me;
- arg = newsplit(&par);
- if (!strcasecmp(arg, "off")) {
- /* turn chat off */
- if (dcc[idx].u.chat->channel < 0) {
- dprintf(idx, "You weren't in chat anyway!\n");
- return;
- } else {
- dprintf(idx, "Leaving chat mode...\n");
- check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
- dcc[idx].u.chat->channel);
- chanout_but(-1, dcc[idx].u.chat->channel,
- "*** %s left the party line.\n",
- dcc[idx].nick);
- Context;
- if (dcc[idx].u.chat->channel < 100000)
- botnet_send_part_idx(idx, "");
- }
- dcc[idx].u.chat->channel = (-1);
- } else {
- if (arg[0] == '*') {
- if (((arg[1] < '0') || (arg[1] > '9'))) {
- if (arg[1] == 0)
- newchan = 0;
- else {
- Tcl_SetVar(interp, "chan", arg, 0);
- if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) == TCL_OK) &&
- interp->result[0])
- newchan = atoi(interp->result);
- else
- newchan = -1;
- }
- if (newchan < 0) {
- dprintf(idx, "No channel by that name.\n");
- return;
- }
- } else
- newchan = 100000 + atoi(arg + 1);
- if (newchan < 100000 || newchan > 199999) {
- dprintf(idx, "Channel # out of range: local channels must be *0-*99999\n");
- return;
- }
- } else {
- if (((arg[0] < '0') || (arg[0] > '9')) && (arg[0])) {
- if (!strcasecmp(arg, "on"))
- newchan = 0;
- else {
- Tcl_SetVar(interp, "chan", arg, 0);
- if ((Tcl_VarEval(interp, "assoc ", "$chan", NULL) == TCL_OK) &&
- interp->result[0])
- newchan = atoi(interp->result);
- else
- newchan = -1;
- }
- if (newchan < 0) {
- dprintf(idx, "No channel by that name.\n");
- return;
- }
- } else
- newchan = atoi(arg);
- if ((newchan < 0) || (newchan > 99999)) {
- dprintf(idx, "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);
- if (dcc[idx].u.chat->channel == newchan) {
- if (newchan == 0) {
- dprintf(idx, "You're already on the party line!\n");
- return;
- } else {
- dprintf(idx, "You're already on channel %s%d!\n",
- (newchan < 100000) ? "" : "*", newchan % 100000);
- return;
- }
- } else {
- oldchan = dcc[idx].u.chat->channel;
- if (oldchan >= 0)
- check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, oldchan);
- if (oldchan == 0) {
- chanout_but(-1, 0, "*** %s left the party line.\n", dcc[idx].nick);
- Context;
- } else if (oldchan > 0) {
- chanout_but(-1, oldchan, "*** %s left the channel.\n", dcc[idx].nick);
- Context;
- }
- dcc[idx].u.chat->channel = newchan;
- if (newchan == 0) {
- dprintf(idx, "Entering the party line...\n");
- chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick);
- Context;
- } else {
- dprintf(idx, "Joining channel '%s'...\n", arg);
- chanout_but(-1, newchan, "*** %s joined the channel.\n", dcc[idx].nick);
- Context;
- }
- check_tcl_chjn(botnetnick, dcc[idx].nick, newchan, geticon(idx),
- dcc[idx].sock, dcc[idx].host);
- if (newchan < 100000)
- botnet_send_join_idx(idx, oldchan);
- else if (oldchan < 100000)
- botnet_send_part_idx(idx, "");
- }
- }
- /* new style autosave here too -- rtc, 09/28/1999*/
- if ((me = module_find("console", 1, 1))) {
- Function *func = me->funcs;
- (func[CONSOLE_DOSTORE]) (idx);
- }
- }
- static void cmd_echo(struct userrec *u, int idx, char *par)
- {
- module_entry *me;
- if (!par[0]) {
- dprintf(idx, "Echo is currently %s.\n", dcc[idx].status & STAT_ECHO ?
- "on" : "off");
- return;
- }
- if (!strcasecmp(par, "on")) {
- dprintf(idx, "Echo turned on.\n");
- dcc[idx].status |= STAT_ECHO;
- } else if (!strcasecmp(par, "off")) {
- dprintf(idx, "Echo turned off.\n");
- dcc[idx].status &= ~STAT_ECHO;
- } else {
- dprintf(idx, "Usage: echo <on/off>\n");
- return;
- }
- /* new style autosave here too -- rtc, 09/28/1999*/
- if ((me = module_find("console", 1, 1))) {
- Function *func = me->funcs;
- (func[CONSOLE_DOSTORE]) (idx);
- }
- }
- int stripmodes(char *s)
- {
- int res = 0;
- for (; *s; s++)
- switch (tolower(*s)) {
- case 'b':
- res |= STRIP_BOLD;
- break;
- case 'c':
- res |= STRIP_COLOR;
- break;
- case 'r':
- res |= STRIP_REV;
- break;
- case 'u':
- res |= STRIP_UNDER;
- break;
- case 'a':
- res |= STRIP_ANSI;
- break;
- case 'g':
- res |= STRIP_BELLS;
- break;
- case '*':
- res |= STRIP_ALL;
- break;
- }
- return res;
- }
- char *stripmasktype(int x)
- {
- static char s[20];
- char *p = s;
- if (x & STRIP_BOLD)
- *p++ = 'b';
- if (x & STRIP_COLOR)
- *p++ = 'c';
- if (x & STRIP_REV)
- *p++ = 'r';
- if (x & STRIP_UNDER)
- *p++ = 'u';
- if (x & STRIP_ANSI)
- *p++ = 'a';
- if (x & STRIP_BELLS)
- *p++ = 'g';
- if (p == s)
- *p++ = '-';
- *p = 0;
- return s;
- }
- static char *stripmaskname(int x)
- {
- static char s[161];
- int i = 0;
- s[i] = 0;
- if (x & STRIP_BOLD)
- i += my_strcpy(s + i, "bold, ");
- if (x & STRIP_COLOR)
- i += my_strcpy(s + i, "color, ");
- if (x & STRIP_REV)
- i += my_strcpy(s + i, "reverse, ");
- if (x & STRIP_UNDER)
- i += my_strcpy(s + i, "underline, ");
- if (x & STRIP_ANSI)
- i += my_strcpy(s + i, "ansi, ");
- if (x & STRIP_BELLS)
- i += my_strcpy(s + i, "bells, ");
- if (!i)
- strcpy(s, "none");
- else
- s[i - 2] = 0;
- return s;
- }
- static void cmd_strip(struct userrec *u, int idx, char *par)
- {
- char *nick, *changes, *c, s[2];
- int dest = 0, i, pls, md, ok = 0;
- module_entry *me;
- if (!par[0]) {
- dprintf(idx, "Your current strip settings are: %s (%s)\n",
- stripmasktype(dcc[idx].u.chat->strip_flags),
- stripmaskname(dcc[idx].u.chat->strip_flags));
- return;
- }
- nick = newsplit(&par);
- if ((nick[0] != '+') && (nick[0] != '-') && u &&
- (u->flags & USER_MASTER)) {
- for (i = 0; i < dcc_total; i++)
- if (!strcasecmp(nick, dcc[i].nick) && (dcc[i].type == &DCC_CHAT) &&
- !ok) {
- ok = 1;
- dest = i;
- }
- if (!ok) {
- dprintf(idx, "No such user on the party line!\n");
- return;
- }
- changes = par;
- } else {
- changes = nick;
- nick = "";
- dest = idx;
- }
- c = changes;
- if ((c[0] != '+') && (c[0] != '-'))
- dcc[dest].u.chat->strip_flags = 0;
- s[1] = 0;
- for (pls = 1; *c; c++) {
- switch (*c) {
- case '+':
- pls = 1;
- break;
- case '-':
- pls = 0;
- break;
- default:
- s[0] = *c;
- md = stripmodes(s);
- if (pls == 1)
- dcc[dest].u.chat->strip_flags |= md;
- else
- dcc[dest].u.chat->strip_flags &= ~md;
- }
- }
- if (nick[0])
- putlog(LOG_CMDS, "*", "#%s# strip %s %s", dcc[idx].nick, nick, changes);
- else
- putlog(LOG_CMDS, "*", "#%s# strip %s", dcc[idx].nick, changes);
- if (dest == idx) {
- dprintf(idx, "Your strip settings are: %s (%s)\n",
- stripmasktype(dcc[idx].u.chat->strip_flags),
- stripmaskname(dcc[idx].u.chat->strip_flags));
- } else {
- dprintf(idx, "Strip setting for %s: %s (%s)\n", dcc[dest].nick,
- stripmasktype(dcc[dest].u.chat->strip_flags),
- stripmaskname(dcc[dest].u.chat->strip_flags));
- dprintf(dest, "%s set your strip settings to: %s (%s)\n", dcc[idx].nick,
- stripmasktype(dcc[dest].u.chat->strip_flags),
- stripmaskname(dcc[dest].u.chat->strip_flags));
- }
- /* new style autosave here too -- rtc, 09/28/1999*/
- if ((me = module_find("console", 1, 1))) {
- Function *func = me->funcs;
- (func[CONSOLE_DOSTORE]) (dest);
- }
- }
- static void cmd_su(struct userrec *u, int idx, char *par)
- {
- int atr = u ? u->flags : 0;
- struct flag_record fr = {FR_ANYWH | FR_CHAN | FR_GLOBAL, 0, 0, 0, 0, 0};
- Context;
- u = get_user_by_handle(userlist, par);
- if (!par[0])
- dprintf(idx, "Usage: su <user>\n");
- else if (!u)
- dprintf(idx, "No such user.\n");
- else if (u->flags & USER_BOT)
- dprintf(idx, "Can't su to a bot... then again, why would you wanna?\n");
- else if (dcc[idx].u.chat->su_nick)
- dprintf(idx, "You cannot currently double .su, try .su'ing directly\n");
- else {
- get_user_flagrec(u, &fr, NULL);
- if ((!glob_party(fr) && (require_p || !(glob_op(fr) || chan_op(fr)))) &&
- !(atr & USER_BOTMAST))
- dprintf(idx, "No party line access permitted for %s.\n", par);
- else {
- correct_handle(par);
- putlog(LOG_CMDS, "*", "#%s# su %s", dcc[idx].nick, par);
- if (!(atr & USER_OWNER) ||
- ((atr & USER_OWNER) && !(isowner(dcc[idx].nick))) ||
- ((u->flags & USER_OWNER) && (isowner(par)))) {
- /* This check is only important for non-owners */
- if (u_pass_match(u, "-")) {
- dprintf(idx, "No password set for user. You may not .su to them\n");
- return;
- }
- if (dcc[idx].u.chat->channel < 100000)
- botnet_send_part_idx(idx, "");
- chanout_but(-1, dcc[idx].u.chat->channel,
- "*** %s left the party line.\n", dcc[idx].nick);
- Context;
- /* store the old nick in the away section, for weenies who can't get
- * their password right ;) */
- if (dcc[idx].u.chat->away != NULL)
- nfree(dcc[idx].u.chat->away);
- dcc[idx].u.chat->away = get_data_ptr(strlen(dcc[idx].nick) + 1);
- strcpy(dcc[idx].u.chat->away, dcc[idx].nick);
- dcc[idx].u.chat->su_nick = get_data_ptr(strlen(dcc[idx].nick) + 1);
- strcpy(dcc[idx].u.chat->su_nick, dcc[idx].nick);
- dcc[idx].user = u;
- strcpy(dcc[idx].nick, par);
- dprintf(idx, "Enter password for %s%s\n", par,
- (dcc[idx].status & STAT_TELNET) ? "\377\373\001" : "");
- dcc[idx].type = &DCC_CHAT_PASS;
- } else if (atr & USER_OWNER) {
- if (dcc[idx].u.chat->channel < 100000)
- botnet_send_part_idx(idx, "");
- chanout_but(-1, dcc[idx].u.chat->channel,
- "*** %s left the party line.\n", dcc[idx].nick);
- dprintf(idx, "Setting your username to %s.\n", par);
- if (atr & USER_MASTER)
- dcc[idx].u.chat->con_flags = conmask;
- dcc[idx].u.chat->su_nick = get_data_ptr(strlen(dcc[idx].nick) + 1);
- strcpy(dcc[idx].u.chat->su_nick, dcc[idx].nick);
- dcc[idx].user = u;
- strcpy(dcc[idx].nick, par);
- dcc_chatter(idx);
- }
- }
- }
- }
- static void cmd_fixcodes(struct userrec *u, int idx, char *par)
- {
- if (dcc[idx].status & STAT_ECHO) {
- dcc[idx].status |= STAT_TELNET;
- dcc[idx].status &= ~STAT_ECHO;
- dprintf(idx, "Turned on telnet codes\n");
- putlog(LOG_CMDS, "*", "#%s# fixcodes (telnet on)", dcc[idx].nick);
- return;
- }
- if (dcc[idx].status & STAT_TELNET) {
- dcc[idx].status |= STAT_ECHO;
- dcc[idx].status &= ~STAT_TELNET;
- dprintf(idx, "Turned off telnet codes\n");
- putlog(LOG_CMDS, "*", "#%s# fixcodes (telnet off)", dcc[idx].nick);
- return;
- }
- }
- static void cmd_page(struct userrec *u, int idx, char *par)
- {
- int a;
- module_entry *me;
- if (!par[0]) {
- if (dcc[idx].status & STAT_PAGE) {
- dprintf(idx, "Currently paging outputs to %d lines.\n",
- dcc[idx].u.chat->max_line);
- } else
- dprintf(idx, "You dont have paging on.\n");
- return;
- }
- a = atoi(par);
- if (!strcasecmp(par, "off") || (a == 0 && par[0] == 0)) {
- dcc[idx].status &= ~STAT_PAGE;
- dcc[idx].u.chat->max_line = 0x7ffffff; /* flush_lines needs this */
- while (dcc[idx].u.chat->buffer)
- flush_lines(idx, dcc[idx].u.chat);
- dprintf(idx, "Paging turned off.\n");
- putlog(LOG_CMDS, "*", "#%s# page off", dcc[idx].nick);
- } else if (a > 0) {
- dprintf(idx, "Paging turned on, stopping every %d lines.\n", a);
- dcc[idx].status |= STAT_PAGE;
- dcc[idx].u.chat->max_line = a;
- dcc[idx].u.chat->line_count = 0;
- dcc[idx].u.chat->current_lines = 0;
- putlog(LOG_CMDS, "*", "#%s# page %d", dcc[idx].nick, a);
- return;
- } else {
- dprintf(idx, "Usage: page <off or #>\n");
- return;
- }
- /* new style autosave here too -- rtc, 09/28/1999*/
- if ((me = module_find("console", 1, 1))) {
- Function *func = me->funcs;
- (func[CONSOLE_DOSTORE]) (idx);
- }
- }
- /* evaluate a Tcl command, send output to a dcc user */
- static void cmd_tcl(struct userrec *u, int idx, char *msg)
- {
- int code;
- if (!(isowner(dcc[idx].nick)) && (must_be_owner)) {
- dprintf(idx, MISC_NOSUCHCMD);
- return;
- }
- debug1("tcl: evaluate (.tcl): %s", msg);
- code = Tcl_GlobalEval(interp, msg);
- if (code == TCL_OK)
- dumplots(idx, "Tcl: ", interp->result);
- else
- dumplots(idx, "TCL error: ", interp->result);
- }
- /* perform a 'set' command */
- static void cmd_set(struct userrec *u, int idx, char *msg)
- {
- int code;
- char s[512];
- if (!(isowner(dcc[idx].nick)) && (must_be_owner)) {
- dprintf(idx, MISC_NOSUCHCMD);
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# set %s", dcc[idx].nick, msg);
- strcpy(s, "set ");
- if (!msg[0]) {
- strcpy(s, "info globals");
- Tcl_Eval(interp, s);
- dumplots(idx, "global vars: ", interp->result);
- return;
- }
- strcpy(s + 4, msg);
- code = Tcl_Eval(interp, s);
- if (code == TCL_OK) {
- if (!strchr(msg, ' '))
- dumplots(idx, "currently: ", interp->result);
- else
- dprintf(idx, "Ok, set.\n");
- } else
- dprintf(idx, "Error: %s\n", interp->result);
- }
- static void cmd_module(struct userrec *u, int idx, char *par)
- {
- Context;
- putlog(LOG_CMDS, "*", "#%s# module %s", dcc[idx].nick, par);
- do_module_report(idx, 2, par[0] ? par : NULL);
- }
- static void cmd_loadmod(struct userrec *u, int idx, char *par)
- {
- const char *p;
- if (!(isowner(dcc[idx].nick)) && (must_be_owner)) {
- dprintf(idx, MISC_NOSUCHCMD);
- return;
- }
- Context;
- if (!par[0]) {
- dprintf(idx, "%s: loadmod <module>\n", USAGE);
- } else {
- p = module_load(par);
- if (p)
- dprintf(idx, "%s: %s %s\n", par, MOD_LOADERROR, p);
- else {
- putlog(LOG_CMDS, "*", "#%s# loadmod %s", dcc[idx].nick, par);
- dprintf(idx, "%s %s\n", MOD_LOADED, par);
- }
- }
- Context;
- }
- static void cmd_unloadmod(struct userrec *u, int idx, char *par)
- {
- char *p;
- if (!(isowner(dcc[idx].nick)) && (must_be_owner)) {
- dprintf(idx, MISC_NOSUCHCMD);
- return;
- }
- Context;
- if (!par[0]) {
- dprintf(idx, "%s: unloadmod <module>\n", USAGE);
- } else {
- p = module_unload(par, dcc[idx].nick);
- if (p)
- dprintf(idx, "%s %s: %s\n", MOD_UNLOADERROR, par, p);
- else {
- putlog(LOG_CMDS, "*", "#%s# unloadmod %s", dcc[idx].nick, par);
- dprintf(idx, "%s %s\n", MOD_UNLOADED, par);
- }
- }
- }
- static void cmd_pls_ignore(struct userrec *u, int idx, char *par)
- {
- char *who;
- char s[UHOSTLEN];
- if (!par[0]) {
- dprintf(idx, "Usage: +ignore <hostmask> [comment]\n");
- return;
- }
- who = newsplit(&par);
- remove_gunk(who);
- if (!par[0])
- par = "requested";
- else if (strlen(par) > 65)
- par[65] = 0;
- if (strlen(who) > UHOSTMAX - 4)
- who[UHOSTMAX - 4] = 0;
- /* fix missing ! or @ BEFORE continuing - sounds familiar */
- if (!strchr(who, '!')) {
- if (!strchr(who, '@'))
- simple_sprintf(s, "%s!*@*", who);
- else
- simple_sprintf(s, "*!%s", who);
- } else if (!strchr(who, '@'))
- simple_sprintf(s, "%s@*", who);
- else
- strcpy(s, who);
- if (match_ignore(s)) {
- dprintf(idx, "That already matches an existing ignore.\n");
- return;
- }
- dprintf(idx, "Now ignoring: %s (%s)\n", s, par);
- addignore(s, dcc[idx].nick, par, 0L);
- putlog(LOG_CMDS, "*", "#%s# +ignore %s %s", dcc[idx].nick, s, par);
- }
- static void cmd_mns_ignore(struct userrec *u, int idx, char *par)
- {
- char buf[UHOSTLEN];
- if (!par[0]) {
- dprintf(idx, "Usage: -ignore <hostmask | ignore #>\n");
- return;
- }
- strncpy(buf, par, UHOSTMAX);
- buf[UHOSTMAX] = 0;
- if (delignore(buf)) {
- putlog(LOG_CMDS, "*", "#%s# -ignore %s", dcc[idx].nick, buf);
- dprintf(idx, "No longer ignoring: %s\n", buf);
- } else
- dprintf(idx, "Can't find that ignore.\n");
- }
- static void cmd_ignores(struct userrec *u, int idx, char *par)
- {
- putlog(LOG_CMDS, "*", "#%s# ignores %s", dcc[idx].nick, par);
- tell_ignores(idx, par);
- }
- static void cmd_pls_user(struct userrec *u, int idx, char *par)
- {
- char *handle, *host;
- if (!par[0]) {
- dprintf(idx, "Usage: +user <handle> <hostmask>\n");
- return;
- }
- handle = newsplit(&par);
- host = newsplit(&par);
- if (strlen(handle) > HANDLEN)
- handle[HANDLEN] = 0; /* max len = XX */
- if (get_user_by_handle(userlist, handle))
- dprintf(idx, "Someone already exists by that name.\n");
- else if (strchr(BADNICKCHARS, handle[0]) != NULL)
- dprintf(idx, "You can't start a nick with '%c'.\n", handle[0]);
- else if (!strcasecmp(handle, botnetnick))
- dprintf(idx, "Hey! That's MY name!\n");
- else {
- putlog(LOG_CMDS, "*", "#%s# +user %s %s", dcc[idx].nick, handle, host);
- userlist = adduser(userlist, handle, host, "-", 0);
- dprintf(idx, "Added %s (%s) with no password or flags.\n", handle, host);
- }
- }
- static void cmd_mns_user(struct userrec *u, int idx, char *par)
- {
- char *handle;
- struct userrec *u2;
- if (!par[0]) {
- dprintf(idx, "Usage: -user <nick>\n");
- return;
- }
- handle = newsplit(&par);
- u2 = get_user_by_handle(userlist, handle);
- if (!u2 || !u) {
- dprintf(idx, "No such user!\n");
- return;
- }
- if (isowner(u2->handle)) {
- dprintf(idx, "Can't remove the permanent bot owner!\n");
- return;
- }
- if ((u2->flags & USER_OWNER) && !(u->flags & USER_OWNER)) {
- dprintf(idx, "Can't remove the bot owner!\n");
- return;
- }
- if ((u2->flags & USER_BOT) && (bot_flags(u2) & BOT_SHARE) &&
- !(u->flags & USER_OWNER)) {
- dprintf(idx, "You can't remove shared bots.\n");
- return;
- }
- if ((u->flags & USER_BOTMAST) && !(u->flags & USER_MASTER) &&
- !(u2->flags & USER_BOT)) {
- dprintf(idx, "Can't remove users who aren't bots!\n");
- return;
- }
- if (deluser(handle)) {
- putlog(LOG_CMDS, "*", "#%s# -user %s", dcc[idx].nick, handle);
- dprintf(idx, "Deleted %s.\n", handle);
- } else
- dprintf(idx, "Failed.\n");
- }
- static void cmd_pls_host(struct userrec *u, int idx, char *par)
- {
- char *handle, *host;
- struct userrec *u2;
- struct list_type *q;
- struct flag_record fr =
- {FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
- Context;
- handle = newsplit(&par);
- if (!par[0]) {
- dprintf(idx, "Usage: +host <handle> <newhostmask>\n");
- return;
- }
- host = newsplit(&par);
- u2 = get_user_by_handle(userlist, handle);
- if (!u2) {
- dprintf(idx, "No such user.\n");
- return;
- }
- for (q = get_user(&USERENTRY_HOSTS, u); q; q = q->next)
- if (!strcasecmp(q->extra, host)) {
- dprintf(idx, "That hostmask is already there.\n");
- return;
- }
- get_user_flagrec(u, &fr, NULL);
- if ((u->flags & USER_BOTMAST) && !(u->flags & USER_MASTER) &&
- !(u2->flags & USER_BOT) && !chan_master(fr)) {
- dprintf(idx, "You can't add hostmasks to non-bots.\n");
- return;
- }
- if (!(u->flags & USER_OWNER) && (u2->flags & USER_BOT) &&
- (bot_flags(u2) & BOT_SHARE)) {
- dprintf(idx, "You can't add hostmasks to share-bots.\n");
- return;
- }
- if ((u2->flags & USER_OWNER) &&
- !(u->flags & USER_OWNER) && strcasecmp(handle, dcc[idx].nick)) {
- dprintf(idx, "Can't add hostmasks to the bot owner.\n");
- return;
- }
- putlog(LOG_CMDS, "*", "#%s# +host %s %s", dcc[idx].nick, handle, host);
- addhost_by_handle(handle, host);
- dprintf(idx, "Added '%s' to %s\n", host, handle);
- }
- static void cmd_mns_host(struct userrec *u, int idx, char *par)
- {
- char *handle, *host;
- struct userrec *u2;
- struct flag_record fr =
- {FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
- if (!par[0]) {
- dprintf(idx, "Usage: -host [handle] <hostmask>\n");
- return;
- }
- handle = newsplit(&par);
- if (par[0]) {
- host = newsplit(&par);
- u2 = get_user_by_handle(userlist, handle);
- } else {
- host = handle;
- handle = dcc[idx].nick;
- u2 = u;
- }
- if (!u2 || !u) {
- dprintf(idx, "No such user.\n");
- return;
- }
- if (strcasecmp(handle, dcc[idx].nick)) {
- get_user_flagrec(u, &fr, NULL);
- if (!(u2->flags & USER_BOT) && !(u->flags & USER_MASTER) &&
- !chan_master(fr)) {
- dprintf(idx, "You can't remove hostmasks from non-bots.\n");
- return;
- } else if ((u2->flags & USER_BOT) && (bot_flags(u2) & BOT_SHARE) &&
- !(u->flags & USER_OWNER)) {
- dprintf(idx, "You can't remove hostmask from a shared bot.\n");
- return;
- } else if ((u2->flags & USER_OWNER) && !(u->flags & USER_OWNER) &&
- (u2 != u)) {
- dprintf(idx, "Can't remove hostmasks from the bot owner.\n");
- return;
- } else if (!(u->flags & USER_BOTMAST) && !chan_master(fr)) {
- dprintf(idx, "Permission denied.\n");
- return;
- }
- }
- if (delhost_by_handle(handle, host)) {
- putlog(LOG_CMDS, "*", "#%s# -host %s %s", dcc[idx].nick, handle, host);
- dprintf(idx, "Removed '%s' from %s\n", host, handle);
- } else
- dprintf(idx, "Failed.\n");
- }
- static void cmd_modules(struct userrec *u, int idx, char *par)
- {
- int ptr;
- Context;
- if (!par[0])
- dprintf(idx, "Usage: modules <bot>\n");
- else {
- putlog(LOG_CMDS, "*", "#%s# modules %s", dcc[idx].nick, par);
- if ((ptr = nextbot(par)) >= 0)
- dprintf(ptr, "v %s %s %d:%s\n", botnetnick, par, dcc[idx].sock,
- dcc[idx].nick);
- else
- dprintf(idx, "No such bot online.\n");
- }
- }
- /* DCC CHAT COMMANDS */
- /* function call should be:
- * int cmd_whatever(idx,"parameters");
- * as with msg commands, function is responsible for any logging
- */
- cmd_t C_dcc[] =
- {
- {"+bot", "t", (Function) cmd_pls_bot, NULL},
- {"+host", "tm|m", (Function) cmd_pls_host, NULL},
- {"+ignore", "m", (Function) cmd_pls_ignore, NULL},
- {"+user", "m", (Function) cmd_pls_user, NULL},
- {"-bot", "t", (Function) cmd_mns_user, NULL},
- {"-host", "", (Function) cmd_mns_host, NULL},
- {"-ignore", "m", (Function) cmd_mns_ignore, NULL},
- {"-user", "m", (Function) cmd_mns_user, NULL},
- {"addlog", "to|o", (Function) cmd_addlog, NULL},
- {"away", "", (Function) cmd_away, NULL},
- {"back", "", (Function) cmd_back, NULL},
- {"backup", "m|m", (Function) cmd_backup, NULL},
- {"banner", "t", (Function) cmd_banner, NULL},
- {"binds", "m", (Function) cmd_binds, NULL},
- {"boot", "t", (Function) cmd_boot, NULL},
- {"botattr", "t", (Function) cmd_botattr, NULL},
- {"botinfo", "t", (Function) cmd_botinfo, NULL},
- {"bots", "", (Function) cmd_bots, NULL},
- {"bottree", "t", (Function) cmd_bottree, NULL},
- {"chaddr", "t", (Function) cmd_chaddr, NULL},
- {"chat", "", (Function) cmd_chat, NULL},
- {"chattr", "m|m", (Function) cmd_chattr, NULL},
- {"chnick", "t", (Function) cmd_chnick, NULL},
- {"chpass", "t", (Function) cmd_chpass, NULL},
- {"comment", "m", (Function) cmd_comment, NULL},
- {"console", "to|o", (Function) cmd_console, NULL},
- {"dccstat", "t", (Function) cmd_dccstat, NULL},
- {"debug", "m", (Function) cmd_debug, NULL},
- {"die", "n", (Function) cmd_die, NULL},
- {"echo", "", (Function) cmd_echo, NULL},
- {"fixcodes", "", (Function) cmd_fixcodes, NULL},
- {"help", "", (Function) cmd_help, NULL},
- {"ignores", "m", (Function) cmd_ignores, NULL},
- {"link", "t", (Function) cmd_link, NULL},
- {"loadmod", "n", (Function) cmd_loadmod, NULL},
- {"match", "to|o", (Function) cmd_match, NULL},
- {"me", "", (Function) cmd_me, NULL},
- {"module", "m", (Function) cmd_module, NULL},
- {"modules", "n", (Function) cmd_modules, NULL},
- {"motd", "", (Function) cmd_motd, NULL},
- {"newpass", "", (Function) cmd_newpass, NULL},
- {"nick", "", (Function) cmd_nick, NULL},
- {"page", "", (Function) cmd_page, NULL},
- {"quit", "", (Function) 0, NULL},
- {"rehash", "m", (Function) cmd_rehash, NULL},
- {"rehelp", "n", (Function) cmd_rehelp, NULL},
- {"relay", "t", (Function) cmd_relay, NULL},
- {"reload", "m|m", (Function) cmd_reload, NULL},
- {"restart", "m", (Function) cmd_restart, NULL},
- {"save", "m|m", (Function) cmd_save, NULL},
- {"set", "n", (Function) cmd_set, NULL},
- {"simul", "n", (Function) cmd_simul, NULL},
- {"status", "m|m", (Function) cmd_status, NULL},
- {"strip", "", (Function) cmd_strip, NULL},
- {"su", "", (Function) cmd_su, NULL},
- {"tcl", "n", (Function) cmd_tcl, NULL},
- {"trace", "", (Function) cmd_trace, NULL},
- {"unlink", "t", (Function) cmd_unlink, NULL},
- {"unloadmod", "n", (Function) cmd_unloadmod, NULL},
- {"uptime", "m|m", (Function) cmd_uptime, NULL},
- {"vbottree", "t", (Function) cmd_vbottree, NULL},
- {"who", "", (Function) cmd_who, NULL},
- {"whois", "to|o", (Function) cmd_whois, NULL},
- {"whom", "", (Function) cmd_whom, NULL},
- {0, 0, 0, 0}
- };
|